vr: add VrArmComponent cartesian teleop leader#261
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new VR-based hardware leader component that provides Cartesian-space teleoperation targets (including gripper) from a VR controller, integrating with the existing TeleopController lifecycle and the shared process-wide VrSession.
Changes:
- Introduces
VrArmComponentimplementingteleop::CartesianSpaceTeleop, mapping VR controller pose + trigger to a 7-element Cartesian target. - Adds session/claim management via
VrSession(port selection, connection wait, input claims, teardown). - Wires the new component into the build by adding the source file to
trossen_sdk.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/hw/vr/vr_arm_component.cpp |
Implements VR controller → robot-frame Cartesian target generation and session lifecycle handling. |
include/trossen_sdk/hw/vr/vr_arm_component.hpp |
Declares the new VR arm teleop leader component and its configuration/teleop interface. |
CMakeLists.txt |
Adds the new VR arm component source to the shared library build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e0d0dc5 to
c716b0c
Compare
9cd3e7a to
0ddba2a
Compare
c716b0c to
5e8f734
Compare
0ddba2a to
0d9e5b9
Compare
shantanuparab-tr
left a comment
There was a problem hiding this comment.
The pose math, the trigger-to-gripper mapping, and the re-grip behavior can all be tested without hardware. A few small tests would lock in the behavior. The math looks right, this is just to keep it that way.
| } | ||
|
|
||
| std::vector<float> VrArmComponent::read() { | ||
| if (!initialized_) return last_good_; |
There was a problem hiding this comment.
The build downloads the latest trossen_vr each time, so an unrelated change over there can break our build with no change here. Can we pin it to a fixed version?
| out[4] = static_cast<float>(cart.ay); out[5] = static_cast<float>(cart.az); | ||
| out[6] = static_cast<float>(gripper); | ||
|
|
||
| last_good_ = out; |
There was a problem hiding this comment.
The rotation math can produce a "not a number" value in some positions, and right now that would go straight to the arm. Can we check the final pose is all real numbers and fall back to the last good one if not?
There was a problem hiding this comment.
for (float v : out) {
if (!std::isfinite(v)) return last_good_; // do not send a broken pose to the arm
}There was a problem hiding this comment.
Added, read() checks the final pose is all finite and holds the last good target otherwise.
5e8f734 to
a85d93c
Compare
0d9e5b9 to
14b6015
Compare
|
Added test_vr_arm_component.cpp covering the pose math, trigger gripper, re-grip, and the NaN guard. |
Add VrArmComponent, a Cartesian-space teleop leader driven by one VR controller. Registered as hardware type "vr_arm_component". - Each read() applies a frozen VR-to-robot offset (captured in sync_to_state()) to the live controller pose, producing a 7-vec [x, y, z, rx, ry, rz, gripper_m] target. write() is a no-op (leader-only). - Grip is the deadman switch: tracking edges (is_tracked 0->1) re-anchor the offset so re-gripping never jumps. Holds last good pose through transient frame drops. - Trigger maps linearly onto [gripper_min_m, gripper_max_m]. Claims pose + trigger on its controller_type via VrSession so overlapping configs fail loudly. Builds on VrSession (shared connection) and CartesianSpaceTeleop. Adds src/hw/vr/vr_arm_component.cpp to the library.
a85d93c to
8e7f5ee
Compare
14b6015 to
10ffedc
Compare

Summary
Adds
VrArmComponent, a Cartesian-space teleop leader driven by one VR controller (hardware typevr_arm_component).Changes
read()applies a frozen VR-to-robot offset (captured insync_to_state()) to the live controller pose, producing a 7-vec[x, y, z, rx, ry, rz, gripper_m]target.write()is a no-op (leader-only).[gripper_min_m, gripper_max_m]. Claims pose + trigger on itscontroller_typeviaVrSession.read()andsync_to_state()each sample a single VR frame and reuse it for the tracking check, offset recompute, pose, and trigger — avoiding cross-frame inconsistencies and redundant locking.Test Plan
make build)make test)pre-commit run --all-files)Breaking Changes
None.
Related Issues
N/A — part of the VR teleoperation feature stack.