Feat/turtle2 deploy v4#4
Draft
MuggleZzzH wants to merge 7 commits into
Draft
Conversation
…ontroller When the smooth controller observed pose error within tolerance for both arms, it cached the last expected pose and early-returned without publishing any further control message. Because the underlying ROS interface is a streaming command channel, stopping publication also stops gripper motion. Gripper convergence is much slower than pose (mechanical limits on the gripper actuator), so the typical timeline is: t=0.0s pose err large, gripper err large -> publish moving msg t=0.3s pose err in tol, gripper err still large -> early return, no msg t>0.3s loop keeps early-returning -> gripper stuck mid-travel The bug was hidden in ButtonEnv training because action_scale[2]=0.0 forces the gripper closed and never exercises a non-zero gripper target. It surfaces as soon as a policy commands gripper open/close. Fix: after pose converges, if gripper has not converged, publish one control message holding the current pose and re-issuing the gripper target so the controller keeps driving the gripper. ``_GRIPPER_TARGET_ TOLERANCE`` is a local class constant (0.05) sized for the gripper's mechanical precision, not exposed as a launch parameter. Signed-off-by: MuggleZzzH <2558818257@qq.com>
Introduce a generic deploy environment for the Turtle2 platform that
supports policy-only rollout / evaluation without changing the Turtle2
training path.
Scope:
* New ``Turtle2DeployEnv`` subclass of ``Turtle2Env``, isolated to
``rlinf/envs/realworld/xsquare/tasks/turtle2_deploy_env.py`` (sibling of
``button_env.py``). The base ``Turtle2Env`` and ``ButtonEnv`` are not
modified.
* Local obs/action contract (Turtle2 deploy only — not a repo-wide
convention): ``state.tcp_pose`` is per-arm ``xyz+quat`` (14D dual-arm,
unchanged from the base env), ``state.gripper`` is a separate 2D key.
``RealWorldEnv._wrap_obs`` concatenates keys alphabetically, so the
flattened ``obs["states"]`` order is ``gripper(2) + tcp_pose(12)`` after
``DualQuat2EulerWrapper``.
* Two action modes selected via ``override_cfg.action_mode``:
- ``relative_pose`` (default): delegates to ``Turtle2Env.step``; EE→base
transform is performed by the shared ``DualRelativeFrame`` wrapper
applied externally in the factory.
- ``absolute_pose``: per-arm base-frame ``[x, y, z, rx, ry, rz, g]``
target executed directly via ``controller.move_arm``. The wrapper
chain skips ``DualRelativeFrame`` but still applies
``DualQuat2EulerWrapper`` for observation conversion (it does not
modify actions).
Zero changes to ``rlinf/envs/realworld/common/wrappers/**`` — the deploy
contract was designed to be representable with the wrappers already on
main.
Validation is minimal (action_mode and dual-arm only) and lives in the
factory, not in the base config; ``Turtle2DeployConfig.__post_init__``
only promotes YAML lists to ``np.ndarray`` so the base env's numpy
slicing works.
Configs:
* ``examples/embodiment/config/env/realworld_turtle2_deploy.yaml`` — env
fragment with safe default safety-box limits and ``action_mode:
relative_pose``.
* ``examples/embodiment/config/realworld_turtle2_deploy_eval.yaml`` —
eval-only top-level config (``only_eval: True``, ``state_dim: 14``,
``action_dim: 14``).
Signed-off-by: MuggleZzzH <2558818257@qq.com>
Add an EN + ZH "Deployment" section to the XSquare Turtle2 example page covering ``Turtle2DeployEnv-v1``: * Run command for the eval-only deploy config. * Local obs/action contract (Turtle2 deploy only — not a repo-wide convention): ``tcp_pose`` is per-arm ``xyz+quat`` / ``xyz+rpy``, ``gripper`` is a separate state key, and the flattened ``obs["states"]`` order is ``gripper(2) + tcp_pose(12) = 14`` because ``RealWorldEnv._wrap_obs`` concatenates keys alphabetically. * The two ``action_mode`` semantics and which wrappers each path applies: ``relative_pose`` keeps the training EE-frame action contract via ``DualRelativeFrame``; ``absolute_pose`` skips ``DualRelativeFrame`` but still applies ``DualQuat2EulerWrapper`` (observation only, action untouched). * A dual-container deployment note describing the control-container / RLinf-container split and the ROS / ``host network`` rationale. EN and ZH pages mirror each other (same sections, same code blocks, same command). Signed-off-by: MuggleZzzH <2558818257@qq.com>
审阅者指南(Reviewer's Guide)添加了面向部署的 Turtle2 双臂环境(Gym 入口 + 配置),支持相对/绝对位姿控制模式,将其接入真实环境注册表,并修复 Turtle2 平滑控制器,使得在达到位姿容差后,夹爪指令仍能收敛。 Turtle2SmoothController 夹爪收敛逻辑的时序图sequenceDiagram
participant Turtle2SmoothController
participant Turtle2State
participant Turtle2Controller
Turtle2SmoothController->>Turtle2State: read follow1_pos
Turtle2SmoothController->>Turtle2State: read follow2_pos
Turtle2SmoothController->>Turtle2SmoothController: smooth_action_callback(event)
Turtle2SmoothController->>Turtle2SmoothController: compute pose_reached
Turtle2SmoothController->>Turtle2SmoothController: compute err_gripper1, err_gripper2
Turtle2SmoothController->>Turtle2SmoothController: compute gripper_reached
alt pose_reached and not gripper_reached
Turtle2SmoothController->>Turtle2Controller: arms_control(left_arm_target, right_arm_target)
Turtle2SmoothController-->>Turtle2SmoothController: return (keep publishing gripper targets)
else pose_reached and gripper_reached
Turtle2SmoothController-->>Turtle2SmoothController: return (no further commands)
else not pose_reached
Turtle2SmoothController->>Turtle2SmoothController: interpolate xyz and rpy
Turtle2SmoothController->>Turtle2Controller: arms_control(left_arm_target, right_arm_target)
end
文件级变更(File-Level Changes)
技巧与命令(Tips and commands)与 Sourcery 交互(Interacting with Sourcery)
自定义你的体验(Customizing Your Experience)打开你的 dashboard 来:
获取帮助(Getting Help)Original review guide in EnglishReviewer's GuideAdds a deploy-focused Turtle2 dual-arm environment (Gym entry + config) with relative/absolute pose control modes, wires it into the real-world env registry, and fixes the Turtle2 smooth controller so gripper commands converge even after pose tolerance is reached. Sequence diagram for Turtle2SmoothController gripper convergence logicsequenceDiagram
participant Turtle2SmoothController
participant Turtle2State
participant Turtle2Controller
Turtle2SmoothController->>Turtle2State: read follow1_pos
Turtle2SmoothController->>Turtle2State: read follow2_pos
Turtle2SmoothController->>Turtle2SmoothController: smooth_action_callback(event)
Turtle2SmoothController->>Turtle2SmoothController: compute pose_reached
Turtle2SmoothController->>Turtle2SmoothController: compute err_gripper1, err_gripper2
Turtle2SmoothController->>Turtle2SmoothController: compute gripper_reached
alt pose_reached and not gripper_reached
Turtle2SmoothController->>Turtle2Controller: arms_control(left_arm_target, right_arm_target)
Turtle2SmoothController-->>Turtle2SmoothController: return (keep publishing gripper targets)
else pose_reached and gripper_reached
Turtle2SmoothController-->>Turtle2SmoothController: return (no further commands)
else not pose_reached
Turtle2SmoothController->>Turtle2SmoothController: interpolate xyz and rpy
Turtle2SmoothController->>Turtle2Controller: arms_control(left_arm_target, right_arm_target)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…on only The previous ``examples/embodiment/config/realworld_turtle2_deploy_eval.yaml`` was a 108-line top-level config that pre-committed several deploy-time choices (cnn_policy, embodied_sac algorithm, fixed micro/global batch sizes, etc.). Real deploy users always need to swap their own policy and checkpoint, so the file was not actually a working example — it added a third copy of similar settings on top of the env fragment and the docs skeleton, with no way to keep them in sync. Per review feedback, drop the top-level config. The env fragment ``examples/embodiment/config/env/realworld_turtle2_deploy.yaml`` is the only piece this PR needs to add. Docs (EN + ZH) now show how to integrate the fragment into an existing eval config (override the env default and set ``state_dim`` / ``action_dim`` to 14), and the redundant "minimal eval config skeleton" block is removed from both languages. No code changes; protected paths still zero-diff vs origin/main. Signed-off-by: MuggleZzzH <2558818257@qq.com>
…ode flags Merge the previously separate Turtle2DeployEnv subclass into the base Turtle2Env / Turtle2RobotConfig so all Turtle2 capabilities live in one file. Four new opt-in fields on Turtle2RobotConfig — action_mode (default "relative_pose"), task_description (default ""), expose_gripper_obs (default False), enable_task_reward (default True) — make every deploy behaviour gated and preserve the existing ButtonEnv path exactly. How this differs from RLinf#1082's reverted change to the same file: * _get_observation never modifies tcp_pose. The gripper channel is added as a separate state.gripper key only when expose_gripper_obs=True (default False). ButtonEnv keeps tcp_pose untouched and its observation dict is byte-identical to origin/main. * step() dispatches between private _step_relative_pose (= original step body, unchanged) and a new _step_absolute_pose. No public step_* methods are exposed. * action_mode is only read from override_cfg in the deploy factory; no top-level / override double path. * enable_task_reward short-circuits _calc_step_reward to 0.0 only when False (deploy factory sets this). Default True preserves ButtonEnv reward semantics. Pose-array normalization (np.asarray with dtype=np.float64) is placed in Turtle2Env.__init__ rather than Turtle2RobotConfig.__post_init__. This avoids the Python dataclass pitfall where ButtonEnvConfig's own __post_init__ would shadow the base's; np.asarray is idempotent for already-converted ndarrays so the ButtonEnv path observes no behavioural change. Removed: rlinf/envs/realworld/xsquare/tasks/turtle2_deploy_env.py (275 lines). All logic now lives in turtle2_env.py. The deploy factory in tasks/__init__.py constructs Turtle2RobotConfig directly with deploy-specific defaults injected via a dict merge (expose_gripper_obs=True, enable_task_reward=False, enforce_gripper_close=False, etc.), then wraps with DualRelativeFrame (relative_pose only) and DualQuat2EulerWrapper. ButtonEnv-v1 byte-identical regression verified against origin/main with fixed seed (gym space sample + action seed): obs, reward, terminated, truncated all match exactly across reset + 3 random-action steps. Signed-off-by: MuggleZzzH <2558818257@qq.com>
This reverts commit 4994a37.
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.
Description
Motivation and Context
How has this been tested?
Additional information (optional, e.g., figures and logs):
Types of changes
Checklist:
Summary by Sourcery
引入以部署为核心的 Turtle2 双臂环境与评估配置,并优化 Turtle2 平滑控制器,以更好地处理夹爪收敛问题。
New Features:
Turtle2DeployEnv-v1gym 环境,支持可配置的相对与绝对位姿动作模式,并提供显式的双臂夹爪观测。Turtle2DeployConfig以及用于真实 Turtle2 部署和评估运行的 Hydra 配置。Bug Fixes:
Enhancements:
DualRelativeFrame和DualQuat2EulerWrapper)。Original summary in English
Summary by Sourcery
Introduce a deploy-focused Turtle2 dual-arm environment and evaluation config, and refine the Turtle2 smooth controller to better handle gripper convergence.
New Features:
Bug Fixes:
Enhancements: