By the end of this “bootcamp” you will have a knowledge of Linux, ROS, our robot’s code, and be able to drive our robot around in our simulator! If you on the CWRUbotix team feel free to ask questions in the nasa-rmc-software Slack Channel. If you have stumbled across this tutorial and have questions feel free to email me at [email protected].
Almost all robots use the operating system called Linux (imagine if your Windows robot decided to update without your permission). However, most of you probably have a Windows computer, luckily we can install a Virtual Machine to use Linux. These instructions should also work if you have a mac but it hasn’t been tested. If you already have a linux Virtual machine or better have a real Linux machine feel free to skip this step.
-
Click on the Windows or Mac icon under VMware Products from the CWRU software center. Log in in the top right corner to view the products.
- Download VMWare Workstation Pro.
- We want to run Ubuntu 20.04 Focal Fossa in our VM. Download it here.
- You can open a terminal as an application or by using the shortcut
Control+Alt+T
. - Here are a couple useful linux commands, try out the first 12 in a terminal. Don’t delete anything important!
-
VIM is a text editor you can use when editing files in the command
line. The very general use is: type
vim <file>
to open a file. Pressa
to enter editing mode. Make your edits. PressEsc
to exit editing mode. Type:x
and press enter to save and quit. Or type:q
to exit without saving. Try it out. Don’t worry, most code is written with a normal editor not Vim. - Tips: The VM is just another computer so you can install chrome and your favorite editor and whatever else you like.
ROS is the robot operating system. It’s not an operating system, at its core it's a framework for different parts of the robot to communicate with each other.
-
Read this (very) basic intro to ROS.
-
Here are the instructions to install ROS Noetic onto Ubuntu 20.04. You may either follow the ROS guide or use the one provided below. To copy/paste text to a terminal, you can’t use Ctrl-C as is reserved for stopping running programs. Use Shift-Ctrl-C or V.
- Skip this step. Should already be setup.
-
The sources.list tells Linux where to download new software packages from.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
-
Keys are a security measure to make sure the software packages haven’t been tampered with.
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
-
Do the Desktop install, not the Desktop-Full.
sudo apt update
sudo apt install ros-noetic-desktop
-
This command will add a command to your .bashrc that will setup the ros environment. The
source
command just runs a script. For those at home who don't know or don't remember .bashrc file is a file that runs everytime Linux starts up.
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
-
These code lines will install some basic dependencies for ROS. We will install the specific dependencies later.
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo rosdep init
rosdep update
Test your ros build by running the commandroscore
.
- Go through the first 8 tutorials here. This will take a while but by the end you will have a good knowledge of ros. I think you can do tutorials 3 and 4 last as they aren’t as fun.
- Additional tutorial about how to write code for nodes. (Not needed for next steps but very good knowledge to have)
Git is a version control system which allows you to track changes in your code and help multiple people work together on one project. Our code is stored on GitHub, a website for hosting git repositories.
Follow this git tutorial. Note git should already be installed on your Linux VM. Create a github account if you don’t have one. Tell us your username so we can add you to our organization.
At the end of this step you will be able to build and run our robot software in the simulation.
-
Create a catkin_ws in your home folder. The home folder is the ~ folder. Then create a
src
folder in the catkin_ws.
mkdir -p ~/catkin_ws/src
-
Clone the NASA-RMC-2020 repository into
~/catkin_ws/src/
.
cd ~/catkin_ws/src
git clone https://github.com/cwruRobotics/NASA-RMC-2020.git
-
Navigate to the
tools
folder inside of NASA-RMC-2020.
cd NASA-RMC-2020/tools
Runinstall_ros_deps.sh
to install our ros dependencies.
Runinstall_helper_programs.sh
to install helper programs (open these files if you’re curious what you’re installing).
source install_ros_deps.sh
source install_helper_programs.sh
sudo apt upgrade
-
Build the code using
catkin build
. Note: need to be in the catkin_ws folder.catkin build
is a nicer version ofcatkin_make
.
cd ~/catkin_ws
catkin build
-
Now that we have a workspace, it helps to automatically setup the workspace when we login. Add the commands
source ~/catkin_ws/devel/setup.bash
to your~/.bashrc
file and then source the file.
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
-
Our code has an option to store the data generated by our sensor for later review. To do this we must create the folder
USB_BAGGING/log
inside the home directory. Then we need to change default logging location of ROS to be within this folder.
mkdir -p ~/USB_BAGGING/log
echo "export ROS_LOG_DIR=~/USB_BAGGING/log" >> ~/.bashrc
source ~/.bashrc
-
For those new to linux anyhing in the .bashrc file will run automatically everytime you start up linux. It is a very basic way to automate some repetive things. To edit the .bashrc use
vim ~/.bashrc
. Note that because this folder starts with a.
it is hidden tols
unless you dols -a
.
Gazebo needs to know the path to plugins built for it. Add the line -
Time to run the simulator!
Open a terminal and run
roscore
. Open another terminal and runroslaunch glenn_description glenn.launch
. (Set bags to true if you want to record data from the simulation). You should hopefully see our robot in the simulation. Try driving it around or playing with some of the windows that opened.
roscore
roslaunch glenn_description glenn.launch
export GAZEBO_PLUGIN_PATH=~/catkin_ws/devel/lib/
to your .bashrc
. It also needs to know where our arena models are. Add the line export GAZEBO_MODEL_PATH=~/catkin_ws/src/NASA-RMC-2020/glenn_simulation/glenn_description/models/
to the .bashrc
as well.echo "export GAZEBO_PLUGIN_PATH=~/catkin_ws/devel/lib/" >> ~/.bashrc
echo "export GAZEBO_MODEL_PATH=~/catkin_ws/src/NASA-RMC-2020/glenn_simulation/glenn_description/models/" >> ~/.bashrc
source ~/.bashrc
You are free to use whatever IDE you want as long as it can devolop for both C++ and Python. If you want to use VsCode on your VM we have file to install and setup.
source ~/catkin_ws/src/NASA-RMC-2020/tools/install_vscode.sh
To open VSCode either use code -n ~/catkin_ws/src/NASA-RMC-2020/
or as an application.
code -n ~/catkin_ws/src/NASA-RMC-2020/
Do this tutorial on programming a ros node if you haven’t yet.
Here’s a document that explains the nodes currently on our robot. Run the robot simulator. Use rosnode list
and rosnode info <node_name>
to see what topics each node is publishing. Also use rostopic list
and rostopic info <topic_name>
to learn about the topics we use.