Skip to content

Firmware Architecture

loganfillo edited this page Nov 28, 2021 · 8 revisions

Introduction

This serves as a document outlining the design of the firmware systems, which includes the types of connections between sensors/actuators/boards, and what sensors/actuators are found on which boards. It also briefly talks about how this design will be integrated in with the software.

Terminology

  • TX2 - A Nvidia created supercomputer which runs Ubuntu linux
  • Fathom-X - An underwater ethernet tether
  • Teensy - A USB-based microcontroller which can run Arduino scripts
  • Teensyduino - A software add-on used to run Arduino scripts on a teensy
  • micro-ros - A framework containing ROS nodes and libraries to interface between a microcontroller and CPU in ROS
  • I2C - Protocol used in sensor-to-microcontroller communication
  • Docker Compose - A container platform used to run and orchestrate instances of operating systems

Resources

  • To understand more on micro-ros, which is the library we will use to integrate the TX2 with the Teensy, check out their website.
  • The official overview of Docker Compose
  • For more info on Teensyduino, see here.
  • An Arduino library for using micro-ros (i.e we can use this in an Arduino sketch to send/receive messages over ROS topics)
  • A tutorial on connecting a teensy to a CPU using micro-ros (not what I directly used however is still a good resource)
  • Github of ROS2 driver for USB cameras
  • Github of ROS2 driver for Phidgets IMU

Detailed Description

The firmware system can be thought of as containing two parts, one part containing the TX2, and the other containing the Teensy. First let's briefly talk about how these two parts will communicate. The TX2 will run our software using Docker Compose, where one container will contain our ROS system (i.e all the nodes that process data from sensors and produce actions to send to actuators), and the other is a part of the micro-ros library which serves as an agent to communicate with the Teensy. The Docker Compose file containing these two services can be viewed here. Essentially, the TX2 runs both containers, and the micro-ros containers makes it so that we can receive ROS messages from the Teensy (which is the simplest way to interface with the data coming from the Teensy). As long as the TX2 is running the micro-ros agent container, the software running on the Teensy can use the micro-ros Arduino library (as long as the Teensy is configured through Teensyduino) to communicate with the ROS nodes running on the ROS system container by sending messages over ROS topics.

TX2 Firmware

For the TX2 firmware, we make use of existing ROS driver nodes to interfaces with our USB pluggable sensors (e.g IMU, Cameras). This essentially means that as long as these sensors are plugged into the TX2 through a USB port, the drivers will be able to parse their data and send this over ROS topics. The nodes mentioned will be running in the ROS system containers. For the Fathom-X we do not need a ROS driver, as it is used to connect the TX2 to our personal laptops by simply putting these devices on the same network.

Teensy Firmware

For the Teensy firmware, we make use of the micro-ros library to communicate data from the non-USB pluggable sensors/actuators (e.g Depth Sensor, Thruters) to the TX2, as mentioned above. The sensors/actuators will communicate with the Teensy over I2C (most likely using libraries in Arduino). In the Arduino loop running on the Teensy, we will perform the following algorithm

  1. Read the latest state of the ROS messages sent from the TX2 using micro-ros (e.g /controls/thruster_input which would contain the list of PWM signals to send to the thrusters)
  2. Write the latest state of the ROS messages to the appropriate actuator (e.g write the PWM signals for the thrusters)
  3. Read the latest state of the sensors connected to the Teensy (i.e take a reading from the depth sensor)
  4. Publish the latest state of the sensor data as a ROS message using micro-ros (i.e send the reading of the depth sensor we just took over /controls/depth_state)
  5. Repeat

Below is a diagram showcasing this design Firmware System

Clone this wiki locally