8. Joint Control: Extension Python Scripting

8.1. Learning Objectives

In this tutorial, we will interact with a manipulator, the Franka Emika Panda Robot. We will

  • Add a joint state bridge via UI

  • Add a joint control rosbridge using python API in the extension using the script editor.

Prerequisite

  • Completed Workflows to understand the Extension Workflow.

Note

if using ROS melodic with Ubuntu 18.04, use python instead of python3 for the commands below

8.2. Add Joint States in UI

  1. Go to Content tab below the viewport, and open Isaac/Robots/Franka/franka_alt_fingers.usd.

  2. Create -> Isaac -> ROS -> Joint States to add a joint state bridge. In the Raw USD Properties of the newly added /ROS_JointStates, add the /panda robot articulation to the targetPrim.

  3. Make sure roscore is running, press Play to start publishing joint states to the /joint_states topic and subscribing commands on the /joint_command topic.

  4. To test out the ROS bridge, use provided python script to publish joint commands to the robot. In a ROS-sourced terminal:

python3 ros_workspace/src/isaac_tutorials/scripts/ros_publisher.py
  1. While the robot is moving, open a ROS-sourced terminal and check the joint state rostopic by rostopic echo /joint_states. You’ll see that the position of the joints are changing following the robot.

8.3. Add Joint States in Extension

The same action done via UI can also be done using python script. More details regarding the different workflow of using Omniverse Isaac Sim can be found Workflows.

  1. Go to Content tab below the viewport, and open Isaac/Robots/Franka/franka_alt_fingers.usd.

  2. Open Script Editor in Window -> Script Editor and copy paste the following code into it. This is the equivalent to Step 2 of the previous section.

import omni
from pxr import Usd, UsdGeom
import omni.usd

stage = omni.usd.get_context().get_stage()
ROS_prim = stage.GetPrimAtPath("/ROS_JointState")
if not ROS_prim:
    omni.kit.commands.execute(
        "ROSBridgeCreateJointState",
        path="/ROS_JointState",
        enabled=True,
        state_topic="/joint_states",
        command_topic="/joint_command",
        articulation_prim_rel=["/panda"],
    )
  1. Make sure roscore is running, press Run in the Script Editor and the Joint State bridge should be added. You can find the corresponding Prim in the Stage Tree.

  2. Same as the previous section, test out the ROS bridge using the provide python script to publish joint commands to the robot.

python3 ros_workspace/src/isaac_tutorials/scripts/ros_publisher.py
  1. check the joint state in rostopic echo while it’s moving.

8.4. Summary

This tutorial covered adding a ROS Joint State bridge via both UI and Extension scripting.

8.4.1. Next Steps