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 (view all EZB hardware)
EZ-B V4
by EZ-Robot
EZ-B v4/2 robot controller: dual Cortex ARM, Wi-Fi, audio/video, 24 servo/digital ports, I2C/UART, camera and Synthiam ARC control for custom robots
Wi-Fi / USB
Servos
24
Camera
Audio
UART
3
I2C
ADC
8
Digital
24
Related Robot Skills (view all robot skills)
Custom Movement Panel
by Synthiam
Custom Movement Panel maps directional commands to scripts, adjusts per-wheel speed (0-255), and integrates with joysticks for unsupported motors
Websocket Client
by Synthiam
WebSocket client for ARC: open/send messages, store server responses in a variable, run a response script, and track connection status.
Requires ARC
v6

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
@Nink - you sent a link to an HTML file. A JSON file looks similar to XML in that it has labelled parameter tags containing values.
i.e.
But, you can also parse the JSON in javascript right in arc..
Here's an example parsing JSON from a string...
And here's an example of getting JSON from an HTTP get request...
One last thing - you can view all of the built-in javascript classes here: https://synthiam.com/Support/javascript-api/javascript-overview
You can click on the ECMA 5.1 classes to read their manual page from developer.mozilla.org.
Thanks DJ I will try and connect with javascript. The HTML file I posted calls a javascript app.js that communicates with the bot via JSON. https://github.com/mjbots/quad/blob/main/mech/web_control_assets/js/app.js 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
I noticed your app.js is actually a WebSocket, so an HTTP get wouldn't work. Use this: https://synthiam.com/Support/Skills/Communication/WebSocket-Client?id=20442
The json that you would need to send is defined as a class struct in the app.js. You could edit the app.js and print the json to the console. But this is essentially the part that is creating the json - it is stored in a "command" variable and built throughout those lines by extracting data from the webpage objects and joystick.
*Moved into own thread because it is out of scope for the original thread