Démonstration de mai

Connexion au robot


In [1]:
from cherry import Cherry

In [2]:
cherry = Cherry()
cherry.setup()
poppy = cherry.robot


---------------------------------------------------------------------------
SerialException                           Traceback (most recent call last)
<ipython-input-2-dd9588846b2f> in <module>()
----> 1 cherry = Cherry()
      2 cherry.setup()
      3 poppy = cherry.robot

C:\Users\laura\Desktop\Defis H\Code\cherry-project\src\cherry.pyc in __init__(self, simulator)
     88         #Vrai :
     89         else:
---> 90             self.robot = from_json("../utils/poppy_torso_config.json")
     91             self.robot.start_sync()
     92 

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\robot\config.pyc in from_json(json_file, sync)
    198         config = json.load(f)
    199 
--> 200     return from_config(config, sync=sync)
    201 
    202 

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\robot\config.pyc in from_config(config, strict, sync)
     54 
     55         attached_ids = [m.id for m in attached_motors]
---> 56         dxl_io = dxl_io_from_confignode(config, c_params, attached_ids, strict)
     57 
     58         check_motor_limits(config, dxl_io, motor_names)

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\robot\config.pyc in dxl_io_from_confignode(config, c_params, ids, strict)
    103 
    104     if port == 'auto':
--> 105         port = pypot.dynamixel.find_port(ids, strict)
    106         logger.info('Found port {} for ids {}'.format(port, ids))
    107 

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\dynamixel\__init__.pyc in find_port(ids, strict)
     47         for DxlIOCls in (DxlIO, Dxl320IO):
     48             try:
---> 49                 with DxlIOCls(port) as dxl:
     50                     founds = len(dxl.scan(ids))
     51 

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\dynamixel\io\abstract_io.pyc in __init__(self, port, baudrate, timeout, use_sync_read, error_handler_cls, convert)
     70         self._serial_lock = threading.Lock()
     71 
