36
36
dynComp = iDynTree .KinDynComputations ()
37
37
iDynTreeModel = None
38
38
39
+ list_of_links = []
40
+
39
41
40
42
41
43
# ------------------------------------------------------------------------
@@ -192,6 +194,9 @@ def generate_joint_classes(self):
192
194
# Scene Properties
193
195
# ------------------------------------------------------------------------
194
196
197
+ def getLinks (self , context ):
198
+ return list_of_links
199
+
195
200
class MyProperties (PropertyGroup ):
196
201
197
202
my_bool : BoolProperty (
@@ -294,20 +299,19 @@ class MyProperties(PropertyGroup):
294
299
max = 360.0
295
300
)
296
301
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
302
306
)
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
308
311
)
309
312
310
313
314
+
311
315
class ListItem (PropertyGroup ):
312
316
value : StringProperty (
313
317
name = "Name" ,
@@ -479,8 +483,8 @@ def execute(self, context):
479
483
#bpy.ops.object.wm_ot_reachTarget
480
484
mytool = scene .my_tool
481
485
482
- base_frame = mytool .my_baseframe
483
- endeffector_frame = mytool .my_endeffectorframe
486
+ base_frame = mytool .my_baseframeenum
487
+ endeffector_frame = mytool .my_eeframeenum
484
488
485
489
# TODO substitute the traversal part with this block after
486
490
# DHChain has been added to the bindings
@@ -640,8 +644,8 @@ def draw(self, context):
640
644
641
645
reach_box = layout .box ()
642
646
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 " )
645
649
646
650
reach_box .label (text = "Position" )
647
651
reach_box .row (align = True ).prop (mytool , "my_reach_x" )
@@ -730,6 +734,12 @@ def configure_ik():
730
734
mdlLoader .loadModelFromString (model_urdf )
731
735
iDynTreeModel = mdlLoader .model ()
732
736
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
+
733
743
inverseKinematics .setModel (iDynTreeModel )
734
744
# Setup the ik problem
735
745
inverseKinematics .setCostTolerance (0.0001 )
@@ -742,4 +752,4 @@ def configure_ik():
742
752
s = iDynTree .VectorDynSize (dofs )
743
753
for dof in range (dofs ):
744
754
s .setVal (dof , 0.0 )
745
- dynComp .setJointPos (s )
755
+ dynComp .setJointPos (s )
0 commit comments