4: Robot Motion
This tutorial shows you how to play system motions, create, save, and replay custom motions, and how to stream motions from one robot to another.
📄 Nao Motion Tutorial
Connecting to the Nao
Your computer must be connected to the same network as the Nao. Make sure the Nao crouches safely in its resting position. Press on its chest button to turn it on. Once it is fully awake, press the chest button again to get its IP address. Replace “XXX” with this IP address in the demo script.
self.nao_ip = "XXX"
Playing Animations and Setting Posture
We’re following the demo_nao_motion script which can be found here and which contains more detailed comments.
Make sure you are connected to your Nao.
Set posture or play animation:
To set the posture: Second argument is the speed (NOTE: setting the speed too high may result in an error)
nao.motion.request(NaoPostureRequest("Stand", 0.5))
To play an animation:
Note
If you are playing a standing animation, make sure you put the Nao in a standing posture beforehand
nao.motion.request(NaoqiAnimationRequest("animations/Stand/Gestures/Hey_1"))
A list of all Nao animations can be found in the Nao animation documentation.
A complete script for this tutorial can be found here: demo_nao_motion.py
Recording and Playing Custom Animations
We’re following the demo_nao_motion_recorder script which can be found here <https://github.com/Social-AI-VU/sic_applications/blob/main/demos/nao/demo_nao_motion_recorder.py> and which contains more detailed comments.
Make sure you are connected to your Nao.
Specify which Nao parts you want to record (NOTE: a ‘chain’ is a group of body parts, or a link of joints). The full list can be found in the Nao body parts documentation.
chain = ["LArm", "RArm"]
Set the stiffness of these parts to 0 so that you can move them:
nao.stiffness.request(Stiffness(stiffness=0.0, joints=chain))
Start the recording
Set a ‘record_time’ variable. This is how long it will record the Nao’s motion before saving it.
It is recommended to include a message to indicate when to start moving the Nao
record_time = 10
print("Start moving the robot! (not too fast)")
nao.motion_record.request(StartRecording(chain))
time.sleep(record_time)
Save the motion, give it a name:
recording = nao.motion_record.request(StopRecording())
recording.save(MOTION_NAME)
Set the stiffness of the limbs to 0.7 so that the motors can move them. Play the recording back:
nao.stiffness.request(Stiffness(.7, chain))
recording = NaoqiMotionRecording.load(MOTION_NAME)
nao.motion_record.request(PlayRecording(recording))
📹: Video Tutorial
Further reading
If you want some further reading, check out this section.