Skip to content

Commit 462abc6

Browse files
committed
blenderRCBPanel: add combobox for selecting the frame
1 parent 33b1b6a commit 462abc6

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

script/blenderRCBPanel/blenderRCBPanel.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
dynComp = iDynTree.KinDynComputations()
3737
iDynTreeModel = None
3838

39+
list_of_links = []
40+
3941

4042

4143
# ------------------------------------------------------------------------
@@ -192,6 +194,9 @@ def generate_joint_classes(self):
192194
# Scene Properties
193195
# ------------------------------------------------------------------------
194196

197+
def getLinks(self, context):
198+
return list_of_links
199+
195200
class MyProperties(PropertyGroup):
196201

197202
my_bool: BoolProperty(
@@ -294,20 +299,19 @@ class MyProperties(PropertyGroup):
294299
max=360.0
295300
)
296301

297-
my_baseframe: StringProperty(
298-
name="Base frame name",
299-
description="Choose the base frame:",
300-
default="root_link",
301-
maxlen=1024
302+
my_baseframeenum: EnumProperty(
303+
name="Base frame name:",
304+
description="Select the base frame:",
305+
items=getLinks
302306
)
303-
my_endeffectorframe: StringProperty(
304-
name="End-effector frame name",
305-
description="Choose the end-effector frame:",
306-
default="",
307-
maxlen=1024
307+
my_eeframeenum: EnumProperty(
308+
name="End-effector frame name:",
309+
description="Select the end-effector frame:",
310+
items=getLinks
308311
)
309312

310313

314+
311315
class ListItem(PropertyGroup):
312316
value: StringProperty(
313317
name="Name",
@@ -479,8 +483,8 @@ def execute(self, context):
479483
#bpy.ops.object.wm_ot_reachTarget
480484
mytool = scene.my_tool
481485

482-
base_frame = mytool.my_baseframe
483-
endeffector_frame = mytool.my_endeffectorframe
486+
base_frame = mytool.my_baseframeenum
487+
endeffector_frame = mytool.my_eeframeenum
484488

485489
# TODO substitute the traversal part with this block after
486490
# DHChain has been added to the bindings
@@ -640,8 +644,8 @@ def draw(self, context):
640644

641645
reach_box = layout.box()
642646
reach_box.label(text="Reach target")
643-
reach_box.row(align=True).prop(mytool, "my_baseframe")
644-
reach_box.row(align=True).prop(mytool, "my_endeffectorframe")
647+
reach_box.row(align=True).prop(mytool, "my_baseframeenum")
648+
reach_box.row(align=True).prop(mytool, "my_eeframeenum")
645649

646650
reach_box.label(text="Position")
647651
reach_box.row(align=True).prop(mytool, "my_reach_x")
@@ -730,6 +734,12 @@ def configure_ik():
730734
mdlLoader.loadModelFromString(model_urdf)
731735
iDynTreeModel = mdlLoader.model()
732736

737+
for link_idx in range(iDynTreeModel.getNrOfLinks()):
738+
list_of_links.append((iDynTreeModel.getLinkName(link_idx),
739+
iDynTreeModel.getLinkName(link_idx),
740+
""))
741+
742+
733743
inverseKinematics.setModel(iDynTreeModel)
734744
# Setup the ik problem
735745
inverseKinematics.setCostTolerance(0.0001)
@@ -742,4 +752,4 @@ def configure_ik():
742752
s = iDynTree.VectorDynSize(dofs)
743753
for dof in range(dofs):
744754
s.setVal(dof, 0.0)
745-
dynComp.setJointPos(s)
755+
dynComp.setJointPos(s)

0 commit comments

Comments
 (0)