This repo was created as a proof of concept and now is outdated. The work is been continued on https://github.com/eProsima/Firmware.git
This is a proof of concept to communicate a Pixracer Autopilot and a Raspberry Pi through serial ports using CDR serialization, aims to get information from a drone and carry to the DDS world through Fast RTPS.
On the Pixracer side, it will be used an application running an uORB node. This node will be subscribed to the IMU sensor data via the sensor_combined topic. The applications read the message in a loop, serializes the struct and writes it trough an UART port selected by the user.
To compile this appication along the PX4 firmware it is needed to add the eprosima_cdr folder on the examples folder (located on src/examples). Then, the application must be registered in NuttShell adding a new line in nuttx_px4fmu-v4_default.cmake as described in the PX4 documentation:
# eProsima app examples/eprosima_cdr
After uploading the firmware, the application can be launched on NuttShell typing its name and passing an available serial port as argument. Using /dev/ttyACM0 will use the USB port as output. Using /dev/ttyS1 or /dev/ttyS2 will write the output trough TELEM1 or TELEM2 ports respectively.
> eprosima_cdr /dev/ttyACM0 #or /dev/ttySn
NOTE: If the UART port selected is busy, it's possible that Mavlink applications were using them. If it is the case, you can stop Mavlink from NuttShell typing:
> mavlink stop-all
Raspberry PI application
In this project the Raspberry Pi will have two functions: get the sensor data from the Pixracer and publish it to a Fast RTPS environment. In the raspberry folder there is an example Fast RTPS application generated with fastrtpsgen. In this application you can launch a publisher or subcriber which are using an idl file with the same attributes than the msg structure generated by uORB. The publisher read data from the UART, deserializes it, and make a Fast RTPS message mapping the attributes from the uORB message. The subscriber simply receives the Fast RTPS messages and print them to the terminal. The subscriber can be launched on the Raspberry Pi or in any another device connected in the same network.
Before runnning the application, it is needed to have installed Fast RTPS. Visit it installation manual for more information. For compiling the application run this commands in the Raspberry:
$ git clone https://github.com/eProsima/PX4-FastRTPS-PoC.git $ cd PX4-FastRTPS-PoC/raspberry $ mkdir build && cd build $ cmake .. $ make
Now, to launch the publisher run:
$ ./raspberry_px4 publisher /dev/ttyACM0 #or the selected UART
And, for launching the subscriber run:
$ ./raspberry_px4 subscriber
NOTE: Normally, it's necessary set up the UART port in the Raspberry Pi. To enable the serial port available on Raspberry Pi connector:
- Make sure the userid (default is pi) is a member of the dialout group:
$ groups pi $ sudo usermod -a -G dialout pi
- You need to stop the already running on the GPIO serial console:
$ sudo raspi-config
Go to Interfacing options > Serial, NO to Would you like a login shell to be accessible over serial?, valid and reboot.
- Check UART in kernel:
$ sudo vi /boot/config.txt
And enable UART setting enable_uart=1.
The entire application will follow this flow chart:
If all steps has been followed, you should see this output on the subscriber side of Fast RTPS.
A video of this final process as demostration is available on https://youtu.be/NF65EPD-6aY