Installing ROS and Other Required Software (DEPRECATED) - OxRAMSociety/RobotArm GitHub Wiki

DEPRECATED - This page will eventually be updated to act as a quick-start for users familiar with ROS, but for now I suggest starting here instead.

Introduction

In this tutorial, we will be installing and setting up everything needed to control the RBX1 arm. We will also test the software pipeline at the end of the tutorial by giving commands to the simulated arm and sending the calculated joint trajectories to an Arduino Mega (2560) board.

The software that we will be using requires Linux as the operating system; I suggest Ubuntu. You will likely need to install Virtualbox on your PC and run Ubuntu through a virtual machine. This tutorial assumes you have Ubuntu 20.04, which is recommended, but it should also work for Ubuntu 18.04 if you change instances of 'noetic' to 'melodic' instead.

Installing ROS

Resource: http://wiki.ros.org/noetic/Installation

Install ROS (Full Desktop version) using the instructions in the link provided. Also follow the instructions for installing rosdep.

Installing MoveIt

Resource: https://ros-planning.github.io/moveit_tutorials/doc/getting_started/getting_started.html

NOTE: Throughout the tutorial we will be using catkin build to create and manage a workspace rather than catkin_make.

Install MoveIt using the instructions in the link provided. NOTE: Before you run the catkin config ... command, you MUST first run source /opt/ros/noetic/setup.bash. Also follow the instructions to set up and configure a workspace using catkin, and add the line to automatically source the workspace to your .bashrc. You do not need to bother installing the config package for the panda arm, as we will be creating one for the RBX1 arm.

(Optional) Installing Tmux

Resource: https://linuxize.com/post/getting-started-with-tmux/

Install Tmux using the instructions in the link provided. Given that we will often have 5 or more command line tabs running simultaneously when controlling the arm, this may prove to be very helpful for managing all of them.

Setting up the Robot Arm

Resource: https://github.com/equinor/kitchen-rbx1-ros

Download the RBX1 robot arm's GitHub repo. Move the rbx1_urdf folder to the src folder in your new workspace. Now navigate to ws_moveit and run catkin build again so that the folder is recognised as a package.

Resource: https://ros-planning.github.io/moveit_tutorials/doc/setup_assistant/setup_assistant_tutorial.html

Use the MoveIt Setup Assistant to configure the arm for use with MoveIt, referring also to the notes provided.

Notes for Each Step:

  1. (Start) - Choose 'Create New MoveIt Configuration Package'. To load the URDF for the RBX1, select 'Browse' and select the file in the following location in your workspace: /ws_moveit/src/rbx1_urdf/urdf/rbx1.urdf. Then select 'Load Files'. If the package is not found, try running catkin build or sourcing your workspace to your .bashrc again before re-attempting.

  2. (Self-Collisions) - Follow instructions provided. The default parameters are fine.

  3. (Virtual Joints) - Follow instructions provided, with the exception of setting the child link to 'base_link' instead of 'panda_link0'.

  4. (Planning Groups) - For the arm planning group, set the name to 'rbx1_arm'. Choose KDL to be the IK solver. Define the planning group using the 'Kinematic Chain' option. Choose the Base Link to be 'base_link' and the Tip Link to be 'link_6_hand'.

For the gripper planning group, set the name to 'rbx1_gripper'. Leave IK solver as 'None'. Define the planning group using the 'Add Links' option. The selected links should be the six links with the word 'gripper' in their names.

  1. (Robot Poses) - Follow instructions provided, setting a 'home' pose for the rbx1_arm planning group where all the joints are at 0 degrees.

  2. (End Effectors) - Set end effector name to be 'rbx1_gripper' and choose 'rbx1_gripper' to be the end effector group. The parent link should be 'link_6_hand'.

  3. (Passive Joints) - Skip this step.

  4. (Controllers) - Follow instructions provided. Name the controller as 'rbx1_arm_position_controller'. Note that the stepper motors we use to control the arm work on position inputs (i.e. by telling them to perform a number of steps) rather than by effort. Velocity control is pending. Choose 'rbx1_arm' as the selected group to be controlled.

  5. (Simulation) - Run 'Generate URDF'.

  6. (3D Perception) - Skip this step (for now - in future, we may implement a stereo camera for 3D perception).

  7. (Author Information) - Follow instructions provided.

  8. (Configuration Files) - Select 'Browse' and navigate to the src folder in ws_moveit. Create a new folder rbx1_moveit_config and select it for generating the config files. Once the files are generated, exit the setup assistant.

Now run catkin build again so that the config package is recognised.

Testing Installations So Far

  1. Create a new package to house the test script - catkin_create_pkg rbx1_scripts rospy std_msgs moveit_commander moveit_msgs geometry_msgs

  2. Navigate to /ws_moveit/ and run catkin build to build the new package.

  3. Navigate to /rbx1_scripts/src/ and run touch rbx1_test.py to create a new python script.

  4. In our Github repo, navigate to /Movement/Test_Scripts/ and copy + paste the contents of rbx1_test.py into this file.

  5. Run chmod a+x rbx1_test.py to make the file executable.