---> 72         self.open(port, baudrate, timeout)
     73 
     74     def __enter__(self):

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\dynamixel\io\abstract_io.pyc in open(self, port, baudrate, timeout)
     93 
     94             """
---> 95         self._open(port, baudrate, timeout)
     96         logger.info("Opening port '%s'", self.port,
     97                     extra={'port': port,

C:\Python27\lib\site-packages\pypot-2.3.0-py2.7.egg\pypot\dynamixel\io\abstract_io.pyc in _open(self, port, baudrate, timeout, max_recursion)
    125                     self._serial.close()
    126 
--> 127                 self._serial = serial.Serial(port, baudrate, timeout=timeout)
    128                 self.__used_ports.add(port)
    129 

C:\Python27\lib\site-packages\pyserial-2.7-py2.7-win32.egg\serial\serialwin32.pyc in __init__(self, *args, **kwargs)
     36 
     37 
---> 38         SerialBase.__init__(self, *args, **kwargs)
     39 
     40     def open(self):

C:\Python27\lib\site-packages\pyserial-2.7-py2.7-win32.egg\serial\serialutil.pyc in __init__(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, writeTimeout, dsrdtr, interCharTimeout)
    280 
    281         if port is not None:
--> 282             self.open()
    283 
    284     def isOpen(self):

C:\Python27\lib\site-packages\pyserial-2.7-py2.7-win32.egg\serial\serialwin32.pyc in open(self)
     64         if self.hComPort == win32.INVALID_HANDLE_VALUE:
     65             self.hComPort = None    # 'cause __del__ is called anyway
---> 66             raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))
     67 
     68         try:

SerialException: could not open port 'COM8': WindowsError(5, 'Acc\xe8s refus\xe9.')

Lancement de la présentation


In [3]:
poppy.normal_behave.start()

In [4]:
for m in poppy.arms + poppy.head:
    m.compliant = True

Vous voulez faire dire quelque chose à Cherry, c'est par ici !


In [5]:
filename = '../utils/text_to_say.txt'

In [6]:
poppy.say_text.start(filename)

Vision


In [7]:
poppy.run_look.start()


camera detectee!.
cascade ok
  cliquer sur 'Echap' pour quitter
  cliquer sur 'a' pour ajouter une image a la base de donnees
  cliquer sur 't' pour retenir le modele
camera detectee!.
cascade: ../utils/opencv/data/lbpcascades/lbpcascade_frontalface.xml
Nouvel etat: 73 images 6 personnes

In [8]:
poppy.tracking_behave.start()

In [9]:
poppy.tracking_behave.stop()

Prendre le robot en main ? Bouger le bras droit et regarder !


In [10]:
poppy.copy_arm_behave.start()

In [11]:
poppy.copy_arm_behave.stop()

In [12]:
for m in poppy.arms + poppy.head:
    m.compliant = True

Enregistrez vos propres mouvements maintenant

On enregistre le mouvement


In [13]:
from pypot.primitive.move import MoveRecorder, Move, MovePlayer

In [14]:
filename_record = '../utils/move_recorded/move10'

Quel moteurs?


In [15]:
r_motors_group = poppy.arms

On lance le record


In [16]:
move_recorder = MoveRecorder(poppy, 50, r_motors_group)
for m in poppy.l_arm:
    m.compliant = True

for m in poppy.r_arm:
    m.compliant = True
    
for m in poppy.torso:
    m.compliant = False
    
for m in poppy.head:
    m.compliant = True

In [17]:
move_recorder.start()

In [18]:
move_recorder.stop()

with open(filename_record, 'w') as f:
    move_recorder.move.save(f)

Puis on le rejoue


In [19]:
with open(filename_record) as f:
    m = Move.load(f)

poppy.compliant = False

move_player = MovePlayer(poppy, m)
move_player.start()

In [20]:
for m in poppy.arms + poppy.head:
    m.compliant = True

On lie les gestes avec de la paroles pour un vrai discours


In [26]:
import time

In [27]:
with open(filename_record) as f:
    m = Move.load(f)

poppy.compliant = False

move_player = MovePlayer(poppy, m)
move_player.start()
time.sleep(1)
poppy.say_text.start(filename)

Controllez le robot au niveau plus bas ? On a accès à tout les moteurs !


In [64]:
{(m.present_position, m.name) for m in poppy.motors}


Out[64]:
{(-33.98, u'r_elbow_y'),
 (-24.92, u'l_elbow_y'),
 (-7.16, u'r_arm_z'),
 (-5.030000000000001, u'l_shoulder_y'),
 (-1.27, u'l_arm_z'),
 (-0.84, u'bust_y'),
 (-0.48, u'abs_z'),
 (-0.44, u'head_z'),
 (0.3299999999999983, u'r_shoulder_x'),
 (0.4, u'bust_x'),
 (0.41000000000000014, u'head_y'),
 (2.4399999999999977, u'r_shoulder_y'),
 (8.11, u'l_shoulder_x')}

In [67]:
for m in poppy.motors:
    m.compliant = False

poppy.head_y.goto_position(0, 2)
poppy.head_z.goto_position(0, 2)

poppy.abs_z.goto_position(0, 2)
poppy.bust_x.goto_position(0, 2)
poppy.bust_y.goto_position(0, 2)

poppy.l_shoulder_y.goto_position(-8, 2) 
poppy.l_shoulder_x.goto_position(10, 2)
poppy.l_arm_z.goto_position(20, 2)
poppy.l_elbow_y.goto_position(-25, 2)

poppy.r_shoulder_y.goto_position(-8, 2)
poppy.r_shoulder_x.goto_position(-10, 2)
poppy.r_arm_z.goto_position(-20, 2)
poppy.r_elbow_y.goto_position(-25, 2)

Zone de sécurité

Compliance


In [23]:
c_motors_group = cherry.robot.head + cherry.robot.arms

In [24]:
for m in c_motors_group:
    m.compliant = True

Speed Limite


In [12]:
for m in cherry.robot.motors:
    m.moving_speed = 70

In [21]:
poppy.wave_behave.start()

In [22]:
poppy.wave_behave.stop()

In [ ]:
poppy.speak.start('Combien font 9 fois 9')

In [51]:
poppy.speak.start('Bien joué !')

In [233]:
poppy.speak.start('Raté, essaye encore.')

In [133]:
poppy.take_left_ear_behave.start()

In [43]:
poppy.head_idle.stop()

In [134]:
poppy.normal_behave.start()

In [ ]: