Skip to content

bug: push_by_setting_velocity 对 RigidEntity 静默失效(set_vel/set_ang 不存在) #242

Description

@humble02

Pre-flight checklist

  • I searched existing issues (open and closed) and found no duplicate.
  • I checked the README Troubleshooting section — this is not one of the documented pitfalls.
  • The bug does not reproduce in a pure Genesis script without GeneLab. (GeneLab 侧调用了不存在的 API,属于 GeneLab 自身问题。)

What happened

push_by_setting_velocity 事件不起作用:对机器人 articulation(Genesis RigidEntity)推力/速度扰动完全没有生效,训练时配置了 push 事件但基座速度从未被改写,且没有任何报错或警告——静默失效。

原因:该函数通过 getattr(handle, "set_vel", None) / getattr(handle, "set_ang", None) 取方法,取不到就直接跳过。而 Genesis 的 RigidEntity 上没有 set_vel 和 set_ang(这两个方法只存在于 fem_entity 和 tool_entity 上),所以对刚体 articulation 两个分支都拿到 None,函数变成 no-op。

Steps to reproduce

# genesis 1.2.0
from genesis.engine.entities import RigidEntity

print(hasattr(RigidEntity, "set_vel"))          # False
print(hasattr(RigidEntity, "set_ang"))          # False
print(hasattr(RigidEntity, "set_dofs_velocity")) # True

任何配置了 push_by_setting_velocity 事件的任务(例如 examples/unitree 下 G1 / Go1 的 env_cfg.py)均可复现:事件按 interval 触发,但基座线速度/角速度不变。

代码位置:src/genelab/mdp/events.py#L151-L184

Environment

genelab 0.4.0
genesis 1.2.0
(报告者原始环境未提供;上述版本为维护者复核环境)

RL backend

Not applicable

Simulation backend

Not applicable / unknown

Logs / traceback

(无输出——问题恰恰是静默失效,没有任何报错或警告)

Anything else

正确做法:浮动基座速度应通过 RigidEntity.set_dofs_velocity 写入 free joint 的前 6 个基座 DoF(0–2 线速度,3–5 角速度),而不是不存在的 set_vel / set_ang。

维护者按 bug 模板重排了本 issue(2026-07-10);原始内容见编辑历史。感谢 @humble02 的报告与根因分析。

Activity

  1. changed the title [-]push_by_setting_velocity 不起作用[/-] [+]bug: push_by_setting_velocity 对 RigidEntity 静默失效(set_vel/set_ang 不存在)[/+] on Jul 10, 2026
  2. KraHsu commented on Jul 10, 2026

    @KraHsu
    Owner

    已在 #244 修复并合入 main。感谢 @humble02 的报告——根因分析完全正确:RigidEntity 上不存在 set_vel / set_ang(它们只在 FEM / tool 实体上),getattr(..., None) 拿不到方法就静默跳过,所以这个事件对所有刚体 articulation 一直是无声 no-op。

    修复正是按你指的方向:新增 genelab.entity.write_root_velocity(),通过 set_dofs_velocity 写 free joint 的前 6 个基座 DoF(0–2 世界系线速度,3–5 角速度)。

    顺着同样的病根做了全量审计,一并修掉的还有:

    • reset_root_state_uniform 的速度随机化半边(同样的死代码)
    • Articulation.write_root_state 的速度写入
    • examples/ 中 wuji cube 的重置 / 速度扰动 kick 和 franka cube 重置
    • 遥操作 HUD 文字(外层 Viewer 未转发 set_message_text,同类静默失效)

    同时新增 tests/test_genesis_api_contract.py,把所有经 getattr 守卫的 Genesis 方法名钉死在契约测试上,今后 Genesis 升级如再出现这类 API 面变化会直接在 CI 报红,而不是无声失效。

    ⚠️ 一个影响提示:此前带 push 事件训练的策略实际上没有吃到这些扰动——在意 push 鲁棒性的话建议在修复后的版本上重训。修复已在 main 上,将随下个版本发布。

  3. added 2 commits that reference this issue on Jul 10, 2026
    7696df6
    d8674af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions