play_motion: How to play a pre-recorded motion#

This section contains an example of how to use replay a pre-recorded motion through the play_motion action server. We will show both a Python script example, and a direct command-line execution.

Play motion script example#

To play a motion by running a script:

 1from play_motion_msgs.msg import PlayMotionAction, PlayMotionGoal
 2from actionlib import SimpleActionClient
 3
 4def perform_motion():
 5
 6  self.motion_client = SimpleActionClient('/play_motion', PlayMotionAction)
 7  self.motion_client.wait_for_server()
 8
 9  goal = PlayMotionGoal()
10
11  # use here the desired motion ID from the table above
12  goal.motion_name = "bow"
13  goal.skip_planning = False
14  self.motion_client.send_goal_and_wait(goal)
15  rospy.loginfo("Movement done")

Publishing a motion through an action#

To play a motion by calling the ROS action /play_motion:

rostopic pub /play_motion/goal play_motion_msgs/PlayMotionActionGoal
 "header:
      seq: 0
      stamp:
        secs: 0
        nsecs: 0
      frame_id: ''
    goal_id:
      stamp:
        secs: 0
        nsecs: 0
      id: ''
    goal:
      motion_name: 'bow' # include here the motion name
      skip_planning: false
      priority: 0"