12 · MoveIt 2 でアームを制御¶
目標: MoveIt 2 で Lime のアームの動作を計画・実行し、グリッパーを開閉します。ros2_control は 2 つのトピックを通して Isaac Sim とやり取りします。これは、実機のハードウェアドライバーとやり取りするときとまったく同じ方法です。
home 姿勢から手を伸ばした姿勢までの動作を計画し、グリッパーを開きます。実行するのは ros2_control、シミュレーションするのは Isaac Sim です。考え方¶
flowchart LR
subgraph ISAAC["Isaac Sim (isaac/12_moveit.py)"]
rjs[Isaac Read Joint State] --> pjs[ROS2 Publish Joint State]
sjs[ROS2 Subscribe Joint State] --> ac[Articulation Controller]
end
subgraph ROS["ROS 2 container (lime_isaac_moveit)"]
hw[ros2_control hardware:<br/>JointStateTopicSystem]
jtc[arm_controller<br/>JointTrajectoryController]
grip[gripper_controller<br/>GripperActionController]
jsb[joint_state_broadcaster]
mg[move_group<br/>MoveIt 2]
rsp[robot_state_publisher]
end
pjs -- "/isaac_joint_states" --> hw
hw -- "/isaac_joint_commands" --> sjs
mg -- "FollowJointTrajectory" --> jtc --> hw
mg -- "GripperCommand" --> grip --> hw
hw --> jsb -- "/joint_states" --> rsp & mg
- ros2_control は、コントローラーとハードウェアの間にある ROS 2 の標準的なレイヤーです。実機の Lime では、ハードウェアコンポーネントが Dynamixel サーボとやり取りします。ここでは、それが
joint_state_topic_hardware_interface/JointStateTopicSystemです。これはジョイントの状態をあるトピックから読み取り、ジョイントへの指令を別のトピックに書き込みます。それらのトピックの向こう側にいるのが Isaac Sim です。 - MoveIt 2 (
move_group) は、OMPL で衝突のない軌道を計画し、arm_controllerに送ります。グリッパーのゴールはgripper_controllerに送られます。 - トピックごとに持ち主は 1 つ: このチュートリアル以降、
/isaac_joint_statesは Isaac Sim がパブリッシュし、/joint_statesをパブリッシュするのはjoint_state_broadcasterだけです。チュートリアル 07 では、まだ ros2_control がなかったので、Isaac Sim が/joint_statesを直接パブリッシュしていました。
Isaac Sim 側¶
チュートリアル 07 のステージ my_stages/07_odom_tf.usd を開きます。続いて、次のようにします。
- チュートリアル 07 のグラフで、ROS2 Publish Joint State ▸ topicName を
/isaac_joint_statesに変更します。 - 新しい Action Graph を作り、
On Playback Tick→ROS2 Subscribe Joint State(topicName/isaac_joint_commands) →Articulation Controller(targetPrim =…/base_link) とつなぎます。execOut → execIn、jointNames → jointNamesを接続し、出力のpositionCommand、velocityCommand、effortCommandをそれぞれ同じ名前の入力に接続します。 - Play を押します。

