Skip to content

MoveIt! for Xamyab

Audrey Lee edited this page Nov 5, 2021 · 17 revisions

1. Overview

Gazebo is a simulator and it doesn't do any motion planning. ROS is the middleware that allows Gazebo to talk to other software. MoveIt! is a motion planning framework that uses ROS to talk to Gazebo.

At the end of this tutorial, you will be able to launch our robot's simulation in Gazebo, the MoveIt! planning tool and the visualization tool in Rviz to control the simulated robot. Please refer to the last section for controlling the real robot.

What packages do I need to control the robot Xamyab using MoveIt!?

Repository Simulated Robot (Gazebo) Real Harware
olinrobotics/universal_robot x x
olinrobotics/robotiq_2finger_grippers x x
olinrobotics/ur_modern_driver x

2. Simulated Robot in Gazebo

2.1 Gazebo

Gazebo is a 3D simulator, while ROS serves as the interface for the robot. With Gazebo you are able to create a 3D scenario on your computer with robots, obstacles and many other objects. Gazebo also uses a physical engine for illumination, gravity, inertia, etc.

Gazebo

When installing ROS Kinetic full version, you'd already get Gazebo. However, we need Gazebo9 to avoid this error, spawn_model -J initial joint positions not working #93 (basically the bug is that we cannot set initial positions for the joints for our simulated robot using the -J argument in the launch file)

Step 1 Setup your computer to accept software from packages.osrfoundation.org.

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

You can check to see if the file was written correctly. For example, in Ubuntu Xenial, you can type:

cat /etc/apt/sources.list.d/gazebo-stable.list

# you'd get this result
deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main

Step 2 Setup keys

wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

Step 3 Update Debian package

sudo apt-get update

Step 4 Install Gazebo9.

sudo apt-get install ros-kinetic-gazebo9-ros-pkgs ros-kinetic-gazebo9-ros-control                      

2.2 MoveIt!

MoveIt is a primary source of a lot of the functionality for manipulation (and mobile manipulation) in ROS. MoveIt builds on the ROS messaging and build systems and utilizes some of the common tools in ROS like the ROS Visualizer (Rviz) and the ROS robot format (URDF). MoveIt is fast becoming the entry point into ROS, especially through the use of the MoveIt Setup Assistant for configuring new robots.

MoveIt Path Planning through Rviz

To install MoveIt!, run this command in the terminal:

sudo apt-get install ros-kinetic-catkin python-catkin-tools

Optional Tutorials: if you want to learn more about MoveIt!, you can follow instructions on this page: https://github.com/olinrobotics/HIRo/wiki/Tutorial:-Configuring-MoveIt!-for-Your-Robot.

Troubleshooting: If you have any problem related to pyassimp, you probably want to download, build and install the assimp package from source:

mkdir build && cd build
make -j8
  • Make install will copy it to /usr/local/lib.
make install
  • Then go to /port/PyAssimp in the source folder and run python setup.py install. This should create the necessary files in /usr/local/lib/python2.7/dist-packages/pyassimp.

Now that you've installed Gazebo and MoveIt! It's time to clone our team's ROS packages to work with the Xamyab robot!

2.3 Universal Robot (Modified version to work with 2 UR5 arms)

The olinrobotics/universal_robot repository provides ROS support for the universal robots.

Clone the repository into your catkin workspace and make sure you are working with the hiro-xamyab branch. Install the dependencies and build it:

cd ~/catkin_ws/src/
git clone https://github.com/olinrobotics/universal_robot.git

Before running catkin_make, make sure to install all missing packages. Run the script below in the catkin_ws directory:

cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -r -y
catkin_make      # You can run catkin_make after downloading all packages in Section 2.5

2.4 Robotiq 2F-140 Gripper

The olinrobotics/robotiq_2finger_grippers ROS package contains the URDF of the gripper, which is needed to spin up the simulated robot in Gazebo.

cd ~/catkin_ws/src/
git clone https://github.com/olinrobotics/robotiq_2finger_grippers.git
cd ..
catkin_make      # You can run catkin_make after downloading all packages in Section 2.5

2.5 HIRo Core

Finally, we need common packages to run sensor software. Clone the main olinrobotics/hiro repository to your /src folder and run catkin_make:

cd ~/catkin_ws/src/
git clone https://github.com/olinrobotics/hiro.git
cd ..
catkin_make

2.6 Test your Installations

To test your installations, run your simulated robot in Gazebo and fire up the MoveIt! nodes to perform control and planning tasks.

Step 1 To bring up the simulated robot in Gazebo, run:

roslaunch ur_gazebo xamyab.launch grippers:=3 sim:=true limited:=true

grippers:=GRIPPER_CODE (optional) determines the number of grippers we want to use. GRIPPERS_CODE:

  • 0 = No gripper
  • 1 = Gripper for left arm only
  • 2 = Gripper for right arm only
  • 3 = Grippers for both arms (default)

sim:=BOOLEAN (optional) determines whether to bring up the simulated depth camera:

  • true = bring up the camera (default)
  • false = no camera

limited:=true (optional/default) as MoveIt! seems to have difficulties with finding plans for the UR with full joint limits [-2pi, 2pi], this joint_limited version restricts joint limits to [-pi, pi].

Step 2 For setting up the MoveIt! nodes to allow motion planning run:

roslaunch xamyab_moveit_config xamyab_moveit_planning_execution.launch grippers:=3

Step 3 For starting up RViz with a configuration including the MoveIt! Motion Planning plugin run:

roslaunch xamyab_moveit_config moveit_rviz.launch

3. Working with Real Hardware

To work with the real robot, instead of spinning up the simulated robot in Gazebo (step 1 in Section 2.6), we connect with the real arms/grippers and run necessary launch files. Please refer to these resources below for more instruction on how to connect with the hardware:

Following the tutorials will help you understand how to connect and control each hardware component separately (i.e. one arm or one gripper). However, if you want to control the whole Xamyab robot, all you need to run are these launch files:

Step 1 Spin up one simulated gripper and connect with a real gripper:

roslaunch robotiq_2f_gripper_control xamyab_robotiq_dual_action_server.launch left_sim:=true right_sim:=false right_comport:=/dev/ttyUSB0

left_sim and right_sim indicate whether the left/right gripper is simulated or real.

right_comport:=/dev/ttyUSB0 indicates the USB port and is needed because the right gripper is real (right_sim:=false)

Step 2 Connect with two robotic arms:

roslaunch ur_modern_driver xamyab_bringup.launch grippers:=3 left_robot_ip:=10.42.1.175 right_robot_ip:=10.42.0.54 left_reverse_port:=50002 right_reverse_port:=50001

Currently, left_robot_ip:=10.42.1.175 and right_robot_ip:=10.42.0.54. But, please check if robotic arms are switched and you have the right IP addresses when running the command.

Step 3 For setting up the MoveIt! nodes to allow motion planning run:

roslaunch xamyab_moveit_config xamyab_moveit_planning_execution.launch grippers:=3

Step 4 For starting up RViz with a configuration including the MoveIt! Motion Planning plugin run:

roslaunch xamyab_moveit_config moveit_rviz.launch

Notes: All the arguments (grippers, left_sim, left_robot_ip, etc) are optional, but you should know that they exist. You can find more arguments and their documentation in each of the launch files.