Writing a Node in ROS 2 for Isaac Sim

Blog>
writing-a-node-in-ros-2-for-isaac-sim
Last updated: 
June 29, 2025

In a simulated robotics workflow with Isaac Sim, a ROS 2 node can act as a control agent for a robotic arm. For example, it might send joint commands, listen to joint state updates, or control motion planning logic. Let’s walk through what this looks like for Python.

🐍 Python Node for Isaac Robotic Arm

Here’s an example Python node that could command the joints of a robotic arm in Isaac Sim via ROS 2:

# Import the core ROS 2 Python library
import rclpy
from rclpy.node import Node

# Import the standard message type for publishing an array of float64 values (e.g., joint angles)
from std_msgs.msg import Float64MultiArray

# Define a new ROS 2 Node class for commanding a robotic arm
class ArmCommandNode(Node):
    def __init__(self):
        # Initialize the node with the name 'arm_command_node'
        super().__init__('arm_command_node')

        # Create a publisher that sends Float64MultiArray messages to the topic '/robot_arm/joint_positions'
        # The queue size is set to 10
        self.publisher = self.create_publisher(Float64MultiArray, '/robot_arm/joint_positions', 10)

        # Create a timer that triggers the publish_command method every 1.0 second
        self.timer = self.create_timer(1.0, self.publish_command)

    # Method to publish a command to the robot arm
    def publish_command(self):
        msg = Float64MultiArray()
        # Populate the message with example joint angles (6 joints)
        msg.data = [0.0, 0.5, -0.5, 1.0, 0.0, 0.3]
        # Publish the message to the topic
        self.publisher.publish(msg)
        # Log the published data for visibility/debugging
        self.get_logger().info(f'Published joint command: {msg.data}')

# Entry point of the ROS 2 Python node
def main(args=None):
    # Initialize the ROS 2 Python client library
    rclpy.init(args=args)

    # Create an instance of the ArmCommandNode
    node = ArmCommandNode()

    # Keep the node alive and responsive (spins the event loop)
    rclpy.spin(node)

    # Clean up when the node is shut down
    node.destroy_node()
    rclpy.shutdown()

💡 This node:

  • Publishes to /robot_arm/joint_positions, a topic you would connect to a controller inside Isaac Sim.
  • Can be used to run simple scripted motions or test inverse kinematics solutions.

🤖 How a ROS 2 Node Connects to Isaac Sim

In Isaac Sim, you simulate a robotic arm using USD scenes with physics-enabled components like joints and articulation bodies. To control this robot from ROS 2, you use a ROS bridge that connects your ROS 2 node to Isaac's internal simulation engine.

Here’s how the connection works:

🧩 1. Articulation Controller in Isaac Sim

  • The robotic arm in Isaac Sim is rigged as an Articulation (i.e., physics-aware jointed body).
  • It’s driven by the ArticulationController extension, which can accept joint position or velocity commands.

🔌 2. ROS 2 Bridge (ros2_tutorials + ros2_bridge)

  • Isaac Sim includes a ROS2 bridge that listens to ROS topics and translates them into simulation actions.
  • Example topic: /robot_arm/joint_positions
  • The bridge maps this topic to the ArticulationController's internal input port.

🛠 You configure the mapping like this inside Isaac:

{
  "topic": "/robot_arm/joint_positions",
  "type": "std_msgs/msg/Float64MultiArray",
  "targetPrim": "/World/Arm",
  "command": "SetJointPositions"
}

📤 3. Your ROS Node Publishes Commands

  • Your custom Python or C++ node sends joint angle commands to /robot_arm/joint_positions.
  • The bridge receives these and updates the joint angles in the simulation.

This turns your node into a remote controller for the simulated robot.

📥 4. Feedback Loop (Optional)

You can also subscribe to topics like /joint_states from Isaac Sim:

  • Let’s you close the control loop.
  • Useful for building controllers (PID, trajectory tracking, etc.).

🔄 Example Workflow

[ROS 2 Node] --> [ROS Topic: /robot_arm/joint_positions]
[Isaac ROS2 Bridge] --> [ArticulationController in Isaac Sim]
[Simulated Robot Arm Moves]

This makes your node a true simulation-time agent that could be replaced with a real-world controller or planner later.

Available Now

Book a demo and get early access. Free trial!

Email Address:
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Email Address:
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.