graphs.create_odom_tf_joint_states_graph(articulation_root, joint_states_topic="/isaac_joint_states")
graphs.create_joint_command_graph(articulation_root) # /isaac_joint_commands -> Articulation Controller
isaac/common/graphs.py の create_joint_command_graph()
def create_joint_command_graph(
articulation_root: str,
graph_path: str = "/World/ROS2_JointCommands",
topic: str = "/isaac_joint_commands",
):
"""Tutorial 12: apply sensor_msgs/JointState commands (from ros2_control) to the robot's joints."""
import usdrt.Sdf
og = _og()
keys = og.Controller.Keys
og.Controller.edit(
{"graph_path": graph_path, "evaluator_name": "execution"},
{
keys.CREATE_NODES: [
("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"),
("SubscribeJointState", "isaacsim.ros2.bridge.ROS2SubscribeJointState"),
("ArticulationController", "isaacsim.core.nodes.IsaacArticulationController"),
],
keys.SET_VALUES: [
("SubscribeJointState.inputs:topicName", topic),
("ArticulationController.inputs:targetPrim", [usdrt.Sdf.Path(articulation_root)]),
],
keys.CONNECT: [
("OnPlaybackTick.outputs:tick", "SubscribeJointState.inputs:execIn"),
("SubscribeJointState.outputs:execOut", "ArticulationController.inputs:execIn"),
# The message says which joints it commands; pass the names through.
("SubscribeJointState.outputs:jointNames", "ArticulationController.inputs:jointNames"),
("SubscribeJointState.outputs:positionCommand", "ArticulationController.inputs:positionCommand"),
("SubscribeJointState.outputs:velocityCommand", "ArticulationController.inputs:velocityCommand"),
("SubscribeJointState.outputs:effortCommand", "ArticulationController.inputs:effortCommand"),
],
},
)
スクリプト全体:isaac/12_moveit.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 12 - Control the TurtleBot3 Lime arm with MoveIt 2 (ros2_control over topics).
source scripts/isaac_env.sh
python isaac/12_moveit.py
# ROS 2 container: ros2_control + MoveIt 2 + RViz (MotionPlanning panel)
./docker/run_ros.sh ros2 launch lime_isaac_moveit moveit.launch.py
# or plan + execute from Python
./docker/run_ros.sh ros2 run lime_isaac_moveit arm_demo
How Isaac Sim and ros2_control are connected:
Isaac Sim ROS 2 (container)
Isaac Read Joint State -> ROS2 Publish Joint State ---- /isaac_joint_states ----> JointStateTopicSystem
Articulation Controller <- ROS2 Subscribe Joint State <- /isaac_joint_commands --- (ros2_control hardware)
|-- arm_controller (JointTrajectoryController) <- MoveIt
|-- gripper_controller (GripperActionController) <- MoveIt
'-- joint_state_broadcaster -> /joint_states
"""
import sys
from common.cli import parse_args
args = parse_args(__doc__.splitlines()[0])
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": args.headless, "width": 1280, "height": 720})
import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
import numpy as np
from common import graphs, lime
from isaacsim.core.experimental.objects import GroundPlane
from isaacsim.core.experimental.prims import Articulation
from isaacsim.core.simulation_manager import SimulationManager
from pxr import UsdLux
graphs.enable_ros2_realtime(simulation_app)
stage = stage_utils.create_new_stage(template="sunlight")
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)
GroundPlane("/World/GroundPlane")
articulation_root = lime.add_lime("/World/turtlebot3_lime")
graphs.create_clock_graph()
graphs.create_drive_graph(articulation_root)
# Joint states now go to /isaac_joint_states: ros2_control reads them there, and its
# joint_state_broadcaster becomes the ONE publisher of /joint_states.
graphs.create_odom_tf_joint_states_graph(articulation_root, joint_states_topic="/isaac_joint_states")
graphs.create_joint_command_graph(articulation_root) # NEW: /isaac_joint_commands -> arm + gripper
recorder = None
if args.record:
from common.recorder import Recorder
recorder = Recorder(args.record, eye=(0.75, -0.75, 0.6), target=(0.0, 0.0, 0.3), every_n=2, fps=30)
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
robot = Articulation(articulation_root)
arm_idx = robot.get_dof_indices(lime.ARM_JOINTS)
grip_idx = robot.get_dof_indices([lime.GRIPPER_JOINT])
print("[12] ready: /isaac_joint_states published, /isaac_joint_commands subscribed", flush=True)
# The pose that lime_isaac_moveit's arm_demo plans to (see ros2_ws/src/lime_isaac_moveit/scripts/arm_demo.py)
DEMO_TARGET = np.array([0.0, -0.6, 0.3, 0.0, 1.2, 0.0])
steps, reached_at = 0, None
while simulation_app.is_running():
simulation_app.update()
steps += 1
if recorder and steps % 2 == 0:
recorder.capture()
if args.test or args.record:
q = robot.get_dof_positions(dof_indices=arm_idx).numpy()[0]
g = float(robot.get_dof_positions(dof_indices=grip_idx).numpy()[0, 0])
if reached_at is None and np.max(np.abs(q - DEMO_TARGET)) < 0.05 and g > 0.015:
reached_at = steps
print(f"[12] arm reached the demo pose (max error {np.max(np.abs(q - DEMO_TARGET)):.3f} rad), gripper open {g:.4f} m", flush=True)
if reached_at is not None and steps - reached_at > 90:
break
if steps > 240 * 60: # give up after 4 minutes
break
ok = True
if args.test:
ok = reached_at is not None
print(f"[12][test] MoveIt plan executed in Isaac Sim: {'PASS' if ok else 'FAIL'}")
if recorder:
recorder.save()
app_utils.stop()
simulation_app.close(exit_code=0 if ok else 1)
sys.exit(0 if ok else 1)
ROS 側:RViz で計画する¶
./scripts/build_ws.sh # once, if you have not built the workspace yet
./docker/run_ros.sh ros2 launch lime_isaac_moveit moveit.launch.py
RViz の MotionPlanning パネルで、Planning Group を arm にし、インタラクティブマーカーをドラッグして(または home などの Goal State を選んで)から、Plan & Execute をクリックします。Isaac Sim でアームが動く様子を見てください。

ROS 側:Python から計画する¶
lime_isaac_moveit/scripts/arm_demo.py は、MoveIt の /move_action(moveit_msgs/action/MoveGroup、計画と実行)にジョイントのゴールを送り、続いて control_msgs/action/GripperCommand を送ります。
./docker/run_ros.sh ros2 run lime_isaac_moveit arm_demo # reach forward, open
./docker/run_ros.sh ros2 run lime_isaac_moveit arm_demo --pose home --gripper close
[lime_arm_demo]: arm -> [0.0, -0.6, 0.3, 0.0, 1.2, 0.0]: SUCCESS
[lime_arm_demo]: gripper -> 0.019 m: reached=True stalled=False at 0.0174
arm_demo.py
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Plan + execute arm motions with MoveIt 2 and open/close the gripper (tutorial 12).
ros2 run lime_isaac_moveit arm_demo # demo pose, open gripper
ros2 run lime_isaac_moveit arm_demo --pose home --gripper close
It talks to two ROS 2 actions:
/move_action moveit_msgs/action/MoveGroup (move_group: plan + execute)
/gripper_controller/gripper_cmd control_msgs/action/GripperCommand
"""
import argparse
import sys
import rclpy
from control_msgs.action import GripperCommand
from moveit_msgs.action import MoveGroup
from moveit_msgs.msg import Constraints, JointConstraint, MoveItErrorCodes
from rclpy.action import ActionClient
ARM_JOINTS = [f"joint{i}" for i in range(1, 7)]
POSES = { # radians
"home": [0.0, -1.10, 1.80, 0.0, 0.98, 0.0], # folded (SRDF "home")
"demo": [0.0, -0.6, 0.3, 0.0, 1.2, 0.0], # reach forward, gripper pointing down/forward
"left": [1.2, -0.6, 0.3, 0.0, 1.2, 0.0],
}
GRIPPER = {"open": 0.019, "close": -0.010}
def wait_result(node, future):
rclpy.spin_until_future_complete(node, future)
return future.result()
def move_arm(node, client, joints):
goal = MoveGroup.Goal()
req = goal.request
req.group_name = "arm"
req.num_planning_attempts = 5
req.allowed_planning_time = 5.0
req.max_velocity_scaling_factor = 0.5
req.max_acceleration_scaling_factor = 0.5
req.goal_constraints = [
Constraints(
joint_constraints=[
JointConstraint(joint_name=n, position=p, tolerance_above=0.01, tolerance_below=0.01, weight=1.0)
for n, p in zip(ARM_JOINTS, joints)
]
)
]
goal.planning_options.plan_only = False # plan AND execute
handle = wait_result(node, client.send_goal_async(goal))
if not handle.accepted:
node.get_logger().error("MoveGroup goal rejected")
return False
result = wait_result(node, handle.get_result_async()).result
ok = result.error_code.val == MoveItErrorCodes.SUCCESS
node.get_logger().info(f"arm -> {joints}: {'SUCCESS' if ok else f'error code {result.error_code.val}'}")
return ok
def move_gripper(node, client, position):
goal = GripperCommand.Goal()
goal.command.position = position
goal.command.max_effort = 5.0
handle = wait_result(node, client.send_goal_async(goal))
if not handle.accepted:
node.get_logger().error("gripper goal rejected")
return False
result = wait_result(node, handle.get_result_async()).result
node.get_logger().info(f"gripper -> {position:.3f} m: reached={result.reached_goal} stalled={result.stalled} at {result.position:.4f}")
return result.reached_goal or result.stalled
def main():
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--pose", choices=POSES, default="demo")
parser.add_argument("--gripper", choices=GRIPPER, default="open")
args, ros_args = parser.parse_known_args()
rclpy.init(args=ros_args)
node = rclpy.create_node("lime_arm_demo", parameter_overrides=[])
node.set_parameters([rclpy.parameter.Parameter("use_sim_time", rclpy.Parameter.Type.BOOL, True)])
arm = ActionClient(node, MoveGroup, "/move_action")
gripper = ActionClient(node, GripperCommand, "/gripper_controller/gripper_cmd")
for name, client in [("move_group", arm), ("gripper_controller", gripper)]:
if not client.wait_for_server(timeout_sec=60.0):
node.get_logger().error(f"{name} action server not available - is moveit.launch.py running?")
sys.exit(1)
ok = move_arm(node, arm, POSES[args.pose]) and move_gripper(node, gripper, GRIPPER[args.gripper])
node.destroy_node()
rclpy.shutdown()
sys.exit(0 if ok else 1)
if __name__ == "__main__":
main()
Lime の MoveIt 設定を Humble から Jazzy へ移植する¶
upstream の turtlebot3_lime_moveit_config は、Humble と実機向けに書かれたものです。このチュートリアルで必要になった変更を以下に示します。最初の 2 つは Jazzy の移行ノートに書かれているもので、それ以外の行はすべて実際に動かしてみて見つけたものです。
9 つの問題とその対処
| 症状 | 原因 | 対処(lime_isaac_moveit 内) |
|---|---|---|
planning_plugin / default_planner_request_adapters/* が見つからない |
Jazzy で名前が変わった | Jazzy 形式の ompl_planning.yaml:planning_plugins、default_planning_request_adapters/*、default_planning_response_adapters/* |
topic_based_ros2_control が Jazzy では使えない |
パッケージ名が変わった | joint_state_topic_hardware_interface/JointStateTopicSystem(パラメーターは同じ) |
The requested state interface not found: 'wheel_left_joint/effort'。ハードウェアが非アクティブになる |
Isaac Sim の JointState には effort も入っていて、トピックシステムはすべてのフィールドをコピーする | position、velocity に加えて effort の状態インターフェースを宣言する |
| アームがまったく動かない。Isaac Sim が「ensure size of position … arrays match the number of actuators」と警告する | 車輪(状態のみ)とアームが 1 つのコンポーネントに入っていた。そのため指令メッセージには名前が 9 個あるのに、位置は 7 個しかなかった | ハードウェアコンポーネントを 2 つに分ける:IsaacArm(指令あり)と IsaacWheels(状態のみ) |
MoveIt:Start state out of bounds … joint3 |
SRDF の home は joint3 = 1.87 だが、URDF の制限は 1.8567 |
home には 1.80 を使う。1.85 では、アームが数ミリラジアン垂れ下がっただけで、やはり制限に達してしまうことがある |
No acceleration limit was defined for joint joint1 |
Jazzy の時間パラメーター化には加速度の制限が必要 | max_acceleration を含む独自の joint_limits.yaml |
| アームが動いていないのに「SUCCESS」になる | ゴールの許容誤差がないと、軌道コントローラーは時間が過ぎた時点で成功を報告する | arm_controller.constraints.<joint>.goal: 0.05 |
| グリッパーがすぐに「stalled at 0.0」になる | 指が動き出す前にストール検出が働いた | stall_timeout: 2.0、stall_velocity_threshold: 0.0005 |
一度だけ発生:Switch controller timed out after 5 seconds! と出て spawner が終了し、MoveIt にアームとグリッパーのコントローラーがない状態になる |
コントローラーの有効化に、spawner のデフォルトの 5 s より長くかかった(Isaac Sim、YOLO、RViz を同時に動かしていて PC が忙しかった) | moveit.launch.py で spawner に --switch-timeout 30 を指定 |
シミュレーションは一度に 1 つだけ
Isaac Sim のインスタンスが 2 つ動いていると、両方が /clock をパブリッシュします。すると、すべての ROS ノードで時間が前後に飛ぶようになり(「Detected jump back in time. Clearing TF buffer.」)、計画がおかしな形で失敗します。古い実行は tools/stop_isaac.sh で、古い ROS のプロセスは docker/ros_clean.sh で止めてください。
自動チェック¶
python isaac/12_moveit.py --headless --test は、シミュレーション上のアームが arm_demo の姿勢に(0.05 rad 以内で)到達し、グリッパーが開くまで待ちます。確かめているのはコントローラーの報告ではなく、Isaac Sim の中の実際のジョイントの状態です。
[12] arm reached the demo pose (max error 0.012 rad), gripper open 0.0154 m
[12][test] MoveIt plan executed in Isaac Sim: PASS
tools/run_all_checks.sh 12 を使うと、MoveIt と arm_demo がコンテナの中で自動的に起動します。
次へ: 13 · ピック&プレース