Setup ROS

Table of contents

  1. Set up ROS on VOXL
  2. Set up ROS on Host PC
  3. Testing ROS Configuration
  4. Next Steps

Set up ROS on VOXL

VOXL ships with ROS Indigo and the voxl-utils package pre-installed. voxl-utils installs the script my_ros_env.sh to /home/root/ which sources the normal /opt/ros/indigo/setup.bash script to configure the ROS environment variables. It also sets the IP address environment variables. Since everyone’s VOXL will be on a different IP address, you will need to edit this script to match the network configuration for your desired ROS master/slave configuration which will be different depending on your use case.

We recommend having the ROS Master be on VOXL. The Master IP is already set up to 192.168.8.1 to match the Soft Access Point use case. If you have your VOXL on a WiFi network you will need to change this address to match your configuration.

# On VOXL, begin by switching to the bash shell (by default, ADB puts you in the sh shell)
/# bash
/# vi ~/my_ros_env.sh

...

# IP Environment variables must be set after setup scripts
# Set ROS_IP & ROS_MASTER_URI appropriately for your configuration
# 192.168.8.1 is default for the robot in soft access point mode
export ROS_MASTER_URI=http://localhost:11311/
export ROS_IP=192.168.8.1
unset ROS_HOSTNAME

You can refresh your environment variables after updating this script by running:

exec bash

And then check that they have been updated by using the voxl-env tool or just grep’ing the bash environment variables.

/# voxl-env show
ROS_MASTER_URI=http://localhost:11311/
ROS_IP=192.168.8.1
/# env | grep "ROS"
ROS_ROOT=/opt/ros/indigo/share/ros
ROS_PACKAGE_PATH=/home/root/catkin_ws/install/share:/home/root/catkin_ws/install/stacks:/opt/ros/indigo/share:/opt/ros/indigo/stacks
ROS_MASTER_URI=http://localhost:11311/
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=indigo
ROS_IP=192.168.8.1
ROS_ETC_DIR=/opt/ros/indigo/etc/ros

Both of these methods require you to run inside a bash shell, NOT sh. If you logged in over ADB you are put in an sh shell by default and need to start bash manually.

Set up ROS on Host PC

VOXL ships with ROS Indigo pre-installed. However you can use whichever distribution of ROS 1 on your host PC. This will probably be ROS Melodic on Ubuntu 18.04. Follow the ROS wiki instructions to install ros-melodic-desktop-full here: http://wiki.ros.org/melodic/Installation/Ubuntu

To maintain consistency with the previous instructions for setting up ROS on the VOXL we will set up a similar my_ros_env.sh script on the host pc:

touch ~/my_ros_env.sh
echo ". ~/my_ros_env.sh" >> ~/.bashrc

Then paste the following into your my_ros_env.sh script. This is where you will edit IP addresses as necessary.

#!/bin/bash
#
# script to set up ros environment variables. This should be kept as
# /home/root/my_ros_env.sh on the robot and should be called by .bashrc or .profile
# so that the ros environment is loaded when bash starts. You can optionally run
# this from an on_target.sh script just to be sure.
#
# The IP addresses below are specific to the robot and developer, please don't
# set these variables in scripts that are distributed to other users through git
# as a simple git commit could break another user's ros environment.

# load main ros environment
if [ -f /opt/ros/melodic/setup.bash ]; then
    source /opt/ros/melodic/setup.bash
elif [ -f /opt/ros/kinetic/setup.bash ]; then
    source /opt/ros/kinetic/setup.bash
elif [ -f /opt/ros/indiego/setup.bash ]; then
    source /opt/ros/indigo/setup.bash
fi

# if a catkin workspace is setup then make sure the launch
# files and run files are available in the ROS PATH
if [ -f ~/catkin_ws/devel/setup.bash ]; then
    source ~/catkin_ws/devel/setup.bash
fi

if [ -f ~/catkin_ws/install/setup.bash ]; then
    source ~/catkin_ws/install/setup.bash
fi

# ignore ROS_HOSTNAME, it only causes problems and overrides ROS_IP
unset ROS_HOSTNAME

# configure ROS IPs here
export ROS_MASTER_IP=192.168.8.1
export ROS_MASTER_URI=http://${ROS_MASTER_IP}:11311/
export ROS_IP=192.168.8.91

## bonus alias to ssh into ros master
alias sshh='sshpass -p oelinux123 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@${ROS_MASTER_IP}'

The script above provides an alias ‘sshh’ which allows you to ssh remotely into your VOXL using default credentials. Update ROS_MASTER_IP and ROS_IP to match your network configuration. On your host machine, also be sure to update ROS_MASTER_IP and ROS_IP to match this VOXL IP address.

You will need to install sshpass to use the aforementioned alias.

# ON HOST PC
$ sudo apt install sshpass

Note: Due to SSH environment variable issues using the default terminal, we recommend that users with host Ubuntu machine versions newer than Ubuntu 14.04 use XTerm (not the default terminal) to connect to VOXL via SSH while using ROS.

Testing ROS Configuration

To test that your ROS configuration is working, start roscore on VOXL. Double check you are in a bash prompt and not sh before doing so.

PLEASE NOTE: Currently an issue can be seen when attempting to use ROS using the native Ubuntu terminal. As a work around XTerm can be used.

# ON VOXL
/# echo $SHELL
/bin/bash
/# roscore

process[rosout-1]: started with pid [5706]
started core service [/rosout]

Now on your host PC use rostopic to see if it can communicate with VOXL.

# ON HOST PC
$ rostopic list
/rosout
/rosout_agg

Next Steps

Now explore the ROS Nodes provided in the voxl-nodes package!

Source: https://gitlab.com/voxl-public/voxl-nodes/tree/master/catkin_ws/src Package download link: https://docs.modalai.com/docs/resources/downloads/

See the naxt page in this manual for how to build your own ROS nodes for VOXL.

Copyright (c) 2019 ModalAI Inc.