Skip to content

Optimize Inference Loop by Moving Observation Capture Inside Condition Block#3

Merged
shantanuparab-tr merged 1 commit intotrossen-aifrom
fix/optimize-get-observation
Sep 22, 2025
Merged

Optimize Inference Loop by Moving Observation Capture Inside Condition Block#3
shantanuparab-tr merged 1 commit intotrossen-aifrom
fix/optimize-get-observation

Conversation

@shantanuparab-tr
Copy link
Copy Markdown
Collaborator

  • Moved get_observation() and image preprocessing inside the inference condition.
  • Now observations and image transformations are only triggered when a new action chunk is needed.
  • This reduces unnecessary image capture and avoids frame drops on low-power or poorly configured machines (e.g., USB bandwidth bottlenecks).
  • Ensures better performance and stability during evaluation and deployment.

@shantanuparab-tr shantanuparab-tr self-assigned this Sep 22, 2025
@shantanuparab-tr shantanuparab-tr added bug Something isn't working enhancement New feature or request labels Sep 22, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Trossen AI robot integration and optimizes the inference loop by moving observation capture inside condition blocks. The changes enable training and evaluating Pi-0 policies on Trossen AI stationary bimanual setups.

  • Adds a new training configuration for Trossen AI robot support with proper camera mapping
  • Implements a complete client bridge for connecting Trossen AI hardware to OpenPI policy servers
  • Moves observation capture and image preprocessing inside inference conditions to reduce unnecessary processing

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/openpi/training/config.py Adds training configuration for Trossen AI robot with LoRA fine-tuning
pyproject.toml Enables direct git references for dependency management
examples/trossen_ai/pyproject.toml Sets up isolated environment for Trossen AI client with specific LeRobot version
examples/trossen_ai/main.py Implements bridge between Trossen AI hardware and OpenPI policy server
examples/trossen_ai/README.md Provides comprehensive setup and usage documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

cameras = list(self.robot._cameras_ft.keys())
for cam in cameras:
image_hwc = observation_dict[cam]
#convert BGR to RGB
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Comment should start with a capital letter and have proper spacing: '# Convert BGR to RGB'

Suggested change
#convert BGR to RGB
# Convert BGR to RGB

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +114
elif self.test_mode == "autonomous":
joint_features = list(self.robot._joint_ft.keys())
action_dict = {k: full_action[i] for i, k in enumerate(joint_features)}
self.robot.send_action(action_dict)
else:
logger.error(f"Unknown mode: {self.test_mode}. No action executed.")
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The action_dict construction assumes full_action has the same length as joint_features, but there's no validation. This could cause an IndexError if the action dimensions don't match the expected joint count.

Copilot uses AI. Check for mistakes.
Comment on lines +168 to +170
#convert BGR to RGB
image_resized = cv2.resize(image_hwc, (224, 224))
image_rgb = cv2.cvtColor(image_resized, cv2.COLOR_BGR2RGB)
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

[nitpick] The image processing steps (resize to 224x224, BGR to RGB conversion) should be extracted into a separate method to improve readability and reusability.

Copilot uses AI. Check for mistakes.
@lukeschmitt-tr lukeschmitt-tr changed the base branch from main to trossen-ai September 22, 2025 21:13
@shantanuparab-tr shantanuparab-tr merged commit 5f6f593 into trossen-ai Sep 22, 2025
@shantanuparab-tr shantanuparab-tr deleted the fix/optimize-get-observation branch September 22, 2025 21:16
shantanuparab-tr added a commit that referenced this pull request Oct 27, 2025
lukeschmitt-tr pushed a commit that referenced this pull request Nov 19, 2025
lukeschmitt-tr pushed a commit that referenced this pull request Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants