Tutorial for Training and Deploying an RL Policy from Isaac Lab to a Real Robot#
Overview#
This tutorial guides you through the process of deploying a basic RL reach policy trained in Isaac Lab on a real manipulator using Isaac ROS. Both UR10e and Flexiv Rizon 4s robots are supported.
Prerequisites#
Follow the setup instructions in Setup Hardware and Software for Real Robot. Make sure to complete the tab corresponding to your robot (UR or Flexiv) in each step.
Tutorial#
Train and Validate Policy using Isaac Lab#
Set up Isaac Lab using the local installation, but clone the following fork and branch instead of the default Isaac Lab repository:
git clone -b isaac_ros_training https://github.com/shauryadNv/IsaacLab.git
Then continue with the rest of the installation steps from within the cloned
IsaacLabdirectory.Note
The training environment for this task uses the PhysX backend and requires a full Isaac Sim installation. The kit-less (standalone) setup of Isaac Lab is not sufficient. Make sure to follow the installation method that includes Isaac Sim.
Train a policy with RSL-RL:
./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py \ --task Isaac-Deploy-Reach-UR10e-ROS-Inference-v0 --headless
./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py \ --task Isaac-Deploy-Reach-Rizon4s-ROS-Inference-v0 --headless
Validate the policy in simulation:
./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/play.py \ --task Isaac-Deploy-Reach-UR10e-ROS-Inference-v0 --num_envs 1 --checkpoint <CHECKPOINT> \ --visualizer kit
./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/play.py \ --task Isaac-Deploy-Reach-Rizon4s-ROS-Inference-v0 --num_envs 1 --checkpoint <CHECKPOINT> \ --visualizer kit
Replace
<CHECKPOINT>with the path to the.pthpolicy checkpoint file.
Deploy the Policy using Isaac ROS#
Install Cyclone DDS (one-time setup):
sudo apt-get install -y ros-jazzy-rmw-cyclonedds-cpp
Set the Cyclone DDS environment variable (required in every terminal):
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Set up your development environment using the instructions in getting started.
Install
isaac_ros_manipulation_dnn_policyActivate the Isaac ROS environment:
isaac-ros activateInstall the prebuilt Debian package:
sudo apt-get update
sudo apt-get install -y ros-jazzy-isaac-ros-manipulation-dnn-policy
Activate the Isaac ROS environment:
isaac-ros activateUse
rosdepto install the package’s dependencies:sudo apt-get update
rosdep update && rosdep install --from-paths ${ISAAC_ROS_WS}/src/isaac_ros_manipulation/isaac_ros_manipulation_dnn_policy --ignore-src -y
Build the package from source:
cd ${ISAAC_ROS_WS} && \ colcon build --packages-up-to isaac_ros_manipulation_dnn_policy --base-paths ${ISAAC_ROS_WS}/src/isaac_ros_manipulation/isaac_ros_manipulation_dnn_policy
Source the ROS workspace:
Note
Make sure to repeat this step in every terminal created inside the Isaac ROS environment.
Because this package was built from source, the enclosing workspace must be sourced for ROS to be able to find the package’s contents.
source install/setup.bash
Open a new terminal, activate the Isaac ROS environment, and set the Cyclone DDS environment variable:
isaac-ros activate export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Start the robot driver:
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=<UR_TYPE> robot_ip:=<ROBOT_IP> initial_joint_controller:=impedance_controller launch_rviz:=False kinematics_params_file:=<calibration_file_path>
Replace
<UR_TYPE>with the type of your UR robot (for example,ur10e) and<ROBOT_IP>with the IP address of your robot.Note
Replace
<calibration_file_path>with the path to the calibration file for your robot. To calibrate your UR robot, refer to the ur_calibration usage.ros2 launch flexiv_bringup rizon.launch.py \ robot_sn:=<ROBOT_SN> load_gripper:=true \ rdk_control_mode:=joint_impedance \ robot_controller:=streaming_position_controller \ start_rviz:=false
Replace
<ROBOT_SN>with your robot’s serial number (for example,Rizon4s-062839).Note
The
streaming_position_controlleris required for the RL reach policy to stream joint position commands to the robot at high frequency.In a separate terminal, activate the Isaac ROS environment, set the Cyclone DDS environment variable, and run the inference pipeline:
isaac-ros activate export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ros2 launch isaac_ros_manipulation_dnn_policy inference.launch.py checkpoint:=<CHECKPOINT>
Replace
<CHECKPOINT>with the path to the.pthpolicy checkpoint file.ros2 launch isaac_ros_manipulation_dnn_policy inference_flexiv.launch.py checkpoint:=<CHECKPOINT> robot_sn:=<ROBOT_SN>
Replace
<CHECKPOINT>with the path to the.pthpolicy checkpoint file and<ROBOT_SN>with your robot’s serial number.A pre-trained checkpoint is provided as part of the quickstart assets downloaded from NGC during the setup and should be available at
$ISAAC_ROS_WS/isaac_ros_assets/isaac_ros_manipulation_dnn_policy/flexiv_reach/rizon4s.pt.In a separate terminal, activate the Isaac ROS environment and set the Cyclone DDS environment variable:
isaac-ros activate export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Set a target end-effector pose:
POSITION="{x: <X>, y: <Y>, z: <Z>}"; ORIENTATION="{w: <QW>, x: <QX>, y: <QY>, z: <QZ>}"
Replace
<X>,<Y>, and<Z>with the target end-effector position and<QW>,<QX>,<QY>, and<QZ>with the target end-effector orientation as quaternion values.Publish the target end-effector pose.
Note
The
frame_iddiffers between robots: UR usesbasewhile Flexiv usesworldas the reference frame for the goal pose.ros2 topic pub -r 60 /goal_pose geometry_msgs/msg/PoseStamped \ "{ header: { stamp: now, frame_id: base }, pose: { position: $POSITION, orientation: $ORIENTATION } }"
ros2 topic pub -r 60 /goal_pose geometry_msgs/msg/PoseStamped \ "{ header: { stamp: now, frame_id: world }, pose: { position: $POSITION, orientation: $ORIENTATION } }"
Enable the robot controller:
On the UR teach pendant, press play to enable the robot.
The Flexiv controller is activated automatically by the driver. No manual step is needed.
Troubleshooting#
Out of distribution start state of the robot before reach
The policy for reach is trained with only a specific number of Inverse Kinematics (IK) starting solutions.
The other thing to make sure is that the pose we are sending to the reach policy is also in distribution. We make sure of this by having a check at the policy level where before any inference, we check if the pose is in distribution. If you see a log message like the one shown below, then the pose is not in distribution and the reach policy is unlikely to work.
[WARNING] [observation_encoder_node]: target position out of distribution
It will also mention the bounds of the pose that are acceptable, if you want to change this distribution please check the target_pos_centre, target_pos_range, target_rot_centre, target_rot_range flags in the Isaac Lab documentation during policy training.
Conclusion
So in essence, the user must make sure to do the following things:
Ensure the robot is not in an OOD start state
Ensure the pose we are sending to the reach policy is in distribution
If you have verified all of the above, then the reach policy is likely to work.