Rover Zero - Tutorial 2 Computer Setup

These instructions will help you get started developing with your Rover Zero. If you plan on using a Raspberry Pi, then we have a set of quick instruction for flashing a preinstalled image that has everything you need to start developing. If you are not using a Raspberry Pi or want to setup your own environment you can skip down to 'Configure Ubuntu Machine'. This section will walk you through everything you need to setup your workspace from scratch.


Flash a RPI 3B+

Setup Your RPI 3B+

If you are using a Raspberry Pi 3 B+ for your project you have the option of flashing your microSD card with our custom image. The base OS is Lubuntu 16.04 and comes with ROS Kinetic, rr_openrover_stack, all the suggested udev rules, and a systemd unit that starts the rr_rover_zero_driver on boot to work with configurations matching our Starter Kit components. If you want to set everything up with an existing system or on a non-RPI system continue to the next section "Create Your Catkin Workspace".

1. Download the Rover Robotics RPI 3B+ OS image. Link

2. Download Balena Etcher. Link

3. Insert your microSD card (recommended 16GB+).

4. Unzip Etcher, and start the Etcher application.

5. Press "Select Images", and select the RPI image from the download location.

6. If your microSD card is not automatically select by the "Select target" phase, click "Change" and select you microSD card.

7. Press "Flash!" and wait a few minutes while the image is written the microSD card.

8. Unmount you microSD card and insert the card into your RPI.

9. Power your RPI and wait for a minute or so for the system to fully boot.

If you are using our Starter Kit or have your own Xbox 360 Wireless Controller plugged into your RPI, then you should be able to drive your Rover Zero on boot. All the ROS code for this behavior is located in the ~/catkin_ws directory.  

If you would like to suspend this behavior you can log into your RPI and deactivate it. The easiest way to log into the RPI is by connecting to the WiFi network which the RPI broadcasts automatically. The username and password are both 'ubuntu', we recommend updating the password upon your initial login.

10. Connect to the RPI WiFi network
ssid: roverrobotics**** (e.g. roverrobotics1234)
password: robotseverywhere

11. Create a remote connection to the RPI.
ssh ubuntu@10.42.0.1

12. Disable the systemd unit.
sudo systemctl disable rover-robotics.service

or Configure a non-RPi (Jetson Nano, Xavier, Intel NUC, ADLINK Vizi AI etc...)

Install ROS

First, ROS needs to be installed on the computer. These instructions come from the official ROS Kinetic and Melodic installation instructions (ROS Installation).  

1. Add ROS to source.list
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

2. Setup Keys
$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3. Update Apt
$ sudo apt update

4. Install ROS
$ sudo apt install ros-kinetic-desktop-full #Kinetic/Ubuntu 16.04
or
$ sudo apt install ros-melodic-desktop-full #Melodic/Ubuntu 18.04

5. Add setup.bash to .bashrc
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc && source ~/.bashrc #Kinetic/Ubuntu 16.04
or
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc && source ~/.bashrc #Melodic/Ubuntu 18.04

6. Install build packages
$ sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

7. Init rosdep
$ sudo rosdep init
$ rosdep update

Create Your Catkin Workspace

Every ROS project starts with creating your catkin workspace. The following will walk you through setting up your workspace with the Rover Robotics' Open Rover Stack. This gives you all the code you need to get started and then some.

1. Create your workspace.
$ mkdir -p ~/zero_ws/src && cd ~/zero_ws/src

2. Clone the rr_openrover_stack repository with Git.
$ git clone https://github.com/RoverRobotics/rr_openrover_stack.git

3. Build your ROS code with Catkin.
$ cd ..
$ rosdep install --from-paths src --ignore-src -r -y

$ catkin_make

4. Source your workspace, this will allow you to run your code using ROS.
$ source devel/setup.bash

5. If you want to source the workspace when opening a new terminal you can add this to your .bashrc file.
$ echo "source $HOME/zero_ws/devel/setup.bash" >> ~/.bashrc


There you go! You should be ready to start developing with your Rover Zero. rr_rover_zero_driver containers the driver node in rover_zero.py, and the rest of the stack contains utility packages for controller mapping, control message management, robot body descriptor models. The next section will walk through setting up UDEV rules for your rover, this will make development easier and help avoid some potential serial communication issues.

Setting Up UDEV Rules

When the the Rover Zero's USB is plugged in, we want the motor controller to enumerate its device file consistently and with the proper permissions. Thankfully, one UDEV rule can fix both of these issues. The commands below will create a UDEV rule that sets the proper permissions and creates a uniquely named device file at /dev/rover-zero when the Rover Zero is connected.

# Creates the UDEV rule at /etc/udev/rules.d/rover-zero.rules
$ sudo sh -c "echo 'KERNEL==\"ttyACM[0-9]\", ATTRS{idVendor}==\"03eb\", ATTRS{idProduct}==\"2404\", MODE:=\"0666\", SYMLINK+=\"rover-zero\"
' > /etc/udev/rules.d/rover-zero.rules"

# This will cause your computer to start using the new rule
$ sudo udevadm control --reload-rules && sudo udevadm trigger

Now use the command ls -l /dev/rover-zero , if you see the rover-zero file listed then you know that your UDEV rule is working properly.

Then Run Example Code

Running Example Code

Now that everything is installed lets try get the rover wheels spinning. The first thing you will want to do is to put the Rover Zero on a box so that the wheels are not touching the ground. Second, plug in your Rover Zero into your computer you will be running ROS from. Once you have done these two things you are ready to move onto using ROS to drive the Rover.

Open a new terminal on your work machine, navigate to your Rover Zero workspace, and source your workspace if you have not done so in your .bashrc file, and launch the Rover Zero node.

$ cd ~/zero_ws
$ source /devel/setup.bash
$ roslaunch rr_rover_zero_driver example.launch

If the node does not launch properly make sure that you followed the instructions in the "Setting Up UDEV Rules" section. Now open a second terminal and navigate to your workspace again. This time we are going to be sending twist commands to drive the robot.

# Forward at 0.3 meters per second
$ rostopic pub -r 1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.3, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'
# Stop the robot
$ rostopic pub -r 1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

The first command publishes a ROS Twist message to the topic /cmd_vel with a forward speed of 0.3 meters per second. The Rover Zero driver node listens for velocity commands on the /cmd_vel topic, and then translates them into motor commands for the motor controllers. You should see the wheels start to spin forward. The second command tells the motors to move at speed zero, stopping the Rover. If you are able to start and stop the Rover with these commands you know that your Rover is entirely set up and ready to start developing on. We wish you the best of luck, and can not wait to see what you accomplish with your Rover Zero!