Task: Robot State Endpoint
Parent epic: #4 (M1 — Robot Connection)
Depends on: #15 (Registry), #18 (EventStream populating state)
What to do
Add GET /api/v1/robots/{esn}/state route to buildRouter in main.go, returning a live api.RobotState snapshot from the ConnectionManager.
mux.HandleFunc("GET /api/v1/robots/{esn}/state", func(w http.ResponseWriter, r *http.Request) {
esn := r.PathValue("esn")
cm, ok := registry.Get(esn)
if !ok {
writeJSON(w, http.StatusNotFound, api.ErrorResponse{Error: "robot not found"})
return
}
writeJSON(w, http.StatusOK, cm.State())
})
The api.RobotState type is already defined in pkg/api/types.go — populate all fields from live SDK data.
Fields to populate (from EventStream state)
battery.voltage, battery.level, battery.is_charging, battery.is_on_charger
pose.x, pose.y, pose.z, pose.angle_rad
stimulation (from StimulationInfo events)
faces_visible (from RobotObservedFace events)
is_on_charger, is_picked_up
has_control (from behavior control stream)
Definition of done
curl http://localhost:8070/api/v1/robots/008093b9/state returns JSON with a real battery.voltage value matching the robot. This is the Milestone 1 completion criterion.
Task: Robot State Endpoint
Parent epic: #4 (M1 — Robot Connection)
Depends on: #15 (Registry), #18 (EventStream populating state)
What to do
Add
GET /api/v1/robots/{esn}/stateroute tobuildRouterinmain.go, returning a liveapi.RobotStatesnapshot from theConnectionManager.The
api.RobotStatetype is already defined inpkg/api/types.go— populate all fields from live SDK data.Fields to populate (from EventStream state)
battery.voltage,battery.level,battery.is_charging,battery.is_on_chargerpose.x,pose.y,pose.z,pose.angle_radstimulation(from StimulationInfo events)faces_visible(from RobotObservedFace events)is_on_charger,is_picked_uphas_control(from behavior control stream)Definition of done
curl http://localhost:8070/api/v1/robots/008093b9/statereturns JSON with a realbattery.voltagevalue matching the robot. This is the Milestone 1 completion criterion.