The arduino firmware on the one hand implements the JETTY protocol for communicating with ROS and on the other hand takes care of all low-level hardware communication including:
The work flow of the Arduino firmware can be found on the following figure:
Basically, after the initialization, the firmware performs three principal routines:
The first routine is the hardware interruption routine which has the highest priority. This routine is triggered by the micro-processor upon the value changing event on one of 4 interruption pins. It allows to read the motor encoder values, which are lately used by ROS to estimate the robot position (Dead Reckoning).
Detail on the odometry data reading is presented in the next sub section.
This routine handles the high level data reception from ROS via the JETTY protocol, it monitors the input serial link, and perform the following task:
The implementation of frame reception and processing is pretty forward as shown in the schema above. The Arduino firmware handles two kind of frame:
Detail on the motor controlling is presented in sub section.
This routine collects all the sensor data and publishing this data to ROS via the JETTY protocol. The sensor data consists of:
All the sensor data is encoded in a 47 bytes COBS data frame before sending to ROS via the serial link. The data is published with the frequency of around 100Hz.
Information on workspace setup can be found here
The implementation of JETTY on arduino can be found in
~/workspace/arduino/JETTY, the sketch depends on some external libraries that can be installed using
Install all the dependencies libraries:
arduino-cli lib install "Adafruit Motor Shield V2 Library" arduino-cli lib install "Adafruit ADS1X15"
Note the MPU9250 library header is included directly in the repository, so no need to install it
Build the JETTY sketch:
cd ~/workspace/arduino/ arduino-cli compile --fqbn arduino:avr:mega JETTY
Then upload the sketch to the Arduino:
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:mega JETTY
JETTY will run on the Arduino and start transferring sensor data. Note that The board will be reset automatically when the ROS endpoint connects to the serial link.