<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Record, Save, and Play Moves on a Poppy Creature
This notebook is still work in progress! Feedbacks are welcomed!
In this tutorial we will show how to
Step1:  Import the Move, Recorder and Player
Step2:  Create a Recorder for the robot Poppy
Step3:  Start the recording
First, turn the recorded motors compliant, so you can freely move them
Step4:  Starts the recording when you are ready!
Step5:  Stop the recording
Stop it when you are done demonstrating the movement.
Step6:  Turn back off the compliance.
Step7:  Get the recorder Move and store it on the disk
Save the recorded move on the text file named 'mymove.json'.
Step8:  Load a saved Move
Re-load it from the file jsut as an example purpose.
Step9:  Create a Move Player and Play Back a Recorded Move
First, create the object used to re-play a recorded Move.
Step10:  You can start the play back whenever you want
Step11:  You can play your move as many times as you want. Note, that we use the wait_to_stop method to wait for the first play abck to end before running it again.
<ASSISTANT_TASK:>
Python Code:
from poppy.creatures import PoppyErgo
poppy = PoppyErgo()
for m in poppy.motors:
    m.compliant = False
    m.goal_position = 0.0
Explanation: Record, Save, and Play Moves on a Poppy Creature
This notebook is still work in progress! Feedbacks are welcomed!
In this tutorial we will show how to:
* record moves by direct demonstration on a Poppy Creature
* save them to the disk - and re-load them
* play, and re-play the best moves
To follow this notebook, you should already have installed everything needed to control a Poppy Creature. The examples below used a Poppy Ergo but then can be easily transposed to a Poppy Humanoid or to any other creatures.
Connect to your Poppy Creature
First, connect to your Poppy Creature and put it in its "base" position so you can easily record motions.
Here we use a Poppy Ergo but you can replace it by a Poppy Humanoid.
End of explanation
# Import everything you need for recording, playing, saving, and loading Moves
# Move: object used to represent a movement
# MoveRecorder: object used to record a Move
# MovePlayer: object used to play (and re-play) a Move
from pypot.primitive.move import Move, MoveRecorder, MovePlayer
Explanation: Import the Move, Recorder and Player
End of explanation
record_frequency = 50.0 # This means that a new position will be recorded 50 times per second.
recorded_motors = [poppy.m4, poppy.m5, poppy.m6] # We will record the position of the 3 last motors of the Ergo
# You can also use alias for the recorded_motors
# e.g. recorder = MoveRecorder(poppy, record_frequency, poppy.tip)
# or even to record all motors position
# recorder = MoveRecorder(poppy, record_frequency, poppy.motors)
recorder = MoveRecorder(poppy, record_frequency, recorded_motors)
Explanation: Create a Recorder for the robot Poppy
End of explanation
for m in recorded_motors:
    m.compliant = True
Explanation: Start the recording
First, turn the recorded motors compliant, so you can freely move them:
End of explanation
recorder.start()
Explanation: Starts the recording when you are ready!
End of explanation
recorder.stop()
Explanation: Stop the recording
Stop it when you are done demonstrating the movement.
End of explanation
for m in recorded_motors:
    m.compliant = False
Explanation: Turn back off the compliance.
End of explanation
recorded_move = recorder.move
with open('mymove.json', 'w') as f:
    recorded_move.save(f)
Explanation: Get the recorder Move and store it on the disk
Save the recorded move on the text file named 'mymove.json'.
End of explanation
with open('mymove.json') as f:
    loaded_move = Move.load(f)
Explanation: Load a saved Move
Re-load it from the file jsut as an example purpose.
End of explanation
player = MovePlayer(poppy, loaded_move)
Explanation: Create a Move Player and Play Back a Recorded Move
First, create the object used to re-play a recorded Move.
End of explanation
player.start()
Explanation: You can start the play back whenever you want:
End of explanation
for _ in range(3):
    player.start()
    player.wait_to_stop()
Explanation: You can play your move as many times as you want. Note, that we use the wait_to_stop method to wait for the first play abck to end before running it again.
End of explanation
<END_TASK>