.. _brash_setup_and_installation:


Setup & Installation
####################

BRASH is a NASA-funded Phase II STTR focused on developing tools for integrating ROS2 with Flight Software (FSW) tools such as cFS.

These are instructions to install the BRASH tools on Ubuntu 22.04 using ROS2 humble. You'll need vcstool to pull some packages:

.. code-block:: bash

   $ pip3 install vcstool
    
    
.. _install_cfs:

Install TRACLabs' cFS
=====================

We have forked NASA's cFS `here <https://github.com/traclabs/cFS>`_.  The following instructions will guide you through checking it out and testing it.  

.. note::

   Note that the basic BRASH demos and bridge plugins *will* run with NASA's cFS (https://github.com/nasa/cFS), version 7.0.0. There are some additional cFE applications we have developed for testing and logging that are included in our fork however. So for testing and tutorial processes it is recommended you use that fork.

1. Checkout and install the cFS source

   .. code-block:: bash

      $ export CFE_ROOT=$HOME/code/cFS  # or someplace else you want to keep the cFS
      $ echo "export CFE_ROOT=$CFE_ROOT" >> ~/.bashrc
      $ source ~/.bashrc
      $ mkdir -p $CFE_ROOT
      $ git clone git@github.com:traclabs/cFS.git $CFE_ROOT
      $ pushd $CFE_ROOT
      $ git submodule update --init --recursive
      $ make SIMULATION=native prep
      $ make
      $ make install
      $ popd

2. Test the install

   .. code-block:: bash
    
      $ cd build/exe/cpu1
      $ ./core-cpu1 2>&1 | tee out.txt

.. _install_brash:

Install the BRASH ROS2 Workspace
=================================

1. Checkout the BRASH workspace and its packages:

   .. code-block:: bash
    
      $ cd ~/code  # or wherever you want to install the BRASH ROS2 workspace
      $ git clone git@github.com:traclabs/brash.git
      $ cd brash
      $ mkdir src
      $ git checkout main
      $ vcs import src < https.repos     # User choice of https.repos or ssh.repos

   ..
      Note however that you may need to set up an App Password on your Bitbucket Account.
      To do this, login to bitbucket.org and click on the gear icon on the top right that
      opens up a **Settings** submenu.  Click on **Personal Bitbucket Settings** and then
      choose *App passwords* from the list on the left.  Generate a new app password and
      save it somewhere for later (you wont see the pop up again).
   ..
      When you run the vcs import command and it asks you for your password, use this new
      password **not** your regular Bitbucket account password.

   * Pulling code updates

     .. code-block:: bash
 
        $ vcs pull src  # this will do a git pull on all the checked our repos in src

2. Compile

   .. code-block:: bash
    
      $ source /opt/ros/humble/setup.bash
      $ colcon build --symlink-install


Optional but recommended
=========================

If you want to develop your own applications and create new messages, you will need **juicer**. If you want
to transfer files from flight to ground, you'll need **CFDP**:

.. _install_juicer:

1. **Install juicer**: Taken from the juicer `README <https://github.com/WindhoverLabs/juicer](https://github.com/WindhoverLabs/juicer>`_ docs:

   .. code-block:: bash

      $ cd ~/code
      $ sudo apt install libdwarf-dev libelf-dev libsqlite3-dev
      $ git clone https://github.com/WindhoverLabs/juicer.git --recursive
      $ cd juicer
      $ git checkout archive_unions
      $ make
      $ make run-tests

   Pay special attention to the branch (archive_unions) as this contains a patch made specifically for BRASH.
   **Note** that the run-tests currently fails on Ubuntu 22.04, but the executable will work.


2. **Install CFDP**:

   .. code-block:: bash
   
      $ pip3 install cfdp