Available Now
Book a demo and get early access. Free trial!
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.
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:
/robot_arm/joint_positions
, a topic you would connect to a controller inside 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:
/robot_arm/joint_positions
🛠 You configure the mapping like this inside Isaac:
{
"topic": "/robot_arm/joint_positions",
"type": "std_msgs/msg/Float64MultiArray",
"targetPrim": "/World/Arm",
"command": "SetJointPositions"
}
/robot_arm/joint_positions
.This turns your node into a remote controller for the simulated robot.
You can also subscribe to topics like /joint_states
from Isaac Sim:
[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.
Book a demo and get early access. Free trial!