Skip to content

vr: add VrArmComponent cartesian teleop leader#261

Open
abhichothani42 wants to merge 3 commits into
vr-04-vr-sessionfrom
vr-05-vr-arm-component
Open

vr: add VrArmComponent cartesian teleop leader#261
abhichothani42 wants to merge 3 commits into
vr-04-vr-sessionfrom
vr-05-vr-arm-component

Conversation

@abhichothani42

@abhichothani42 abhichothani42 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds VrArmComponent, a Cartesian-space teleop leader driven by one VR controller (hardware type vr_arm_component).

Changes

  • 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).
  • Hand-grip is the deadman switch: tracking edges (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.
  • read() and sync_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

  • Builds cleanly (make build)
  • Tests pass (make test)
  • Lint passes (pre-commit run --all-files)
  • Tested on hardware

Breaking Changes

None.

Related Issues

N/A — part of the VR teleoperation feature stack.

abhichothani42 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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.

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 VrArmComponent implementing teleop::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.

Comment thread src/hw/vr/vr_arm_component.cpp Outdated
Comment thread src/hw/vr/vr_arm_component.cpp

@shantanuparab-tr shantanuparab-tr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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_;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done, pinned trossen_vr in pr #260

out[4] = static_cast<float>(cart.ay); out[5] = static_cast<float>(cart.az);
out[6] = static_cast<float>(gripper);

last_good_ = out;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for (float v : out) {
  if (!std::isfinite(v)) return last_good_;   // do not send a broken pose to the arm
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added, read() checks the final pose is all finite and holds the last good target otherwise.

@abhichothani42

Copy link
Copy Markdown
Collaborator Author

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.
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.

3 participants