-
Notifications
You must be signed in to change notification settings - Fork 228
[lightx2v_ros]: add RoboTwin 2.0 simulator and reconstruct ros #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fuheaven
wants to merge
2
commits into
ModelTC:main
Choose a base branch
from
fuheaven:robotwin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| [submodule "lightx2v_ros/src/simulator/simulator/libero_node/LIBERO"] | ||
| path = lightx2v_ros/src/simulator/simulator/libero_node/LIBERO | ||
| url = https://github.com/Lifelong-Robot-Learning/LIBERO.git | ||
| [submodule "lightx2v_ros/src/simulator/simulator/robotwin_node/RoboTwin"] | ||
| path = lightx2v_ros/src/simulator/simulator/robotwin_node/RoboTwin | ||
| url = https://github.com/robotwin-Platform/robotwin.git | ||
| branch = main |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "adapter_model_path": "/data/nvme7/yongyang/fastwam_release/robotwin_uncond_3cam_384.pt", | ||
| "dataset_stats_path": "/data/nvme7/yongyang/fastwam_release/robotwin_uncond_3cam_384_dataset_stats.json", | ||
| "camera_size": 384, | ||
| "action_chunk_size": 32, | ||
| "actions_per_plan": 8, | ||
| "num_steps_wait": 0, | ||
| "action_infer_steps": 20, | ||
| "action_sample_shift": 5.0, | ||
| "action_dim_hidden": 1024, | ||
| "action_dim": 14, | ||
| "robot_state_dim": 14, | ||
| "policy_profile": "robotwin", | ||
| "normalize_mode": "z-score", | ||
| "binarize_gripper": false, | ||
| "gripper_postprocess": false, | ||
| "default_prompt": "A video recorded from a robot's point of view executing the following instruction: {task_prompt}" | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from .contract import ( | ||
| CONTRACTS, | ||
| LIBERO_CONTRACT, | ||
| ROBOTWIN_CONTRACT, | ||
| EnvContract, | ||
| get_contract, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "CONTRACTS", | ||
| "EnvContract", | ||
| "LIBERO_CONTRACT", | ||
| "ROBOTWIN_CONTRACT", | ||
| "get_contract", | ||
| ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| """Single source of truth for the simulator/inference/visualization contract. | ||
|
|
||
| This module is intentionally dependency-free (pure Python, no ROS/torch imports) | ||
| so it can be imported by every ROS node as well as plain scripts. It defines, per | ||
| simulation environment, the ROS topic namespace, the set of cameras, the | ||
| action/state dimensions and the inference profile. All three nodes derive their | ||
| topic names and tensor dimensions from the same `EnvContract`, which removes the | ||
| LIBERO-specific hard-coding that used to live in each node. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from typing import Dict, Tuple | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class EnvContract: | ||
| # Logical environment id, e.g. "libero" or "robotwin". | ||
| name: str | ||
| # ROS topic prefix, e.g. "/libero". | ||
| namespace: str | ||
| # All cameras the simulator publishes (logical names, also used by the viewer). | ||
| cameras: Tuple[str, ...] | ||
| # Subset of `cameras` fed to the policy, in the exact order the policy expects. | ||
| policy_input_cameras: Tuple[str, ...] | ||
| # Robot action / proprio-state vector dimensions exchanged over ROS. | ||
| action_dim: int | ||
| state_dim: int | ||
| # Square render/publish size hint (used by simulators that render on demand). | ||
| image_size: int | ||
| # Inference assembly profile understood by FastWAMPolicy ("libero"|"robotwin"). | ||
| policy_profile: str | ||
| # Action/state normalization mode ("minmax"|"zscore"). | ||
| normalize_mode: str | ||
| # Whether to apply the LIBERO single-gripper sign/binarize post-processing. | ||
| gripper_postprocess: bool | ||
| # Optional human-readable description. | ||
| description: str = field(default="") | ||
|
|
||
| # ----- derived topic helpers (kept in one place so nodes never disagree) ----- | ||
| @property | ||
| def action_topic(self) -> str: | ||
| return f"{self.namespace}/action" | ||
|
|
||
| @property | ||
| def state_topic(self) -> str: | ||
| return f"{self.namespace}/state" | ||
|
|
||
| @property | ||
| def success_topic(self) -> str: | ||
| return f"{self.namespace}/success" | ||
|
|
||
| @property | ||
| def observation_ready_topic(self) -> str: | ||
| return f"{self.namespace}/observation_ready" | ||
|
|
||
| @property | ||
| def task_topic(self) -> str: | ||
| return f"{self.namespace}/task_description" | ||
|
|
||
| @property | ||
| def episode_topic(self) -> str: | ||
| # Monotonic episode counter; lets the policy reset its per-episode state when | ||
| # the simulator loops into a fresh episode. | ||
| return f"{self.namespace}/episode" | ||
|
|
||
| def camera_topic(self, camera: str) -> str: | ||
| if camera not in self.cameras: | ||
| raise KeyError(f"camera '{camera}' is not part of contract '{self.name}': {self.cameras}") | ||
| return f"{self.namespace}/{camera}/image_raw" | ||
|
|
||
| def camera_topics(self) -> Dict[str, str]: | ||
| return {camera: self.camera_topic(camera) for camera in self.cameras} | ||
|
|
||
|
|
||
| LIBERO_CONTRACT = EnvContract( | ||
| name="libero", | ||
| namespace="/libero", | ||
| cameras=("agentview", "wrist", "frontview", "galleryview"), | ||
| policy_input_cameras=("agentview", "wrist"), | ||
| action_dim=7, | ||
| state_dim=8, | ||
| image_size=224, | ||
| policy_profile="libero", | ||
| normalize_mode="minmax", | ||
| gripper_postprocess=True, | ||
| description="LIBERO (robosuite/mujoco) single-arm tabletop manipulation.", | ||
| ) | ||
|
|
||
|
|
||
| ROBOTWIN_CONTRACT = EnvContract( | ||
| name="robotwin", | ||
| namespace="/robotwin", | ||
| cameras=("head_camera", "left_camera", "right_camera"), | ||
| policy_input_cameras=("head_camera", "left_camera", "right_camera"), | ||
| action_dim=14, | ||
| state_dim=14, | ||
| image_size=384, | ||
| policy_profile="robotwin", | ||
| normalize_mode="zscore", | ||
| gripper_postprocess=False, | ||
| description="RoboTwin 2.0 (SAPIEN) dual-arm manipulation.", | ||
| ) | ||
|
|
||
|
|
||
| CONTRACTS: Dict[str, EnvContract] = { | ||
| LIBERO_CONTRACT.name: LIBERO_CONTRACT, | ||
| ROBOTWIN_CONTRACT.name: ROBOTWIN_CONTRACT, | ||
| } | ||
|
|
||
|
|
||
| def get_contract(name: str) -> EnvContract: | ||
| key = str(name).strip().lower() | ||
| if key not in CONTRACTS: | ||
| raise KeyError(f"unknown environment '{name}'. Available: {sorted(CONTRACTS)}") | ||
| return CONTRACTS[key] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0"?> | ||
| <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
| <package format="3"> | ||
| <name>common</name> | ||
| <version>0.0.1</version> | ||
| <description>Shared environment contract for LightX2V ROS nodes.</description> | ||
| <maintainer email="user@example.com">user</maintainer> | ||
| <license>Apache-2.0</license> | ||
|
|
||
| <buildtool_depend>ament_python</buildtool_depend> | ||
|
|
||
| <export> | ||
| <build_type>ament_python</build_type> | ||
| </export> | ||
| </package> |
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [develop] | ||
| script_dir=$base/lib/common | ||
| [install] | ||
| install_scripts=$base/lib/common |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前代码中没有对
policy_profile的有效性进行校验。如果用户传入了不支持的 profile(例如拼写错误),代码会默认回退到"libero"的处理逻辑,这可能会导致难以排查的维度不匹配或KeyError错误。建议在初始化时对
policy_profile进行校验,仅允许"libero"和"robotwin"。