Changes between Version 22 and Version 23 of en/ProgrammingRobotsCourse/GettingWwwInfo


Ignore:
Timestamp:
Mar 16, 2020, 5:06:18 PM (21 months ago)
Author:
Ales Horak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • en/ProgrammingRobotsCourse/GettingWwwInfo

    v22 v23  
    55Remember that Python usage in Pepper robots is limited to Python 2 and old version of packages. It is possible to install some (small) Python packages via `pip --user` to `/home/nao` but the space is limited.
    66
    7 If you want to test without the real robot, you can run the Python code using the virtual robot - see [#Testservicewithvirtualrobot below].
     7If you want to test without the real robot, you can run the Python code using the virtual robot - see [#Testingaservicewithvirtualrobot below].
    88
    99=== Use API
     
    119119}}}
    120120
    121 === Test service with virtual robot
    122 
     121=== Testing a service with virtual robot
     122
     123A service can be tested in the virtual robot settings.
     124
     125* prepare an app with the service to test - you may start with the examples below or use the ''templater'' tool [https://github.com/pepperhacking/robot-jumpstarter#template-python-service robot-jumpstarter] (use a ''new name'' for your service):
     126  {{{
     127ssh aurora
     128cd /nlp/projekty/pepper/web/robot-jumpstarter
     129python jumpstart.py python-service tweety-service TweetyService
     130cp -a output/tweety-service ~/pepper/
     131}}}
     132  Here `tweety-service` is the directory name of the application (and the app name), `TweetyService` is the API name of your service as it will be called from Python.[[br]]
     133* copy the directory with the service app (e.g. `~/pepper/tweety-service`) to your computer, where you run Choregraphe. All the following steps are done on this computer, ''not remotely'' via SSH.
     134* start Choregraphe and [../Introduction#virtualrobot run the virtual robot]
     135* find out the ''port number'' of your virtual robot: click [[Image(pepper_connect.png, valign=top)]] [[br]]
     136  and remember the `IP` and `port` from the table:[[br]]
     137  [[Image(pepper_virtual_port.png)]][[br]]
     138  Here the virtual robot's address is `localhost:34121`
     139* run your service in the virtual robot (Choregraphe must still be running, of course):
     140  {{{
     141cd ~/pepper/tweety-service/app
     142python scripts/tweetyservice.py --qi-url localhost:34121
     143}}}
     144  The output should look like:
     145  {{{
     146[I] 1584373059.579170 4749 qimessaging.session: Session listener created on tcp://0.0.0.0:0
     147[I] 1584373059.579385 4749 qimessaging.transportserver: TransportServer will listen on: tcp://192.168.1.2:36873
     148[I] 1584373059.579394 4749 qimessaging.transportserver: TransportServer will listen on: tcp://127.0.0.1:36873
     149}}}
     150* now you can ''communicate'' with your running service in the same way as with all other API services on the real robot:
     151  * use `^call(TweetyService.get())` in a dialog
     152  * direct call in a Python Box code:
     153    {{{#!python
     154def __init__(self):
     155   self.tweety = ALProxy('TweetyService')
     156
     157def onInput_onStart(self):
     158    self.tts.say("číslo {}".format(self.tweety.get()))
     159    self.onStopped() #activate the output of the box
     160}}}
     161  * use the [http://doc.aldebaran.com/2-5/dev/libqi/guide/qicli.html qicli] command line tool:
     162    {{{
     163alias qicli='"/opt/Softbank Robotics/Choregraphe Suite 2.5/bin/qicli" --qi-url localhost:34121'
     164qicli info TweetyService
     165call TweetyService.get
     166call TweetyService.set 2
     167call TweetyService.get
     168}}}
     169    with the output
     170    {{{
     171099 [TweetyService]
     172  * Info:
     173   machine   f883b92e-3a87-44e5-aa70-4a3b78f4d937
     174   process   4749
     175   endpoints tcp://192.168.1.2:36873
     176             tcp://127.0.0.1:36873
     177  * Methods:
     178   100 get   Int8 ()
     179   101 reset Void ()
     180   102 set   Void (Int8)
     181   103 stop  Void ()
     182-------------------------------------------------------
     1830
     184null
     1852
     186}}}
    123187
    124188== Examples