(You’ll need a Zubax Babel and PixRacer for this)
Last week I wrote a post about the USART-UAVCAN.Tunnel bridge firmware that I was writing. The firmware is now in its next iteration: it successfully receives messages over serial and dispatches the corresponding uavcan.tunnel.Broadcast message. Conversely, when it receives a tunnel message, it sends the corresponding message over serial. This allows components that are not made for UAVCAN but interface over serial to be integrated into existing UAVCAN chains.
To install the code, clone my fork (https://github.com/d-v/framework) to the repository of your choice. Make sure you update the submodules. To add support for the idle interrupts you will need navigate to the ChibiOS directory and then to add ArduPilot as an upstream:
git remote add ardupilot https://github.com/ArduPilot/ChibiOS. Then, cherrypick this commit:
git cherry-pick fdc38235aa8b6fbb8f946908833e80479203e59c.
Navigate to the framework/bootloader directory. You’ll need two windows open for this part. Connect your PixRacer to your JTAG debugger, and run openocd in one of the windows in the framework/bootloader directory. Make sure you are using arm-none-eabi-gcc 6.3.1. Run the following command:
BOARD_DIR=../examples/basic_uavcan_functionality/boards/com.mrobotics.pixracer_1.0/ This will build your bootloader. Navigate to the build/com.mrobotics.pixracer_1.0 directory in the window. Execute
arm-none-eabi-gcc bootloader.elf. Once gdb opens, type
target extended-remote :3333. Finally, type
load. Now, open the uavcan_gui_tool, find the node in the list, and double click it. Find the button labeled “update firmware”, and find the bootloader.bin file. Double click it and wait for the process to finish.
Then, navigate to the framework/examples/basic_uavcan_functionality directory and execute the following command
BOARD_DIR=boards/com.mrobotics.pixracer_1.0/ make -j4. Open the uavcan_gui_tool and load the basic_uavcan_functionality-crc.bin file found in the build subdirectory and use the same “update firmware” button as before to load the file.
Next, clone the pyuavcan repository (the main branch doesn’t yet have the tunnel.Broadcast definition). Navigate to the
uavcan/dsdl directory and set the dsdl repository (https://github.com/UAVCAN/dsdl) as an upstream. Navigate to the root of the pyuavcan directory and execute
python setup.py build install and
python setup.py build install. This will install the uavcan.tunnel.Broadcast type.
Now you’re good to go! In the uavcan_basic_functionality directory there’s a serial_tunnel.py file that you can use to test. I use the following command to launch it
sudo python3 serial_tunnel.py --uavcan /dev/serial/by-id/usb-Zubax_Robotics_Zubax_Babel_20001D0019514D563935392000000000-if00 --serial /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AI051B6C-if00-port0. Adjust accordingly based on the FTDI and UAVCAN adapters you have. Once it is launched, you can type
serial <your_message> to have a serial message sent to the PixRacer, transformed into a
uavcan.tunnel.Broadcast message and sent back to the Babel. If you type
uavcan <your_message>, the opposite will happen. Enjoy!