Lance une instance de Poppy sous VREP


In [20]:
# import os
import json
import requests
import pypot
import time

from pypot.vrep import from_vrep
from poppy.creatures import PoppyTorso
from cherry import Cherry

poppy = PoppyTorso(simulator='vrep')

from pypot.server.httpserver import HTTPRobotServer
 
server = HTTPRobotServer(poppy, host='127.0.0.2', port=8888)


from threading import Thread

Thread(target=lambda: server.run(quiet=True, server='wsgiref')).start()


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-20-49e3408ed6e5> in <module>()
      9 from cherry import Cherry
     10 
---> 11 poppy = PoppyTorso(simulator='vrep')
     12 
     13 from pypot.server.httpserver import HTTPRobotServer

C:\Users\jguichar\Anaconda\lib\site-packages\poppy\creatures\abstractcreature.pyc in __new__(cls, base_path, config, simulator, scene, host, port, id, use_snap, snap_host, snap_port, snap_quiet, use_http, http_host, http_port, http_quiet, use_remote, remote_host, remote_port, start_background_services, sync, **extra)
    105                     poppy_creature = from_vrep(config, host, port, scene)
    106                 except VrepConnectionError:
--> 107                     raise IOError('Connection to V-REP failed!')
    108 
    109             elif simulator == 'poppy-simu':

IOError: Connection to V-REP failed!

Verifier que tout les primitives sont accessibles


In [3]:
# Get attached primitive list
import requests
r = requests.get('http://127.0.0.2:8888/primitive/list.json')
r.json()


---------------------------------------------------------------------------
ConnectionError                           Traceback (most recent call last)
<ipython-input-3-91da54d90153> in <module>()
      1 # Get attached primitive list
      2 import requests
----> 3 r = requests.get('http://127.0.0.2:8888/primitive/list.json')
      4 r.json()

C:\Users\jguichar\Anaconda\lib\site-packages\requests\api.pyc in get(url, params, **kwargs)
     65 
     66     kwargs.setdefault('allow_redirects', True)
---> 67     return request('get', url, params=params, **kwargs)
     68 
     69 

C:\Users\jguichar\Anaconda\lib\site-packages\requests\api.pyc in request(method, url, **kwargs)
     51     # cases, and look like a memory leak in others.
     52     with sessions.Session() as session:
---> 53         return session.request(method=method, url=url, **kwargs)
     54 
     55 

C:\Users\jguichar\Anaconda\lib\site-packages\requests\sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    466         }
    467         send_kwargs.update(settings)
--> 468         resp = self.send(prep, **send_kwargs)
    469 
    470         return resp

C:\Users\jguichar\Anaconda\lib\site-packages\requests\sessions.pyc in send(self, request, **kwargs)
    574 
    575         # Send the request
--> 576         r = adapter.send(request, **kwargs)
    577 
    578         # Total elapsed time of the request (approximately)

C:\Users\jguichar\Anaconda\lib\site-packages\requests\adapters.pyc in send(self, request, stream, timeout, verify, cert, proxies)
    435                 raise RetryError(e, request=request)
    436 
--> 437             raise ConnectionError(e, request=request)
    438 
    439         except ClosedPoolError as e:

ConnectionError: HTTPConnectionPool(host='127.0.0.2', port=8888): Max retries exceeded with url: /primitive/list.json (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x049EC3F0>: Failed to establish a new connection: [Errno 10061] Aucune connexion n\x92a pu \xeatre \xe9tablie car l\x92ordinateur cible l\x92a express\xe9ment refus\xe9e',))

Initiation du dialogue


In [ ]:
import urllib
import urllib2

msg ='Bonjour'
params = urllib.urlencode({'msg':msg})
print "J'envois la requête"
urllib2.urlopen('http://localhost:8080/chatterbot',params)
poppy.listen.start()

In [ ]:
##poppy.listen.start()