To test our installation, run the following in terminal:

  • Tab 1: roscore - Initialises ROS.

  • Tab 2: roslaunch rbx1_moveit_config demo.launch - RViz should load up with the 3D model of the arm.

  • Tab 3: rosrun rbx1_scripts rbx1_test.py - The arm should carry out a set of move commands.

Installing Arduino IDE

Note that for this project we are using an Arduino Mega 2560 board.

Resouce: https://www.arduino.cc/en/software

Download the appropriate version of the Arduino IDE for your computer (x32 or x64). Extract the folder to your Downloads folder and navigate to the 'arduino-1.8.19-(version)' folder in the terminal.

Run sudo ./install.sh to install the Arduino IDE.

If using Virtualbox, in order to connect an Arduino board, you will have to add the device in the Virtualbox Manager. To do so, navigate to Settings > Ports > USB with the board plugged into your PC and click the 'add USB filter' icon to the right of the tab. Select the Arduino device. NOTE: You will have to do this again for every Arduino board you use. If permission to access serial ports is asked when subsequently loading Ubuntu, allow permission.

To select the board in the Arduino IDE, first navigate to Tools > Board and choose 'Arduino Mega or Mega 2560'. Then navigate to Tools > Port and choose the port corresponding to the Arduino Mega 2560. The board must be plugged in for this option to be available!

Try uploading the 'Blink' script in the Basics section of the provided Arduino library (File > Examples). It is possible that you will not have permission to use the serial port to upload; in which case open Terminal and run the following commands:

  1. ls -l /dev/ttyACM*

  2. sudo usermod -a -G dialout username where username is your Linux username.

Restart Linux and try uploading the 'Blink' script again.

Installing ROS Serial

Open Terminal and run the following commands:

  1. sudo apt-get install ros-noetic-rosserial-arduino

  2. sudo apt-get install ros-noetic-rosserial

Installing ROS Serial Arduino Library

  1. In the Arduino IDE, navigate to Tools > Manage Libraries.

  2. Search for 'Rosserial Arduino Library' and select 'Install'.

Unfortunately, the library is currently broken as-is and we have to fix it ourselves. To do this, open Files and navigate to Arduino > libraries > Rosserial_Arduino_Library\src\ros\msg.h. Then do the following:

  1. At line 40, replace #include <cstring> with the following code:
#include <string.h>

void memcpy(void *dest, void *src, size_t n)
{
    char *csrc = (char *)src;
    char *cdest = (char *)dest;
    for (int i=0; i<n; i++)
        cdest[i] = csrc[i];
}
  1. At lines 68 and 182, remove the std:: from std::mempy.

Save and close the file. The library should now be working.

Testing Installations

  1. Launch the Arduino IDE and create a new blank script.

  2. In our Github repo, navigate to /Movement/Arduino Scripts/ROS-motor-test and copy + paste the contents of ROS-motor-test.ino into the script. Save the script.

  3. Verify and Upload the script to the Arduino Mega board.

You now have an Arduino script that retrieves joint trajectory data from MoveIt and converts it into step commands for the motors.

We shall test the entire pipeline. Run the following in Terminal:

  • Tab 1: roscore - Initialises ROS.

  • Tab 2: roslaunch rbx1_moveit_config demo.launch - RViz should load up with the 3D model of the arm.

  • Tab 3: rostopic echo /move_group/fake_controller_joint_states - This will show the current joint trajectory information (we are observing the contents of the topic that houses this information).

  • Tab 4: rosrun rosserial_python serial_node.py /dev/ttyACM0 _baud:=115200 - This sets up the Arduino Mega as a ROS node, allowing it to receive messages from the joint trajectory topic as a subscriber.

  • Tab 5: rosrun rbx1_scripts rbx1_test.py - The arm should carry out a set of move commands.

Quickly switch back to Tab 3 (unnecessary if using Tmux) and make sure the simulated RBX1 arm is visible. You should observe three things:

  1. The arm moves to carry out the set of move commands. This means that ROS and MoveIt are working properly, and that MoveIt can solve the inverse kinematics of the RBX1 arm model set up with the Setup Assistant.

  2. The joint trajectory information (Tab 3) is changing as the arm is moving. The changing values are the desired joint values (in radians) published by MoveIt as the motion is carried out.

  3. One of the LEDs on the Arduino Mega is blinking rapidly whenever the arm is moving. This means that that ROS Serial and all the Arduino-related installations are working and the Arduino Mega is acting as a subscriber, receiving the joint trajectory information whenever it is updated.

If this is all working, congratulations! You have the entire software pipeline working in order to control the RBX1 arm. Next steps would be to connect stepper motors to the Arduino and try to get them to move (see related wiki pages) or create new python scripts with which to command the arm!

⚠️ **GitHub.com Fallback** ⚠️