Skip to content

Expose cliff sensor data via /api-sdk/{begin,get,stop}_cliff_stream#508

Open
KuriGohan-Kamehameha wants to merge 717 commits into
kercre123:mainfrom
KuriGohan-Kamehameha:cliff-sensor-api
Open

Expose cliff sensor data via /api-sdk/{begin,get,stop}_cliff_stream#508
KuriGohan-Kamehameha wants to merge 717 commits into
kercre123:mainfrom
KuriGohan-Kamehameha:cliff-sensor-api

Conversation

@KuriGohan-Kamehameha

Copy link
Copy Markdown

Summary

Adds three HTTP endpoints to the SDK app that let callers poll Vector's cliff-detection state, mirroring the existing begin_event_stream / get_stim_status / stop_event_stream pattern. This is purely additive — no existing endpoint or behavior is touched.

User need

Open-loop motor control via wire-pod (drive_wheels, move_wheels, lua scripts that issue raw chassis commands) is unsafe near table edges because there is no SDK-side way to check whether the bot is currently sensing a cliff. Today every consumer that wants to gate movement on cliff state has to write its own gRPC client, duplicate auth, and join the event stream. These three endpoints let any HTTP client do the same with a single curl.

Implementation

  • New event-stream goroutine subscribes to the robot_state event type (the only place DDL's external gRPC interface exposes cliff data; there is no cliff_event and no raw per-sensor field in RobotState).
  • The aggregate ROBOT_STATUS_CLIFF_DETECTED bit (16384) is decoded from RobotState.Status on each event and cached on the Robot struct.
  • get_cliff_status returns JSON shaped {sensors[4], detected[4], any_detected, status, stamp_ms}. The arrays are length 4 to match the physical sensor layout (FL/FR/BL/BR) but currently mirror the aggregate bit, since DDL's external interface does not expose per-sensor raw values. The raw status bitmask is included verbatim for callers that want it.

New endpoints

endpoint response
GET /api-sdk/begin_cliff_stream?serial=ESN done
GET /api-sdk/get_cliff_status?serial=ESN JSON or error: must start cliff stream
GET /api-sdk/stop_cliff_stream?serial=ESN done

Smoke test

Built on real escapepod hardware (Go 1.19.4, Pi 4, vosk STT) and tested against a paired Vector at serial 00509655:

=== conn_test ===
success
=== get_cliff_status before begin ===
error: must start cliff stream
=== begin_cliff_stream ===
done
=== get_cliff_status (after 2s) ===
{"sensors":[0,0,0,0],"detected":[false,false,false,false],"any_detected":false,"status":1056512,"stamp_ms":1778543227694}
=== get_cliff_status (after 3s) ===
{"sensors":[0,0,0,0],"detected":[false,false,false,false],"any_detected":false,"status":1056512,"stamp_ms":1778543230780}
=== stop_cliff_stream ===
done
=== get_cliff_status after stop ===
error: must start cliff stream

Five consecutive polls at 1Hz showed stamp_ms advancing in real time (1778543246537 → 1778543250923) with the bot parked on the charger, confirming the goroutine is live-decoding events rather than returning stale state. status: 1056512 lacks the CLIFF_DETECTED bit (16384), so any_detected: false is correct for the parked-on-charger condition.

Test plan

  • Patch builds cleanly with the existing chipper toolchain (vosk path, nolibopusfile tag)
  • begin_cliff_stream returns done and spawns one goroutine per serial
  • get_cliff_status returns the documented JSON shape with live stamp_ms
  • get_cliff_status returns error: must start cliff stream when not started, including after stop_cliff_stream
  • stop_cliff_stream returns done and clears cached state
  • No regression: existing /api-sdk/* endpoints (conn_test, etc.) still work
  • Verify any_detected flips to true when the bot is physically lifted off a surface (reviewer-side, requires hands on hardware)

Notes

This change does not touch any existing code path; the patch is purely additive (one new field block on Robot, three new cases in the handler switch, one extra flag-reset in removeRobot). 89 lines added, 0 removed.

Zippy-boy and others added 30 commits January 27, 2024 19:33
Added docker-compose and docker image.
…ulls a few times until he sends the right one
Update compose.yaml. Left host network in for development by accident.
Added Turkish language [tr-TR] for STT configuration
…ent_system_noaudio intent if there is an EOF error in a regular Intent request
…I streaming API to make the speech-to-response appear faster despite the slower model. This is done by splitting the response at punctuation marks and having the robot speak each split string one at a time. Get rid of DDL's intent-graph implementation, use mine instead (via SDK, faster). JWT token expires after one month instead of one day.
…be used with it as well. Fix Together AI in initial setup page
Russian language support for voice model Vosk-model-small-ru-0.22
…0.22"

This reverts commit bd5fbe4.

This reverted my Together/OpenAI changes
F4310 and others added 28 commits September 21, 2024 22:54
Playing Audio (WAV) through Vector
Fix - convert stereo to mono - ok
Fix for accelerated audio in stereo WAV
Update isMn func retain the tonal marks and diacritics such as the circumflex, ơ, and ư in Vietnamese.
style: revamp navigation items with modern interactions and interactive hover effects and improve navigation experience
Supporting opensource multimodal LLMs such as Llama3.2 11B or Llama3.2 90B
Add ARM64 Support for Docker Image to Enable Raspberry Pi 5 Compatibility
Adds three new SDK HTTP endpoints that mirror the existing
begin_event_stream / get_stim_status / stop_event_stream pattern, so
callers can poll Vector's cliff-detected status from open-loop motor
control scripts (move_wheels, drive_wheels) without writing their own
gRPC client.

* robot.go: add CliffStreaming, CliffStatus, CliffDetected, CliffStampMs
  fields on the Robot struct; reset CliffStreaming in removeRobot.

* server.go: three new cases in the SdkapiHandler switch.
    - begin_cliff_stream subscribes to the 'robot_state' event stream
      (the only place the DDL gRPC interface exposes cliff data) in a
      goroutine and decodes the CLIFF_DETECTED bit (16384) from
      RobotState.Status.
    - get_cliff_status returns JSON {sensors, detected, any_detected,
      status, stamp_ms}; arrays are length 4 to match the physical
      sensor layout but currently mirror the aggregate bit because
      DDL's external interface does not expose per-sensor raw values.
    - stop_cliff_stream clears the streaming flag and resets state.

No existing code paths are touched; the change is purely additive.
Copilot AI review requested due to automatic review settings May 11, 2026 23:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.