====== Poppy Software ======
{{tag>poppy software}}
Poppy uses pypot for control. It is a python library : http://poppy-project.github.io/pypot/index.html
On the top of pypot are libraries for Poppy creatures : https://github.com/poppy-project
===== Software setup =====
The quick install consists in:
* install pypot : sudo pip install pypot
* install your popppy creature. For instance for poppy humanoid : sudo pip install poppy_humanoid
* to check that the libraries are installed correctly, execute with python the code:
from poppy_humanoid import PoppyHumanoid
poppy = PoppyHumanoid()
A good guide can be found here: https://github.com/HumaRobotics/poppy-examples/blob/master/doc/softwareGuide/softwareGuide.pdf. More technical details about pypot, you can look at [[http://poppy-project.github.io/pypot/intro.html#installation|installation of pypot]].
++++ In detail, this is how I installed the software|
* install pip https://pip.pypa.io/en/latest/installing.html
* install the python pypot library : sudo easy_install pypot
or sudo pip install pypot
* install the poppy_humanoid library: download Poppy model git clone https://github.com/poppy-project/poppy-humanoid.git
* then go to the where-you-downloaded-poppy-humanoid/software folder and install with the terminal command python setup.py install
* To check if everything is installed correctly, you can run the following code from folder where-you-downloaded-poppy-humanoid/software. If it runs without raising an error, everything is probably installed correctly:
import time
import math
import json
import pypot.robot
ergo = pypot.robot.from_json('poppy_torso/configuration/poppy_torso.json')
++++
If you have trouble detecting your motors, you can follow the step 2 of https://forum.poppy-project.org/t/first-start-of-poppy and run in python
import pypot.dynamixel
dxl_io_upper = pypot.dynamixel.DxlIO('PORT_UPPER_BODY')
dxl_io_lower = pypot.dynamixel.DxlIO('PORT_LOWER_BODY')
print dxl_io_upper.scan(range(60))
print dxl_io_lower.scan(range(60))
===== Embedded odroid =====
The poppy humanoid has an embedded [[odroid xu 4]], where these libraries have been installed (pypot and poppy-humanoid).
You can log to the computer by ssh using the network labo-sid: odroid@poppy1 (mdp: odroid)
The new Poppy from february 2017 has a Rasberry Pi 3 instead of odroid xu 4. As the ethernet port is not available, the connexion to the Rasberry Pi is done using Wifi. If your wifi network is not known by the robot, you need to plug a keyboard to the Rasberry Pi and use the touchscreen to configure the new connexion.
Once the computer and the robot are in the same network, you can log to the robot using ssh: poppy@poppy.local (mdp: poppy).
Note that if you want to manage the wifi networks configurations of the robot in ssh, you need to modify the file: /etc/wpa_supplicant/wpa_supplicant.conf.
===== First program =====
* Simple motor command :
from poppy_humanoid import PoppyHumanoid
import time
import pypot.robot
poppy = PoppyHumanoid() # or poppy = pypot.robot.from_config(poppy_config)
poppy.head_z.compliant =False
poppy.head_z.max_torque=20
poppy.head_z.goal_position=20
poppy.head_z.goto_position(-20,3)
time.sleep(5)
print "before moving"
poppy.head_z.goto_position(40,3, wait=True)
print "after moving"
* Make it reset to its standing position :
from poppy_humanoid import PoppyHumanoid
import time
import pypot.robot
poppy = PoppyHumanoid() # or poppy = pypot.robot.from_config(poppy_config)
for m in poppy.motors:
m.compliant = False
for m in poppy.motors:
m.goto_position(0, 5)
time.sleep(5)
* to record and replay a movement https://poppy-project.github.io/pypot/move.html.
++++ code|
#importer des fonctions
import time
import math
import json
import pypot.robot
from pypot.primitive.move import MoveRecorder, Move, MovePlayer
#se connecter au robot
ergo = pypot.robot.from_json('poppy_torso/configuration/poppy_torso_broken.json')
#on met le robot debout: tous les moteurs a 0
for m in ergo.motors:
m.compliant=False
m.goal_position=0.0
#imprimer tous les noms des moteurs
for x in range(0,14):
print "motor ",x," is ", ergo.motors[x].name
#indiquer quels moteurs on relache
indices=[10,11,12,13]
for m in [ergo.motors[x] for x in indices]:
m.compliant=True
#commencer l'enregistrement
move_recorder = MoveRecorder(ergo, 50, ergo.motors)
move_recorder.start()
print "start"
#duree de l'enregistrement
time.sleep(6)
#arreter l'enregistrement
print "stop"
move_recorder.stop()
for m in range(0,14):
ergo.motors[m].compliant=False
#sauvegrader le fichier sous le nom 'my_nice_move.txt'
with open('my_nice_move.txt', 'w') as f:
move_recorder.move.save(f)
#rejouer le mouvement sauvegarde sans le fichier
with open('my_nice_move.txt') as f:
m = Move.load(f)
ergo.compliant = False
move_player = MovePlayer(ergo, m)
move_player.start()
++++
Other examples can be tested from https://github.com/HumaRobotics/poppy-examples
===== Control the robot =====
You have several ways to control the Poppy robot, using pre-built Pypot methods/class:
* Setting the //goal_position// attribute: the joint will immediately try to go as close to the goal as possible (given the angle limits) w.r.t the maximum speed allowed on this joint (which is set via the //moving_speed// attribute). This will not take the //present_speed// attribute of the joint into account;
* Setting the //goal_speed// attribute: the joint will immediately set the speed of the joint to the given value, replacing the current //goal_position// with the angle limit corresponding to the speed direction;
* Using the //goto_position(goal,time)// method: this will actually set the //goal_position// to the given goal value, and also set the //moving_speed// of the joint to (goal - present_position)/t;
* Using the higher level //MovePlayer// class: this class implements a //LoopPrimitive// in order to update frequently the //goal_position// attribute of the joint (N.B: the //moving_speed// attribute __**is not modified**__ by the class when playing the motion and the robot __**will keep in mind the last //moving_speed//**__ sent).
If the //moving_speed// attribute is set to 0, then the joint will move at full speed (N.B: If you're unsure of the //moving_speed// you sent last to the robot and want to play a movement using //MovePlayer//, it is **__recommended__** to initially set the //moving_speed// of all the involved joints to 0.0).