@@ -30,43 +30,27 @@ class Body {
3030    parameter . get ( parameter_  =>  { 
3131      // Joint names 
3232      this . jointNames  =  { } ; 
33-       // Arm joint names. N.B.: the suffices 'left' and 'right' 
34-       // must be added 
35-       this . jointNames . arm  =  [ ] ; 
36-       this . jointNames . leftArm  =  [ ] ; 
37-       this . jointNames . rightArm  =  [ ] ; 
38-       for  ( const  jointName  in  parameter_ . arm . joint_names . values ( ) )  {  // eslint-disable-line guard-for-in 
39-         this . jointNames . arm . push ( `${ jointName }  ` ) ; 
40-         this . jointNames . leftArm . push ( `${ jointName }  _left` ) ; 
41-         this . jointNames . rightArm . push ( `${ jointName }  _right` ) ; 
42-       } 
43- 
44-       // Torso joint name 
45-       this . jointNames . torso  =  parameter_ . torso . joint_names ; 
46- 
47-       // Default joint configuration. N.B., the configurations for the left 
48-       // and right arm are equal 
4933      this . defaultConfigurations  =  { } ; 
50-       this . defaultConfigurations . torso  =  parameter_ . torso . default_configurations ; 
51-        this . defaultConfigurations . arm   =   parameter_ . arm . default_configurations ; 
52-       this . defaultConfigurations . leftArm   =   parameter_ . arm . default_configurations ; 
53-       this . defaultConfigurations . rightArm   =   parameter_ . arm . default_configurations ; 
54-     } ) ; 
55- 
56-      // Define the gripper action 
57-     this . leftGripperAction   =   new   ActionClient ( { 
58-       ros , 
59-       serverName :  'left_arm/gripper/action' , 
60-        actionName :  'tue_manipulation_msgs/GripperCommandAction' , 
61-       timeout :  0 , 
62-     } ) ; 
63- 
64-     // Define the gripper action 
65-     this . rightGripperAction   =   new   ActionClient ( { 
66-       ros , 
67-       serverName :  'right_arm/gripper/action' , 
68-       actionName :  'tue_manipulation_msgs/GripperCommandAction' , 
69-       timeout :  0 , 
34+       this . grippers  =  { } ; 
35+ 
36+       for   ( const   [ partName ,   part ]   of   Object . entries ( parameter_ ) )   { 
37+          if   ( Object . prototype . hasOwnProperty . call ( part ,   'joint_names' ) )   { 
38+            this . jointNames [ partName ]   =   part . joint_names ; 
39+          } 
40+ 
41+          if   ( Object . prototype . hasOwnProperty . call ( part ,   'default_configurations' ) )   { 
42+            this . defaultConfigurations [ partName ]   =   part . default_configurations ; 
43+          } 
44+ 
45+          if   ( Object . prototype . hasOwnProperty . call ( part ,   'ac_gripper' ) )   { 
46+            this . grippers [ partName ]   =   new   ActionClient ( { 
47+             ros , 
48+              serverName :  part . ac_gripper , 
49+              actionName :  'tue_manipulation_msgs/GripperCommandAction' , 
50+              timeout :  0 , 
51+            } ) ; 
52+          } 
53+       } 
7054    } ) ; 
7155  }  // End of constructor 
7256
@@ -86,36 +70,36 @@ class Body {
8670        trajectory : { 
8771          /* eslint camelcase:0 */ 
8872          joint_names : this . jointNames [ cmd . body_part ] , 
89-           points : [ { positions : this . defaultConfigurations [ cmd . body_part ] [ cmd . configuration ] } ] , 
73+           points : [ { 
74+             positions : this . defaultConfigurations [ cmd . body_part ] [ cmd . configuration ] , 
75+             time_from_start : { secs : 2 } , 
76+           } ] , 
9077        } , 
9178        goal_time_tolerance : { 
9279          secs : 5 , 
9380        } , 
9481      } , 
9582    } ) ; 
83+     console . debug ( goal ) ; 
9684
9785    // Send the goal with a default timeout of 10.0 seconds 
9886    goal . send ( 10 ) ; 
9987  }  // End of sendGoal 
10088
10189  /** 
10290   * Sends a gripper goal 
103-    * @param  {object } cmd: object containing 'side' ('left' or 'right')  and 'direction' ('open' or 'close') 
91+    * @param  {object } cmd: object containing 'side' and 'direction' ('open' or 'close') 
10492   */ 
10593  sendGripperGoal ( cmd )  { 
10694    console . log ( 'Robot body: gripper goal:' ,  cmd ) ; 
10795
108-     let  actionClient ; 
109-     // Get the side 
110-     if  ( cmd . side  ===  'left' )  { 
111-       actionClient  =  this . leftGripperAction ; 
112-     }  else  if  ( cmd . side  ===  'right' )  { 
113-       actionClient  =  this . rightGripperAction ; 
114-     }  else  { 
115-       console . error ( 'Gripper command side must be either left or right. Right now, it is' ,  cmd . side ) ; 
96+     if  ( ! Object . prototype . hasOwnProperty . call ( this . grippers ,  cmd . side ) )  { 
97+       console . error ( `Gripper command side must be one of [${ Object . keys ( this . grippers ) }  ]. Right now, it is '${ cmd . side }  '` ) ; 
11698      return ; 
11799    } 
118100
101+     const  actionClient  =  this . grippers [ cmd . side ] ; 
102+ 
119103    // Get the direction: open or close. This is mapped to the enum defined in the action description 
120104    // int8 OPEN=-1 
121105    // int8 CLOSE=1 
0 commit comments