-
Notifications
You must be signed in to change notification settings - Fork 0
status.json Layout
Matthew Yu edited this page Jun 11, 2020
·
3 revisions
A generalized format is provided below.
{
"robot_type": STRING,
"num_connected": INTEGER,
"robots": {
"ROBOT_ID": {
"robot_state": STRING,
"robot_eye_color": STRING,
"robot_expression": STRING
},
"ROBOT_ID": {
"robot_state": STRING,
"robot_eye_color": STRING,
"robot_expression": STRING
},
...
}
}
- Upon initialization, num_connected is 0 and there are no entries following.
- When a robot connects to the server, their ID creates a new entry in robots. Their state are updated to defined defaults.
- When a user updates a robot state, the js retrieves the status.json, finds the correct ROBOT_ID, and updates the information inside. The status.json is pushed back into the db.
- Robots that poll the server at the endpoints such as /robotJoin and /getState, should run app.js code that retrieves the status.json, finds the correct ROBOT_ID (that was included in the POST request), and returns the correct state in a string format. See the Dancebot WebController implementation.
- An alternative is to not have a db and manage a local json document.