Skip to content

Tutorial 2: ROS package

Brad Saund edited this page Apr 29, 2020 · 8 revisions

Previous Tutorial 1: Unity

Next Tutorial 3: Video and RGBD

Tutorial 2: Set up the ROS communication

This second tutorial explains how to:

  1. Set up the Linux machine (possible in a VM)
  2. Set up the ROS package for communication to the Unity package
  3. Run the a simple robot controller and simulated robot
  4. Interact with the robot in VR

You will need:

  • the Windows computer with Unity from the previous tutorial
  • a Linux machine with ROS
  • These machines need to communicate over the ROS network
  • A basic understanding of ROS, with some previous experience

Time: 15min to 1.5hr, depending on computer setup

(Optional: Install Linux on a virtual machine)

Complete this section if you would prefer to run some or all of the ROS software on the same windows computer used for Unity.

  1. Install Virtual Box
  2. Install Ubuntu (e.g. 18.04)
  3. Set up the networking to allow communication between VM and host

See this tutorial for details

Set up ROS

Set up ROS on the Linux machine

Set up ROS packages

  1. Clone the following repo as ROS packages (i.e. under the src folder):
  1. Set up communications
  • Decide which computer will be ros master, and set the appropriate variables
  • Find the IP of the Linux machine (e.g. the virtual machine from above) using ifconfig
  • Enter the Linux machine's IP in the Unity file (RosBridgeSettings -> Mosmaster -> RosBridgeServer URL). It should take the form ws://xxx.xxx.xxx.xxx:9090 (Note: you can assign a static IP from your router to avoid having to update this value)

Unity Pane with Rosbridge highlighted rosbridge pane

Launch the system

From the Linux machine launch (in separate terminal windows)

  1. roscore
  2. roslaunch victor_fake_hardware_interface fake_dual_arm_lcm_bridge.launch
  3. rosrun dual_arm_teleop make_victor_fast.py and then roslaunch unity_launch_files unity_setup.launch
  4. From Unity, launch ("play") the project. (Note: The VR interface should launch right away. If it hangs for a few seconds, likely the VR system cannot communicate with ROS)

You should see the Robot with his hands in the air. Unity first view

Grab one of the robot's hands with your hands. Move you hand up and "click" the side gripper buttons on your VR controller.You can drag the Robot's hand around. Unity Grabbing Victors hand Unity Moving hands

Troubleshooting

Here are some common errors I have found.

  • If the VR system launches but it takes while, and/or you see the error message that the RosBridge cannot connect, double check the IP entered in Unity for the Rosmaster script. Note that ifconfig may report multiple interfaces. Try cycling through all of them
  • If the VR system launches and the Rosbridge connection is successful but the terminal with the fake_victor_hardware_interface is reporting an invalid mode, Re-run rosrun dual_arm_teleop make_victor_fast.py. The robot (Victor) must be in the correct mode to accept joint position commands
  • If the VR system launches but the robot does not move and you've checked the above issues, try moving more slowly. The robot will reject large motions