Note: This tutorial assumes that you have completed the previous tutorials: Preparing a new script (python).

Using the move command (python)

Description: This tutorial teaches you how to use the move function.

Tutorial Level: BEGINNER

Next Tutorial: Modifying parameter files

The Move command

By using the move command you can command any motion for components such as arm, tray, torso, hand and base. By combining these commands you write a first script.

Components are moved by using the move command:

Move(<component_name>,<parameter_name>,<blocking (optional)>)
  1. The first parameter specifies the component which shall be moved. Possible components are "arm", "tray", "sdh" (hand), "torso" and "base".

  2. The second parameter is the name of a parameter on the ROS parameter server which specifies a target position or trajectory. These parameters are specified in several .yaml-files in the <cob_script_server>/launch/ directory. More about modifying and adding new positions in the next tutorial Modifying parameter files. It is also possible to specify directly a position or trajectory instead of a name.

  3. The third parameter is optional and specifies the execution behavior to be blocking or non-blocking. More on the execution behaviour in the Specify execution behaviour. Possible values are True and False, default is True.

First moves

Back to your first script. Add some move-commands for some of the positions you find in the .yaml files to the Run-function and see what happens. For grasping an object and putting it on the tray, a sequence like this might be suitable:

   1     def Run(self):
   2         rospy.loginfo("Grasping an object from table...")
   3 
   4         # prepare for grasping
   5         self.sss.move("arm","pregrasp")
   6         self.sss.move("sdh","cylopen")
   7 
   8         # grasp the object
   9         self.sss.move("arm","grasp")
  10         self.sss.move("sdh","cylclosed")
  11 
  12         # put object on tray
  13         self.sss.move("tray","up")
  14         self.sss.move("arm","grasp-to-tablet")
  15         self.sss.move("sdh","cylopen")
  16 
  17         # draw arm back to folded position
  18         self.sss.move("arm","tablet-to-folded")
  19         self.sss.move("sdh","cylclosed")

Experiment a little bit with these commands. You could for example try to grasp from the tray instead of the table.

You might also want to add some commands for the torso so that Care-O-bot always looks to the back while grasping and to the front while the object is placed on the tray:

   1         self.sss.move("torso","front")
   2         self.sss.move("torso","back")

or make Care-O-bot nodding and shaking its head

   1         self.sss.move("torso","nod")
   2         self.sss.move("torso","shake")

or move the base

   1         self.sss.move("base","home")
   2         self.sss.move("base","kitchen")

Please note that for executing base movements you need to launch another .launch-file besides the script_server. To do this, open a new terminal and enter the following:

roslaunch cob_2dnav 2dnav.launch

Wiki: cob_script_server/Tutorials/Using the move command (python) (last edited 2011-03-17 09:55:14 by Witalij Siebert)