Tutorial – Part 4: Gumstix on the iRobot Create 2

July 6, 2015 | Jesse Ludtke

In part four of the tutorial, we’ll install and setup the ROS package we built in part 3.

Catch up on any tutorials you’ve missed:

Tutorial 1
Tutorial 2
Tutorial 3
Tutorial 4 (You are here)
Tutorial 5

1 Connecting to the COM and Enabling WiFi

In this section we will cover the booting up and connecting to the COM, as well as enabling WiFi on the COM. Carrying on from the previous tutorial, insert the new microSD card into the COM and place the COM on an expansion board with a USB console port.

1.1 Connecting to the COM (on Host)

Plug a USB cable between your host machine and the COM and start a screen session on your host machine (replace /dev/ttyUSBn with the path to your COM):

$ screen /dev/ttyUSBn 115200n8

Connect power to the expansion board and watch the boot sequence. If the COM fails to boot, you m
ay want to retry either bitbaking the image and/or re-extracting the files to the SD card.

When prompt for a login, login as root (“pepper” will be displayed instead of “overo” if you are using a Gumstix Pepper:

overo login: root

1.2 Enabling WiFi (on COM)

Make sure you have the proper antenna inserted into the connector on the COM, and edit the following file with your favourite text editor (pick wlan0 if using an Overo or Pepper and mlan0 if using a Duovero):

# vim /etc/wpa_supplicant/wpa_supplicant-{wlan0|mlan0}.conf

Uncomment the network section and enter your WiFi connection’s SSID and PSK. Then enable WiFi and reboot:

# systemctl enable wpa_supplicant@{wlan0|mlan0}
# sudo reboot

After the reboot, check your connection with ifconfig(your host machine and COM needs to be on the same network for the irobotcreate2 package to work):

# ifconfig
wlan0 Link encap:Ethernet HWaddr ab:cd:ef:gh:ij:kl
inet addr:192.168.1.xxx Bcast:192.168.1.mno Mask:

Take note of your inet addr, this is how your host will identify the COM over the network.

Do the same thing on your host machine to get its inet addr, we will have the COM look for your host’s inet addr as the ROS master node location:

(on Host):

$ ifconfig
wlan0 Link encap:Ethernet HWaddr ab:cd:ef:gh:ij:kl
inet addr:192.168.1.yyy Bcast:192.168.1.mno Mask:

After WiFi is enabled, and your COM is on the same wireless network as your host machine, you can replace the screen session with an SSH session and gain wireless command line access to the COM from your host machine:

$ ssh root@%YOUR_GUMSTIX%.local

Note: Replace %YOUR_GUMSTIX% with the COM or SBC that you are using “overo”, “duovero”, or “pepper”.

Note: If using %YOUR_GUMSTIX%.local fails, you can also replace it with the inet addr of your Gumstix COM or SBC.

Now just add the battery pack(or connect the cable if you are using a Pepper) and your robot will be wireless!

2 Running the ROS Nodes

Next we will go over starting the ROS Package using separate launch files, and a unified launch file as well.

(on Host):
Open a new terminal window and start the ROS master node:
Note Setup.bash must be sourced before using any ROS specific commands, this must be done every time you start a new terminal session. I suggest adding it to the bottom of ~/.bashrc so it runs automatically each time you launch a new terminal session

$ source /opt/ros/indigo/setup.bash
$ roscore

Open another terminal window and run the node to connect to your PS3 controller:

Note: This must be done independantly as the ps3joy.py node requires root permissions to access the Bluetooth drivers on your machine. Starting the other joystick node via the *.launch files without a PS3 controller connected would also throw errors.

$ rosrun ps3joy ps3joy.py

Hit the PS button as instructed and wait until Connection activated is printed on the terminal.

2.1 Starting with Individual Launch Files

Open a third terminal and launch the remaining nodes on your host machine:

$ source ~/catkin_ws/devel/setup.bash
$ roslaunch irobotcreate2 host_teleop.launch

If everything goes well, you should be looking at 3 terminal windows and a small white window.

We need to source the environmental variables for ROS on the COM as well, I like to make a file for this and scp it over to the COM whenever I build a new image:

(on Host):
Create a new file with the following contents (replace 192.168.1.yyy with your HOST’s IP address found in the previous tutorial):

export ROS_ROOT=/opt/ros/indigo
export PATH=$PATH:/opt/ros/indigo/bin
export LD_LIBRARY_PATH=/opt/ros/indigo/lib
export PYTHONPATH=/opt/ros/indigo/lib/python2.7/site-packages
export ROS_MASTER_URI=http://192.168.1.yyy:11311
export CMAKE_PREFIX_PATH=/opt/ros/indigo
touch /opt/ros/indigo/.catkinexec “$@”

Save it as ros_init.sh, then scp it over to the COM:

$ scp ./ros_init.sh root@192.168.1.xxx:/home/root

(on COM):
Initialize the ROS environment and launch the target nodes (note: tab completion on meta-ros doesn’t work as well as on desktop ROS):

# source ./ros_init.sh
# roslaunch irobotcreate2 target_create2.launch

When the COM sends a startup message to the Create 2, it will play a short melody. After you see some information (bootloader version, serial number etc…) about the Create 2 scroll through on the terminal, you should be able to start driving around! Webcam feed should also pop up on the white window that launched on the host earlier.

2.2 Starting with a Unified Launch Files

The <machine> tag recognized by roslaunch allows the user to declare multiple machines. The unified_*.launch files make use of this tag to streamline the node launching process into a single launch file. There are two flavours of unified launch files in this package: a keyboard teleop, and a PS3 teleop. The PS3 flavour isn’t completely streamlined as you still need to launch the ps3joy.py node first (as instructed above). The keyboard flavour is completely streamlined and will launch both local and remote nodes upon launch. Both files are intended to be run on the host machine:

You must first provide the target with your host’s public key for authorization:

(on Host):

$ scp .ssh/id_rsa.pub root@overo.local:/home/root/

(on COM):

# mkdir ~/.ssh/
# touch ~/.ssh/authorized_keys
# cat ./id_rsa.pub >> ~/.ssh/authorized_keys

(on Host):

$ roslaunch irobotcreate2 unified_launch_kb.launch

Or, to use a PS3 controller:
(On Host, two seperate terminals):

$ rosrun ps3joy ps3joy.py
$ roslaunch irobotcreate2 unified_launch_ps3.launch

3 Troubleshooting

Create 2 won’t charge: The Create 2’s battery cannot be charged in Safe or Full mode (the mode it is in when connceted to the Python driver). To leave these modes and enter passive mode, connect to the Create 2 and then disconnect with CTRL-C:

(on COM):

$ roslaunch irobotcreate2 target_create2.launch


(on Target or Host, whichever Create 2 is connected to):

$ rosrun irobotcreate2 target_create2.py

Wait for melody to play, then hit CTRL+C

Roomba by iRobot!
$ ^C
Ctrl+C detected, closing down gracefully...

The Create 2 should now be in passive mode, and the LED ring around the CLEAN button should pulsate when charger is connected.

Can’t connect to Create 2: Double check the path in target_create2.py

No video feed (ERROR: failed to PAUSE stream…):
Double check the path to your webcam /dev/videox and make sure /opt/ros/indigo/share/gscam/v4l.launch reflects that path (on your COM)

You may also need to install the plugins using smart:
(on COM):

# smart update
# smart install gst-plugins-good-video4linux2
# smart install gst-plugins-base-app

In part five of the tutorial, we’ll learn about going further with robotics applications.