Asked

My robot wants to communicate via JSON commands (it is controlled via JSON from a browser) but I need to use ARC to talk to it. It also sends a lot of data back over JSON to provide current servo status that would need to be fed back into ARC. Any thoughts if this can be adapted to communicate with the robot? https://github.com/mjbots/quad/blob/main/mech/web_control_assets/index.html
Related Hardware EZ-B v4
Related Controls
Custom Movement Panel
WebSocket Client
i.e.
Code:
Here's an example parsing JSON from a string...
Code:
And here's an example of getting JSON from an HTTP get request...
Code:
You can click on the ECMA 5.1 classes to read their manual page from developer.mozilla.org.
As far as I can tell this then talks to this file on the bot. https://github.com/mjbots/quad/blob/main/mech/quadruped_state.h#L32
Code:
Code:
For example...
stop is:
{"command":{"mode":"zero_velocity","log":"disable","v_R":[0,0,0],"w_R":[0,0,0]}}
idle is:
{"command":{"mode":"rest","log":"disable","v_R":[0,0,0],"w_R":[0,0,0]}}
And when i press W & S for walking forward backward, i assume? the v_R first parameter value grows the longer i hold W - so maybe that's the speed? It's:
{"command":{"mode":"walk","log":"disable","v_R":[0.19850326650786185,0,0],"w_R":[0,0,0],"walk":{"step_height":1,"maximize_flight":false}}}
And Q & E is turning left right? The w_R last parameter value is positive with E and negative with Q:
{"command":{"mode":"walk","log":"disable","v_R":[8.30430736384064e-9,0,0],"w_R":[0,0,0.34211217332152727],"walk":{"step_height":1,"maximize_flight":false}}}
And A & D is straffe, which is disabled in the UI but can be activated in the advance menu. It seems to grow the second parameter of v_R
{"command":{"mode":"walk","log":"disable","v_R":[-0.0000013168969403094258,0.038964137912889336,0],"w_R":[0,0,9.238252698349165e-20],"walk":{"step_height":1,"maximize_flight":false}}}
The ARC speed is a value between 0-255 and it appears the json speed is a floating-point between max -3 and +3.
This bit of code is an example of what you'd have in the custom Movement Panel for moving forward with speed control.
Code:
And this is what you'd have in the custom Movement Panel for moving backward with speed control (notice the - on the return of the Utility.Map() function)
Code:
And something like this for stop i guess....
Code:
{
"timestamp" : "2021-Mar-06 08:00:49.321910",
"mode" : "stopped",
"mode_start" : "2021-Mar-06 07:58:15.324045",
"fault" : "",
"state" : {
"joints" : [
{
"id" : 1,
"angle_deg" : 82.152000000000001,
"velocity_dps" : 2.79,
"torque_Nm" : 0,
"temperature_C" : 27,
"voltage" : 21,
"mode" : 0,
"fault" : 0,
"kp_Nm" : 0,
"ki_Nm" : 0,
"kd_Nm" : 0,
"feedforward_Nm" : 0,
"command_Nm" : 0
},
@PTP to create a custom movement panel, check the source code for the recent DJI Tello drone, which is helpful: https://github.com/synthiam/Control-DJI-Tello-Movement-Panel
Assign to the OnMovement event from the movement manager. And that way you simply send the data to the robot and handle the movement.
i.e.
Code:
Once you figure out the movement commands and speed, then you can use the Custom Movement Panel to rock it
Something like this for Forward. I dunno if that's the correct json or not. But the idea is use the Map function to convert the ARC speed (0-255) into a float of (0-1) for that robot.
Code: