Note: This tutorial assumes that you have completed the previous tutorials: Preparing a new script (python).
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

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, gripper, torso 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_left", "arm_right", "gripper_left", "gripper_right", "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, a sequence like this might be suitable:

   1     def Run(self):
   2         rospy.loginfo("Grasping an object...")
   3 
   4         # prepare for grasping
   5         self.sss.move("gripper_left","open")
   6         self.sss.move("arm_left","arm_to_tray")
   7 
   8         # grasp the object that is given to the robot
   9         self.sss.move("gripper_left","close")
  10 
  11         # move arm to torso for navigation
  12         self.sss.move("arm_left","side")

Experiment a little bit with these commands. You could for example try to grasp something from a table.

You might also want to add some commands for the torso:

   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","front_down")
   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_navigation_global 2dnav_ros_dwa.launch

Wiki: cob_script_server/Tutorials/Using the move command (python) (last edited 2019-09-24 11:02:32 by HannesBachter)