-
Notifications
You must be signed in to change notification settings - Fork 0
Implement GET /api/v1/robots/{esn}/state handler #19
Copy link
Copy link
Open
Description
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_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/state returns JSON with a real battery.voltage value matching the robot. This is the Milestone 1 completion criterion.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels