Syntax of REST commands?

I try to figure out how the Poppy Snap! blocks are made.
For example, I think I’ve understood that the block :

makes the browser try to join the url
http://localhost:6969/motors/set/goto/head_z:50:2
(for a poppy in Vrep)
Is this what we call REST commands ?
If so, where can I find a kind of “dictionnary” of the REST commands that Poppy understands ?

I found that for the different protocol for the API REST.

It works, but it seems that it’s not the same that you put in example.

Great !
It’s a nice start to understand how it works. I didn’t go so deeply in @Pierre’s github, I should take a breath and start to dive in :slightly_smiling:
Thanks again for your answer.

Yep pretty much. Actually the term REST is supposed to add some extra constraints (see here for details). Our API is not really restful, it tends to become more a buzzword than a real thing. HTTP API seems to be more accurate for what we do.

Shame on me, but for historical reason the Snap API and the HTTP API (slightly) differs at the moment. They will be merged and cleaned in the next stable release.

The Snap API can be inferred from the source code of the Python server : https://github.com/poppy-project/pypot/blob/master/pypot/server/snap.py

To sum up (braces yourselves):

- /motors/<alias>
- /motor/<motor>/get/<register>
- /motors/get/positions
- /motors/alias
- /motors/<motors>/get/<register>
- /motors/set/goto/<motors_position_duration>
- /motors/set/registers/<motors_register_value>
- /motors/set/positions/<positions>
- /motor/<motor>/set/<register>/<value>
- /motor/<motor>/goto/<position>/<duration>
- /snap-blocks.xml
- /snap/<project>
- /ip
- /reset-simulation
- /primitives
- /primitives/running
- /primitive/<primitive>/start
- /primitive/<primitive>/stop
- /primitive/<primitive>/pause
- /primitive/<primitive>/resume
- /primitive/<primitive>/properties
- /primitive/<primitive>/get/<property>
- /primitive/<primitive>/set/<property>/<value>
- /primitive/<primitive>/methodes
- /primitive/<primitive>/call/<method>/<args>
- /primitive/MoveRecorder/<move_name>/start
- /primitive/MoveRecorder/<move_name>/stop
- /primitive/MoveRecorder/<move_name>/attach/<motors>
- /primitive/MoveRecorder/<move_name>/get_motors
- /primitive/MoveRecorder/<move_name>/start/<motors>
- /primitive/MoveRecorder/<move_name>/remove
-  /primitive/MoveRecorder
- /primitive/MovePlayer
- /primitive/MovePlayer/<move_name>/start
- /primitive/MovePlayer/<move_name>/start/<move_speed>
- /primitive/MovePlayer/<move_name>/start/<move_speed>/backwards
- /primitive/MovePlayer/<move_name>/stop
- /detect/<marker>

where <primitive> for instance can be replaced by any primitive (similarly for <motor> etc…

Thanks a lot @Pierre, that’s exactly what I was looking for.
Oh wait, I was also looking for extra time to play with all that stuff. Where can I find some ? :sleeping:

1 Like

I only see one solution… ^^

(Spéciale dédicace à @droy)

Hi,

the link provided by @tlelepvriercussol for 'HTTP-REST API seems a dead link (REST-APIs.md).
Where can I find this documentation ?

Else, I found this other one here.
Is it the exact same and if yes is this one up to date ?

In fact, I look for a way via API REST-HTTP to record moves of Poppy Torso by moving its arms and head by hand while recording and then save this animation and being able to replay it later on. Is this possible ? How ?
Shall I use primitives, or moves, and how to do it via API REST-HTTP ? – Indeed, I do not find the equivalent in API REST-HTTP of the /primitive/MoveRecorder/ and /primitive/MovePlayer/ from API Snap listed above.

At worse, if I need to use snap to record moves of Poppy as some kind of animation, I REALLY need to play them back via the API REST-HTTP. Is this possible ?

Thanks for your help.

You can use the Snap API with the list of Snap commands listed above, why do you want to use the other API ?