Add custom robot websocket mode 9541481191295836274 - #8
Open
abhijeet5642 wants to merge 20 commits into
Open
Conversation
- Added 'CUSTOM' connection mode to ConnectionPanel - Enabled manual input of WebSocket URL for custom robots - Handled raw WebSocket creation when connecting in CUSTOM mode - Updated Joystick publishing loop to map Gamepad API inputs directly to custom JSON payloads, avoiding WebRTC stack if CUSTOM mode is active. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
Changes default WebSocket IP in custom mode from 192.168.1.10 to 0.0.0.0 as requested. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This is an empty commit just to finalize the review cycle. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
Changes default WebSocket IP in custom mode from 192.168.1.10 to 0.0.0.0 as requested. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
`navigator.getGamepads()` returns a `GamepadList` in most modern browsers (Chrome, Safari, etc.), which is an array-like object but lacks standard array methods like `.find()`. The previous code directly called `.find()` on the return value of `navigator.getGamepads()`, throwing a TypeError and breaking the joystick polling loop. This commit converts the result into a standard JavaScript array using `Array.from()` before calling `.find()`, fixing the runtime error. Also cleaned up accidental logs. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This commit introduces the `CUSTOM` robot mode allowing users to control
custom robots over standard WebSockets rather than Unitree's WebRTC protocol.
- Created `CustomWebSocketConnection` mimicking the required `WebRTCConnection`
interface.
- Added a `CUSTOM` mode selector to the landing page with default `ws://127.0.0.1:8080/robot`.
- Mapped FlySky FS-i6s transmitter joystick axes to custom payload coordinates.
- Added Deadman Switch parsing (Axis 4) and custom robot modes (sleep, stand, move)
bound to gamepad buttons 0, 1, 2.
- Emits exact JSON format `{seq, t_ms, deadman, vx, vy, wz, mode}`.
Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This commit adds a new 'CUSTOM' connection mode that bypasses the standard WebRTC flow and instead connects to a local WebSocket server. The gamepad input is parsed and sent as a JSON payload to the WebSocket server. A Python bridge script is included to translate the WebSocket messages into CycloneDDS `JoystickData` messages on the `rt/bt_usb/joystick_data` topic. Also includes a fix in the joystick loop to correctly grab the gamepad instead of silently failing. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This commit adds a new 'CUSTOM' connection mode that bypasses the standard WebRTC flow and instead connects to a local WebSocket server. The gamepad input is parsed and sent as a JSON payload to the WebSocket server. A Python bridge script is included to translate the WebSocket messages into CycloneDDS `JoystickData` messages on the `rt/bt_usb/joystick_data` topic. Also includes a fix in the joystick loop to correctly grab the gamepad instead of silently failing. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This commit adds a new 'CUSTOM' connection mode that bypasses the standard WebRTC flow and instead connects to a local WebSocket server. The gamepad input is parsed and sent as a JSON payload to the WebSocket server. A Python bridge script is included to translate the WebSocket messages into CycloneDDS `JoystickData` messages on the `rt/bt_usb/joystick_data` topic. Also includes a fix in the joystick loop to correctly grab the gamepad instead of silently failing, and maps axes properly for the FlySky FS-i6s emulator. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This commit addresses issues with the FlySky FS-i6s emulator mapping: 1. It presents non-zero rest states (e.g. -1), which prevented the auto-lock feature from grabbing it. The logic was adjusted to require an absolute value greater than 0.1 to trigger auto-lock. 2. It uses `axes[3]` for right-stick Y instead of `axes[2]`. The custom mapping logic was updated to use `axes[3]` if available, falling back to `axes[2]`. 3. The deadman switch is now defaulted to true to ensure the robot can move even if a specific switch isn't explicitly mapped. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
…bsockets - Set `customMode` default to `'move'` instead of `'sleep'` so the robot isn't ignoring inputs when first booted. - Hardcoded `deadman` switch to `true` for custom websocket payloads to ensure the simulation or physical robot actually registers the control inputs. - Added debugging logs in `app.ts` to log joystick inputs sent every ~1s (every 20th sequence). - Added equivalent debugging logs in `dds_bridge.py` to confirm the joystick parameters being received and forwarded to DDS. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
- Introduces a local kinematic simulation hack in `src/ui/app.ts` when `mode === 'CUSTOM'`. - This calculates synthetic odometry locally and drives the `scene3d.robotModel` directly based on raw gamepad or on-screen joystick input. - Allows visual verification of joystick inputs moving the 3D robot model in the browser when connected to a local simulator via WebSocket without requiring `rt/lf/lowstate` DDS feedback. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
- Introduces a local kinematic simulation hack in `src/ui/app.ts` when `mode === 'CUSTOM'`. - This calculates synthetic odometry locally and drives the `scene3d.robotModel` directly based on raw gamepad or on-screen joystick input. - Allows visual verification of joystick inputs moving the 3D robot model in the browser when connected to a local simulator via WebSocket without requiring `rt/lf/lowstate` DDS feedback. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
- Introduces a local kinematic simulation hack in `src/ui/app.ts` when `mode === 'CUSTOM'`. - This calculates synthetic odometry locally and drives the `scene3d.robotModel` directly based on raw gamepad or on-screen joystick input. - Allows visual verification of joystick inputs moving the 3D robot model in the browser when connected to a local simulator via WebSocket without requiring `rt/lf/lowstate` DDS feedback. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
…lation - Added `CUSTOM` mode connection type bypassing WebRTC. - Added `DDSBridgeServer` in `server/dds_bridge.py` to translate WebSocket JSON payloads to Cyclone DDS `JoystickData` structs on the `rt/bt_usb/joystick_data` topic. - Implemented robust gamepad handling to parse non-standard FlySky FS-i6s axes, forcing 'move' mode and ensuring 'deadman' is true. - Integrated a localized kinematic simulation update loop into the frontend UI (during `CUSTOM` mode) so the `scene3d.robotModel` visually responds to joystick input without requiring DDS feedback telemetry. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
Mapped FlySky RC transmitter's axis 4 to move/estop toggles, and axis 5 to sleep/stand/move switches, correctly forwarding these mode strings in the custom DDS payload. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
Modified `server/dds_bridge.py` to use `xterra::msg::dds_::JoyData_` with priority, 6 axes, and 12 buttons. Updated frontend (`src/ui/app.ts`) to send raw gamepad axes and buttons over the WebSocket. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
Added `@annotate.final` to the `JoyData_` struct in `dds_bridge.py` to correctly support Cyclone DDS XTypes discovery, which the Xterra simulation requires. Cleaned up scratchpad test files. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
- Added WebRTC DataChannel support to the frontend (`CustomWebRTCConnection`). - Updated frontend UI placeholders and modes for the new `http://...:8080` signaling. - Mapped FlySky FS-i6s axes to custom control messages (`axes[4]` and `axes[5]`). - Replaced backend WebSocket server with an `aiortc`/`aiohttp` WebRTC signaling server (`dds_bridge.py`). - Integrated Cyclone DDS publisher to bridge WebRTC joystick data to `rt/bt_usb/joystick_data` using the `xterra::msg::dds_::JoyData_` struct. - Updated `requirements.txt` with new backend dependencies. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
- Implemented `server/dds_bridge.py` backend using `aiortc` and `aiohttp` to accept WebRTC signaling and data channel connections. - Mapped incoming JSON payloads to the Cyclone DDS `xterra::msg::dds_::JoyData_` struct. - Published joystick data to the `rt/bt_usb/joystick_data` DDS topic. - Added necessary dependencies (`aiohttp`, `aiortc`, `cyclonedds`) to `requirements.txt`. - Updated the frontend (`src/connection/custom-webrtc.ts`, `app.ts`, `connection-panel.ts`, `types.ts`, `modes.ts`) to handle ICE gathering, post SDP offers, and transmit joystick data via WebRTC data channel for the `CUSTOM` connection mode. - Ensured Flysky stick mapping behaviors (e.g., axes 4 and 5 for mode swapping, axes 2 for throttle) are accurately translated. Co-authored-by: abhijeet5642 <145228365+abhijeet5642@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.