Playing Animations and Setting Posture
First, import the necessary functions from the SIC framework:
from sic_framework.devices import Nao from sic_framework.devices.common_naoqi.naoqi_motion import NaoPostureRequest, NaoqiAnimationRequest
Connect to the Nao (computer must be connected to the same network)
nao = Nao(ip="NAO_IP_HERE")
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:
nao.motion.request(NaoqiAnimationRequest("animations/Stand/Gestures/Hey_1"))
A list of all Nao animations can be found here.
A complete script for this demo can be found here: demo_nao_motion.py
Recording and Playing Custom Animations
First, import the necessary functions from the SIC framework:
from sic_framework.devices import Nao from sic_framework.devices.common_naoqi.naoqi_motion_recorder import ( NaoqiMotionRecording, NaoqiMotionRecorderConf, PlayRecording, StartRecording, StopRecording, ) from sic_framework.devices.common_naoqi.naoqi_stiffness import Stiffness
Connect to the Nao (computer must be connected to the same network)
nao = Nao(ip="NAO_IP_HERE")
Specify which Nao parts you want to record (NOTE: a ‘chain’ is a body part, or a group of joints):
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)
Play the recording back
Set the stiffness of the limbs to 0.7 so that the motors can move them
nao.stiffness.request(Stiffness(.7, chain)) recording = NaoqiMotionRecording.load(MOTION_NAME) nao.motion_record.request(PlayRecording(recording))
A complete script for this demo can be found here: demo_nao_motion_recorder.py