Isaac ROS - Action graph in Python (ROS2 Publisher)

Hi!

I’m building action graph through python, one of the example from this Webpage, “Publish Object Pose“.

and here’s the code that I’m working :

 def object_publisher(self, object_path="/visual_cube"):
        try:
            og.Controller.edit(
                {"graph_path": "/ObjectPoseGraph", "evaluator_name": "execution"},
                {
                    og.Controller.Keys.CREATE_NODES: [
                        ("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"),
                        ("ReadPrimAttributePos", "omni.graph.nodes.ReadPrimAttribute"), 
                        ("ReadPrimAttributeOrient", "omni.graph.nodes.ReadPrimAttribute"),
                        ("BreakVector3", "omni.graph.nodes.BreakVector3"),
                        ("BreakVector4", "omni.graph.nodes.BreakVector4"),
                        ("Context", "isaacsim.ros2.bridge.ROS2Context"),
                        ("ROS2Publisher", "isaacsim.ros2.bridge.ROS2Publisher"),
                    ],
                    og.Controller.Keys.CONNECT: [
                        ("OnPlaybackTick.outputs:tick", "ROS2Publisher.inputs:execIn"),
                        ("Context.outputs:context", "ROS2Publisher.inputs:context"),
                        ("ReadPrimAttributePos.outputs:value", "BreakVector3.inputs:tuple"),
                        ("ReadPrimAttributeOrient.outputs:value", "BreakVector4.inputs:tuple"),
                        ("BreakVector3.outputs:x", "ROS2Publisher.inputs:position.x"),
                        ("BreakVector3.outputs:y", "ROS2Publisher.inputs:position.y"),
                        ("BreakVector3.outputs:z", "ROS2Publisher.inputs:position.z"),
                        ("BreakVector4.outputs:x", "ROS2Publisher.inputs:orientation.x"),
                        ("BreakVector4.outputs:y", "ROS2Publisher.inputs:orientation.y"),
                        ("BreakVector4.outputs:z", "ROS2Publisher.inputs:orientation.z"),
                        ("BreakVector4.outputs:w", "ROS2Publisher.inputs:orientation.w"),
                    ],
                    og.Controller.Keys.SET_VALUES: [
                        # Configure the publisher first
                        ("ROS2Publisher.inputs:topicName", "object_pose"),
                        ("ROS2Publisher.inputs:messagePackage", "geometry_msgs"),
                        ("ROS2Publisher.inputs:messageName", "Pose"),
                        
                        # Configure attribute readers
                        ("ReadPrimAttributePos.inputs:name", "xformOp:translate"),
                        ("ReadPrimAttributePos.inputs:primPath", object_path),
                        ("ReadPrimAttributeOrient.inputs:name", "xformOp:orient"),
                        ("ReadPrimAttributeOrient.inputs:primPath", object_path),
                    ],
                },
            )

Here’s Error : OmniGraphError: Attribute spec can only have one ‘.’ separator - saw ‘ROS2Publisher.inputs:position.x’

I’m wondering that if API of ROS2 Publisher does have input for position/orientation x, y, z with Message type geometry_msgs/Pose. In Isaac Sim application, it automatically reconfigured after typing in message type. However, it doesn’t seem like reconfiguring in Python.

Is there a solution for this problem?

What kind of errors do I have in current code?

Thanks in advance.

Hey,

The Ros2 publisher api is defined here:

There is no mention of position and orientation

Might be better to use the odemetry publisher:

1 Like

Thank you! I thought that it will reconfigure just with message definition, since it reconfigured by itself in simulation app. It looks like publishing odometry is a better option as you said.

Here are the docs for Isaac Sim 5.0.0

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.