Poppy Rest web services and clients

Specification

The idea is to implement clients side applications that consume the actual web services. The client side could be
-Web Client : A navigator with Js framework like Extjs or Yui.
-Mobile App : ios application, android app.
-Desktop application ; JavaFX, Swing, c# ….

The main goals are :

-Configure poppy.
-Control Poppy.
-Ability to configure dynamixel motors directly (doing something equivalent to what the Dynamixel Wizard is doing)

The documentation of the new REST APIs can be found here :

Details about Rest Api are here :
http://poppy-project.github.io/pypot/remote_access.html
we will strart by a web application as first client for these web services, the design and the mock up are below

Design

the mock up can be found here : https://moqups.com/louzar/QeoO8rtn

4 Likes

Actually ZMQ is only one of the “transport” layer available for the REST API. The REST API itself is written using json. Those json data can then be exchanged using ZMQ or HTTP.

Hi guys, I started thinking about how the webapp will look like , could you please look at the link below and give me feedback the mock up can be found here : https://moqups.com/louzar/QeoO8rtn

1 Like

Looking good! I’m really exited to play with something like this :smile:

Just a thought, maybe on the list of motor you could already see the main values, like the current position and if the motor is compliant or not. What do you say?

yes good idea, I will add that

Hi , can someone give me an example of post query for this service :
/motor/motor_name/register/register_name/value.json

also can some one tell me what bottle.request.json contains exacly

@Pierre any idea ?

I am going to use REST API, I wanted to know if I can transfert all the data of Poppy using REST API every 20ms. Do you think it is reasonable ?

It really depends on the type of transport and connection you use. If you want to use HTTP over wifi this seems hard. If you use ZMQ over ethernet this shouldn’t be a problem at all.

Yep, the purpose is to radio control Poppy.
I launched the server on ODROID.
I launched the client on my personal computer.

I only request the position of “head_z” motor.
With HTTP, it takes 17seconds for 1000 requests
With ZMQ, it takes 3seconds for 1000 requests.

ZMQ is clearly better. But for my purpose, I would like all the registers of all motors (except low speed parameters (voltage, temperature)

Do you think it could be possible to add a motor named “all” and a register named “all” so that in one request, I have all the configuration?

Considering ZMQ, getting all configuration in 3millisecond is very large.

I guess you can add to the REST API another method which basically calls all the other to retrieve all informations at once. This should do for what you want.

This is rather slow. How are your board and computer connected?

The connection is via wifi. Personal computer and ODROID are on a Freebox. I may test direct wifi connection using hotspot on my personal computer.

Ok for the method, I see.

I added the REST method to get (and set) all registers and it works very well : 7 milliseconds for 2 motors with direct wifi (I installed an hot spot on my personal computer)
The reactivity is also very good (I have to measure the delay but it is very small)
For the moment, I tried only with 2 motors. Next step is the whole Poppy.

Here are the two global REST methods I added in rest.py :

# global rest methods    
    def get_all_register_values(self):
        dict = {}
        motorList = self.get_motors_list()
        for motor in motorList:
            dict[motor]={}
            regList = self.get_motor_registers_list(motor)
            if regList.count('registers')>0:
                regList.remove('registers')
            for reg in regList:
                try:
                    dict[motor][reg] = self.get_motor_register_value(motor,reg)
                except:
                    pass
        return dict
        
    def set_all_register_values(self,dict):
        for motor in dict:
            for reg in dict[motor]:
                self.set_register_value(motor,reg,dict[motor][reg])

I put a link to the video to see the radio controlled robot :

1 Like

I did the first test with the whole 25 servo of Poppy and it is very low (I think the frequency is around 10Hz :disappointed: ). I am investigating to make a shorter json file (it is very redundant) and also on the wifi. The wifi is not the safer thing of the world… :wink:

After investigation, I reduced the json transmission length. It is again 5Hz…
I made a thread to get robot state and then send orders, it takes 13ms for all the motors. It is very good.
In fact, the 5Hz limitation is due to FIRE…
It is a good news since it is not a wifi problem :smile: . I just have to be a better programmer. easy.

2 Likes

Ok, I saw the “find” and “findItem” methods of Qt are very slow. There is always a way to get rid of these functions (hashtables, or taking the problem differently)
Now, I have a wifi connection of complete Poppy… at 50Hz !! tested with leap motion, there is no delay

3 Likes

For information and comparison, I did a ping test on my robot connect on wifi with an hotspot on my personnal computer :

Envoi d'une requête 'Ping'  192.168.137.121 avec 32 octets de données :
Réponse de 192.168.137.121 : octets=32 temps=37 ms TTL=64
Réponse de 192.168.137.121 : octets=32 temps=213 ms TTL=64
Réponse de 192.168.137.121 : octets=32 temps=199 ms TTL=64
Réponse de 192.168.137.121 : octets=32 temps=173 ms TTL=64

Id there a shortcut to launch a ZMQ server ? (something like an option in poppy-services ?)

other question: what value should be sent to change compliance ? I found that for HTTP you have to set True or False, but ZMQ only want strings and does nothing when I send “0” and crashed when I send “False”…

If you want to add it on poppy-services, feel free to make a pull request !
:slight_smile:

1 Like

What do you call poppy services ? Is it a repository ?