Control a UR5 robot using HTC Vive controller.
Before using this package, make sure you have the following prerequisites installed:
- Ubuntu 20.04 & ROS Noetic
Follow these steps for installation:
-
Install URSIM by following the instructions provided in URSim Installation Guide. You may ignore the
net-statistics
part. Just installing deb packages should be good enough -
Install the Steam app for Ubuntu (https://linuxhint.com/install-steamos-on-ubuntu/ )
-
Install the Beta Version of SteamVR on the Steam app (https://www.vive.com/us/support/vive/category_howto/optin-to-steamvr-beta.html)
-
Change the null driver related settings so that you can use the HTC Vive Controller without headset:
- Navigate to hidden files in your home directory and go to
.steam
. Easiest way to do so it to enable theShow Hidden Files
features in the Nautilus file manager - Find
default.vrsettings
, open it and make the following changes under"steamvr"
:"requireHmd": false
"forcedDriver": "null"
"activateMultipleDrivers": true
- There should be one more
default.vrsettings
corresponding to"driver_null"
, open it and enable the null driver by setting"enable": true
- Navigate to hidden files in your home directory and go to
-
Git clone this repo and build the catkin workspace
cd ~/Documents/
mkdir ur5_teleop_ws && cd ur5_teleop_ws/
mkdir src && cd src/
git clone https://github.com/devvaibhav455/UR5_VR_teleop.git .
cd .. && catkin_make
source ~/Documents/ur5_teleop_ws/devel/setup.bash
-
Set up Base Stations - Left (Channel C) and Right (Channel B), ensuring they are pointing 30 degrees down towards the floor and facing the Vive controller. Maintain a minimum distance of ~50cm between the base stations and the Vive controller. Otherwise, the Base stations might not track the controller.
-
In the Steam VR app, you should see that 2 base stations and a controller are connected, indicated by their respective symbols.
One square icon indicating that one base station is detected. When two are connected, two square icons should light up.
If everything is working fine, the controller icon should not blink and two square icons (one for each base station) should light up.
You may take this image as a reference
cd triad_openvr
python3 controller_test.py
It should show 6 DOF pose information in real time.
For calibration, open ur5_teleop_vive/src/cfgs/teleop.yaml
. This file contains the position/calibration settings for an environment, which can be adjusted. Use Rviz for calibration tasks.
The HTC Vive Controller publishes the 6DOF pose but it might appear very far away from the robot in rviz. To overcome this, rotational and translational offsets are applied. You may adjust these values and see which set of numbers work for you. Try setting some values, stop and re-run vive_ur5_teleop.py
to see the change in RViz until you see the marker's position close to the robot.
-
Start ROS core:
roscore
-
Disable simulation time:
rosparam set use_sim_time false
-
Open SteamVR (if it updates, cancel it otherwise need to change the vrsettings file again). If you figure out a way to prevent it from updating, please let me know as well!
-
Source your workspace:
source ~/Documents/ur5_teleop_ws/devel/setup.bash
-
Launch the HTC Vive teleop package:
roslaunch htc_vive_teleop_stuff vive_tf_joy_and_ps.launch
-
Launch the UR5 robot package:
roslaunch ur5_teleop_vive ur5_bringup.launch
It should open gazebo (ignore the robot's condition, it won't update) and RViz
-
Start the UR5 simulation (URSIM):
/opt/ursim/5.12.2/start-ursim.sh UR5
-
If you want to test using a virtual joystick, run:
rosrun rqt_virtual_joy rqt_virtual_joy
-
Run the provided scripts for simulation testing:
cd ~/Documents/ur5_teleop_ws/src/ur5_teleop_vive/src/vive_sim_test
python3 dummy_static_tf_pub.py
cd ~/Documents/ur5_teleop_ws/src/htc_vive_teleop_stuff/scripts/
python3 frame_as_posestamped.py right_controller hmd 30
These steps perform the same job as that of vive_tf_joy_and_ps.launch
but by simulation the controller and following a trajectory defined in dummy_static_tf_pub.py
-
Run the UR5 teleop script:
cd ~/Documents/ur5_teleop_ws/src/ur5_teleop_vive/src/ && python3 vive_ur5_teleop.py
It will publish the HTC Vive controller's position to see in RViz. -
Ensure proper permissions for the gripper USB
/dev/ttyUSB0
:sudo chmod 777 /dev/ttyUSB0
or you may chown as well -
Install the required Python package:
pip3 install pymodbus==2.1.0
-
Run the Robotiq gripper control node:
roscd robotiq_c_model_control/nodes/
python3 CModelRtuNode.py /dev/ttyUSB0
Gripper's light should change to Blue.
- For recording data, use
rosbag record
with the/ee_pose
topic.
-
source ~/Documents/ur5_teleop_ws/devel/setup.bash
-
cd ~/Documents/ur5_teleop_ws/src/ur5_teleop_vive/src/
-
Remember to change your robot's IP in the script before running it
python3 ur_follow_using_class.py
The code is self explainable. However, if you still need any help. Please feel free to raise a question/ bug on Github and I will try my best to respond it ASAP.
Button configuration to control the robot
To analyze data, run the 2cm_gap.py
script, which prints data after every 2 cm of travel from the current pose to the goal pose. The script is located in ~/UR5_VR_teleop/src/ur5_teleop_vive/src
.
Sometimes, RTDE connection is not closed successfully if CTRL+C is pressed for ur_follow_using_class.py
. In that case, you might want to run close_robot.py
, try to emergency stop the robot/ reboot it using the teach pendant, and re-running ur_follow_using_class.py