Skip to content

Latest commit

 

History

History
170 lines (150 loc) · 9.78 KB

ros_setup.md

File metadata and controls

170 lines (150 loc) · 9.78 KB

CWRUbotix Software Set Up and Tutorial

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].

Table of Contents

Part 1 Installing Linux

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.

  1. 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.

  2. Download VMWare Workstation Pro.
  3. We want to run Ubuntu 20.04 Focal Fossa in our VM. Download it here.
  4. You can open a terminal as an application or by using the shortcut Control+Alt+T.
  5. Here are a couple useful linux commands, try out the first 12 in a terminal. Don’t delete anything important!
  6. 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. Press a to enter editing mode. Make your edits. Press Esc 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.
  7. Tips: The VM is just another computer so you can install chrome and your favorite editor and whatever else you like.

Part 2 Installing ROS

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.

  1. Read this (very) basic intro to ROS.

  2. 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.
    1. Skip this step. Should already be setup.
    2. 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'
    3. 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 -
    4. Do the Desktop install, not the Desktop-Full.
      sudo apt update
      sudo apt install ros-noetic-desktop
    5. 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
    6. 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 command roscore.
  3. 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.
  4. Additional tutorial about how to write code for nodes. (Not needed for next steps but very good knowledge to have)

Part 3 Git

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.

Part 4 Software and Simulator

At the end of this step you will be able to build and run our robot software in the simulation.

  1. 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

  2. Clone the NASA-RMC-2020 repository into ~/catkin_ws/src/.
    cd ~/catkin_ws/src
    git clone https://github.com/cwruRobotics/NASA-RMC-2020.git
  3. Navigate to the tools folder inside of NASA-RMC-2020.
    cd NASA-RMC-2020/tools
    Run install_ros_deps.sh to install our ros dependencies.
    Run install_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
  4. Build the code using catkin build. Note: need to be in the catkin_ws folder. catkin build is a nicer version of catkin_make.
    cd ~/catkin_ws
    catkin build
  5. 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
  6. 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
  7. 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 to ls unless you do ls -a.
  8. Gazebo needs to know the path to plugins built for it. Add the line 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
  9. Time to run the simulator! Open a terminal and run roscore. Open another terminal and run roslaunch 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

Part 5 IDE

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/

Part 6 Next Steps

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.