MoveIt 2 là bộ công cụ lập kế hoạch chuyển động phổ biến nhất cho tay máy trong ROS 2. Kết hợp với Isaac Sim, bạn thử được toàn bộ ứng dụng gắp – đặt (nhận vật, lập kế hoạch tránh va chạm, thực thi) trước khi chạm vào robot thật.

Sau bài này bạn sẽ:
  • Hiểu cách MoveIt 2 nói chuyện với robot trong Isaac Sim.
  • Chạy ví dụ Franka MoveIt và thao tác trên RViz2.
  • Biết cần chuẩn bị gì để dùng với robot của mình.

1. Kiến trúc

Hình 1. Đường đi dữ liệu giữa Isaac Sim, ros2_control và MoveIt 2.
Hình 1. Đường đi dữ liệu giữa Isaac Sim, ros2_control và MoveIt 2.

Isaac Sim publish trạng thái khớp lên /isaac_joint_states và nhận lệnh khớp từ /isaac_joint_commands. Phía ROS 2, gói isaac_moveit dùng topic_based_ros2_control – một "phần cứng" ros2_control đọc/ghi qua hai topic này – nên với MoveIt, robot mô phỏng trông giống hệt robot thật có driver ros2_control. Phía MoveIt, launch file nạp cấu hình bộ điều khiển cho cả cánh tay và tay kẹp, cùng hai pipeline lập kế hoạch OMPL và Pilz.

2. Đồ thị joint state trong Isaac Sim

Ví dụ moveit.py của Isaac Sim 5.1 dựng đồ thị sau (rút gọn):

og.Controller.edit(
    {"graph_path": "/ActionGraph", "evaluator_name": "execution"},
    {
        og.Controller.Keys.CREATE_NODES: [
            ("OnImpulseEvent", "omni.graph.action.OnImpulseEvent"),
            ("ReadSimTime", "isaacsim.core.nodes.IsaacReadSimulationTime"),
            ("Context", "isaacsim.ros2.bridge.ROS2Context"),
            ("PublishJointState", "isaacsim.ros2.bridge.ROS2PublishJointState"),
            ("SubscribeJointState", "isaacsim.ros2.bridge.ROS2SubscribeJointState"),
            ("ArticulationController", "isaacsim.core.nodes.IsaacArticulationController"),
            ("PublishClock", "isaacsim.ros2.bridge.ROS2PublishClock"),
        ],
        og.Controller.Keys.CONNECT: [
            ("OnImpulseEvent.outputs:execOut", "PublishJointState.inputs:execIn"),
            ("OnImpulseEvent.outputs:execOut", "SubscribeJointState.inputs:execIn"),
            ("OnImpulseEvent.outputs:execOut", "PublishClock.inputs:execIn"),
            ("OnImpulseEvent.outputs:execOut", "ArticulationController.inputs:execIn"),
            ("Context.outputs:context", "PublishJointState.inputs:context"),
            ("Context.outputs:context", "SubscribeJointState.inputs:context"),
            ("Context.outputs:context", "PublishClock.inputs:context"),
            ("ReadSimTime.outputs:simulationTime", "PublishJointState.inputs:timeStamp"),
            ("ReadSimTime.outputs:simulationTime", "PublishClock.inputs:timeStamp"),
            ("SubscribeJointState.outputs:jointNames", "ArticulationController.inputs:jointNames"),
            ("SubscribeJointState.outputs:positionCommand", "ArticulationController.inputs:positionCommand"),
            ("SubscribeJointState.outputs:velocityCommand", "ArticulationController.inputs:velocityCommand"),
            ("SubscribeJointState.outputs:effortCommand", "ArticulationController.inputs:effortCommand"),
        ],
        og.Controller.Keys.SET_VALUES: [
            ("ArticulationController.inputs:robotPath", "/Franka"),
            ("PublishJointState.inputs:topicName", "isaac_joint_states"),
            ("SubscribeJointState.inputs:topicName", "isaac_joint_commands"),
            ("PublishJointState.inputs:targetPrim", [usdrt.Sdf.Path("/Franka")]),
        ],
    },
)
# trong vòng lặp: kích đồ thị mỗi bước để publish/subscribe đồng bộ với vật lý
og.Controller.set(og.Controller.attribute("/ActionGraph/OnImpulseEvent.state:enableImpulse"), True)

Tutorial "Joint Control: Extension Python Scripting" giải thích đồ thị này kỹ hơn và cho phép bạn gửi JointState bằng tay để kiểm tra trước khi đưa MoveIt vào.

3. Chạy ví dụ

Hình 2. Các bước chạy thử ví dụ Franka MoveIt.
Hình 2. Các bước chạy thử ví dụ Franka MoveIt.
# cần MoveIt 2 và topic_based_ros2_control đã cài; workspace 5.1 đã build
source /opt/ros/humble/setup.bash
source ~/IsaacSim-ros_workspaces/humble_ws/install/local_setup.bash
ros2 launch isaac_moveit isaac_moveit.launch.py
  1. Isaac Sim: Window > Examples > Robotics Examples > ROS2 > MoveIt > Franka MoveIt, rồi Play.
  2. Chạy lệnh launch ở trên; RViz2 hiện Franka cùng panel MotionPlanning.
  3. Planning Group = hand, Goal State = open, bấm Plan rồi Execute – tay kẹp mở trong Isaac Sim (tài liệu lưu ý chọn close có thể bị hủy trên một số máy).
  4. Planning Group = panda_arm, kéo marker tương tác hoặc chọn <random_valid>, Plan, Execute.
RViz2 đen màn hình chỗ robot: tài liệu gợi ý cập nhật driver Mesa. Nếu robot trong Isaac Sim không cử động: kiểm tra ros2 topic echo /isaac_joint_commands có dữ liệu không, và mô phỏng đang Play.

4. Áp dụng cho robot của bạn

  1. Có URDF và gói cấu hình MoveIt (tạo bằng MoveIt Setup Assistant).
  2. Trong file ros2_control của URDF, dùng plugin topic_based_ros2_control/TopicBasedSystem với hai tham số joint_commands_topic = /isaac_joint_commands, joint_states_topic = /isaac_joint_states.
  3. Trong Isaac Sim: dựng đồ thị như mục 2 cho robot (Tools > Robotics > ROS 2 OmniGraphs > Joint States tạo phần publish), đảm bảo tên khớp trùng URDF.
  4. Chỉnh gain khớp (bài #9) để robot bám quỹ đạo MoveIt sát – gain yếu làm sai lệch lớn và MoveIt báo lỗi khi kiểm tra dung sai thực thi.

Muốn lập kế hoạch nhanh trên GPU, xem cuMotion (cuRobo cho MoveIt 2) trong Isaac ROS – nhắc ở bài #15.

Bài tiếp theo (#24): sinh dữ liệu tổng hợp với Replicator.

Tài liệu tham khảo

Loạt bài "Robot với Isaac Sim" viết theo tài liệu và mã nguồn NVIDIA Isaac Sim 5.1.0. Isaac Sim, Omniverse, PhysX, RTX là thương hiệu của NVIDIA.