DEV Community

alphanine
alphanine

Posted on

Turing Sim: Joint Edits That Apply While You Type

Typing a new joint target now moves the arm right away, without pressing Apply. 输入新的关节目标后机械臂立刻动,不用再点 Apply。

Before · 改前

Shoulder target typed while playing, before and after · Before · 改前

After · 改后

Shoulder target typed while playing, before and after

Shoulder target typed while playing, before and after · GIF

Both captures typed -135° into the shoulder target; only the new version moved the arm.


Situation

The Robot panel's joint controller lets you choose a joint, a mode (position, velocity or passive), a target and gains while physics runs. Every change had to be confirmed with "Apply joint command". Typing a new shoulder angle did nothing until you found that button, which made exploring a pose slow. A second problem: each state update rebuilt the joint list and jumped back to the first joint, losing the one you were driving.

Task

Make edits take effect as you make them, without flooding the physics host with a command per keystroke, and keep the driven joint selected.

Action

  1. Live apply with a short pause. A change to the target, stiffness, damping, force limit or mode starts a 40 ms timer, so a held arrow key or a typed number becomes one command rather than many. The button stays for re-sending the same command.
  2. Showing is not commanding. Selecting a joint loads its current settings into the fields without sending anything.
  3. The driven joint stays selected. When the host reports its joints again, the panel keeps the current joint instead of resetting to the first.

The commit was tested in isolation: 15 tests passed, including a new test for the live behaviour.

Result

In both captures the shoulder target was set to -135° by typing, with Apply never pressed. In the old version the arm stayed where it was. In the new one it swings down to the new angle. The demo shows several edits in a row.


背景

Robot 面板的关节控制器可以在物理运行时选择关节、模式(位置、速度、被动)、目标值和增益。以前每次修改都要再点 "Apply joint command" 确认。输入新的肩部角度后什么都不会发生,直到你找到那个按钮,所以试姿态很慢。另一个问题是每次状态更新都会重建关节列表,跳回第一个关节,正在驱动的那个就丢了。

目标与难点

让修改即时生效,但不能每按一次键就给物理进程发一条指令;同时保持当前驱动的关节处于选中状态。

解决思路与行动

  1. 短暂停顿后自动生效。 修改目标、刚度、阻尼、力矩上限或模式时启动一个 40 ms 的计时器,所以按住方向键或输入一个数字只会变成一条指令。按钮保留,用来重发同一条指令。
  2. 查看不等于下指令。 选中一个关节只会把它当前的设置填进输入框,不发送任何指令。
  3. 正在驱动的关节保持选中。 宿主再次报告关节列表时,面板保留当前关节,不再重置到第一个。

这个 commit 单独测试:15 项通过,其中包括新增的即时生效测试。

结果与下一步

两张截图里都是直接输入把肩部目标设为 -135°,都没有点 Apply。旧版本里机械臂纹丝不动;新版本里它直接摆到了新角度。动图里演示了连续几次修改。

Top comments (0)