Pre-requisite Software 
======================

The ROS driver for the robots is initially supported for the ``ROS Melodic``. All of ROS related software should be install either on remote PC/Rasberry Pi/Nvidia board on robot. The robot ships either with Rasberry Pi or Nvidia board as an upgradation kit. The steps for shown below are for remote PC both boards usually come with pre-installed ROS distribution. 

**Note:** All the ROS related software should be installed/run on remote PC/Rasberry Pi/Nvidia board, nothing needed to be installed on robots control board.


[Ubuntu 20.04 - ROS NOETIC]
---------------------------

.. _ROS Noetic: http://wiki.ros.org/noetic/Installation
.. _Ubuntu 20.04: https://releases.ubuntu.com/20.04/
.. _Ubuntu 20.04 Installation: https://ubuntu.com/server/docs/installation

.. image:: media/common/ros_noetic.png
    :width: 100%
    :align: center

The ROS driver for the robots is initially supported for the
``ROS Noetic``. All of ROS related software should be installed in a **Remote-PC**. The
steps for shown below are for **Remote-PC** or **A1-PC**.


.. warning:: 

   Care should be taken when installing ROS so that it matches with your CPU's architecture (i.e. armhf, amd64, arm6, etc.)
   
PC Setup
--------

`ROS Noetic`_ installation requires Ubutnu 20.04. 

1. Download `Ubuntu 20.04`_ 
2. Follow the `Ubuntu 20.04 Installation`_ guide

ROS-noetic Installation
~~~~~~~~~~~~~~~~~~~~~~~~

The ros driver provided can be run either on a remote PC or on board
robot computer. Usually, the on-board computer already has pre-installed ROS
distribution, so the instructions below will be applicable to a remote computer.
You may run the following commands to install ROS noetic or you can simply follow
the `instructions <http://wiki.ros.org/noetic/Installation/Ubuntu>`_ from the roswiki.

1. Enter the Ubuntu terminal and typie in the following command:

.. code:: bash

   cd 

2. The next step is setting up the source list:

.. code:: bash

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

3. After which you will set up the keys:

.. code:: bash

   sudo apt install curl 
   curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

4. Then, you will install ROS-noetic:

.. code:: bash

   sudo apt update
   sudo apt install ros-noetic-desktop-full

5. Finally, you will add ROS environment to your bash file, what this
   means is that each time you load up your terminal, it will
   automatically find the built-in ROS packages.

.. code:: bash

   echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
   source ~/.bashrc

6. Install python dependencies and initialize repo:

.. code:: bash

   sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
   sudo rosdep init
   rosdep update

Once the ROS packages are set-up the next step would be to set up a
workspace in which you can add pre-built packages to control your robot.

Catkin Workspace
~~~~~~~~~~~~~~~~

1. The first step is to ensure that you have correctly setup you ROS
   noetic. It can be checked by:

.. code:: bash

   cd ..
   source /opt/ros/noetic/setup.bash

2. Next, install catkin_tools:

.. code:: bash

   sudo apt install python3-catkin-tools

3. The next step is to create, your workspace. This is typically created
   in the home directory following the standard ROS convention, once
   built, you should see a ``build`` and ``devel`` folder next to your
   ``src`` folder:

.. code:: bash

   mkdir -p ~/catkin_ws/src
   cd ~/catkin_ws/
   catkin build

4. To enable the workspace, you must type in:

.. code:: bash

   source devel/setup.bash

5. To avoid typing this everytime you start a terminal, you’ll add this
   into the ``last line`` of the bashrc file:

.. code:: bash

   gedit ~/.bashrc

-  Add the following line at the end of the bashrc file:

.. code:: bash

   source /home/<your_computer_username>/catkin_ws/devel/setup.bash

-  Everytime you do a ``catkin build``, it is necessary to either restart all
   your terminals, or source them.

-  To verify that everything is working correctly, type the following
   into the terminal:

.. code:: bash

   echo $ROS_PACKAGE_PATH

[Ubuntu 18.04 - ROS MELODIC]
----------------------------

.. image:: media/common/melodic.jpg
    :width: 100%
    :align: center

The ROS driver for the robots is initially supported for the
``ROS Melodic``. All of ROS related software should be installed in a
remote PC/Rasberry Pi/Nvidia board that is onboard the robot. The robot
ships either with Rasberry Pi or Nvidia board as an upgradation kit. The
steps for shown below are for remote PC both boards usually come with
pre-installed ROS distribution.

**Note:** All the ROS related software should be installed/run on remote
PC/Rasberry Pi/Nvidia board, nothing needs to be installed on robots
control board.

PC Setup
--------

`ROS
Melodic <https://www.ros.org/reps/rep-0003.html#melodic-morenia-may-2018-may-2024>`__
installation requires Ubutnu 18.04 Bionic, Artful and supports macOS,
Windows upto varying extent. But for this installation Ubuntu 18.04.x
Bionic is recommended.

1. Ubuntu 18.04 can be downloaded from
   `here <https://releases.ubuntu.com/18.04/>`__.
2. The installation instruction for Ubuntu can be found
   `here <https://ubuntu.com/tutorials/install-ubuntu-desktop#1-overview>`__

ROS-Melodic Installation
~~~~~~~~~~~~~~~~~~~~~~~~

The ros driver provided can be run either on a remote PC or on board
robot computer. Therefore, ROS only needs to be installed on any one of
them. Usually, the on board computer have already pre-installed ROS
distribution, so below one will only be applicable to a remote computer.
Run following commands to install ROS Melodic or you can simply follow
the `instructions <http://wiki.ros.org/melodic/Installation/Ubuntu>`__.

1. Enter the Ubuntu terminal and typie in the following command:

.. code:: bash

   cd ..

2. The next step is setting up the source list:

.. code:: bash

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

3. After which you will set up the keys:

.. code:: bash

   sudo apt install curl
   curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

4. Then, you will install ROS-melodic:

.. code:: bash

   sudo apt update
   sudo apt install ros-melodic-desktop-full

5. Finally, you will add ROS environment to your bash file, what this
   means is that each time you load up your terminal, it will
   automatically find the built-in ROS packages.

.. code:: bash

   echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
   source ~/.bashrc

Once the ROS packages are set-up the next step would be to set up a
workspace in which you can add pre-built packages to control your robot.

Catkin Workspace
~~~~~~~~~~~~~~~~

1. The first step is to ensure that you have correctly setup you ROS
   melodic. It can be checked by:

.. code:: bash

   cd ..
   source /opt/ros/melodic/setup.bash

2. Next, install catkin_tools:

.. code:: bash

   sudo apt-get install python3-catkin-tools

3. The next step is to create, your workspace. This is typically created
   in the home directory following the standard ROS convention, once
   built, you should see a ``build`` and ``devel`` folder next to your
   ``src`` folder:

.. code:: bash

   mkdir -p ~/catkin_ws/src
   cd ~/catkin_ws/
   catkin build

4. To enable the workspace, you must type in:

.. code:: bash

   source devel/setup.bash

5. To avoid typing this everytime you start a terminal, you’ll add this
   into the ``last line`` of the bashrc file:

.. code:: bash

   gedit ~/.bashrc

-  Add the following line at the end of the bashrc file:

.. code:: bash

   source devel/setup.bash

-  Everytime you do a Catkin build it is necessary to either restart all
   your terminals, or source them.

-  To verify that everything is working correctly, type the following
   into the terminal:

.. code:: bash

   echo $ROS_PACKAGE_PATH
