Pixhawk service
Introduction
The pixhawk service program is a simple application that allows communication through Mavlink to a pixhawk flying controller. It uses blc_channels, a lib to use shared memory made by the friendly collegue, Arnaud Blanchard (See blaar lib).
Project Structure
The project works in real time with multiple threads :
- Main thread
- Serial port thread in reading and writing
- Promethe threads (joystick, neural networks, ...)
IHM thread
Language
C++
Dependencies
This project uses :
-
https://promethe.u-cergy.fr/blaar/blaarhttps://git.cyu.fr/blaar/blaar -> important - xboxdrv
- librapidxml-dev 1.13-1
- libncurses5-dev
- libsdl2-ttf-dev
You need git, a C/C++ compiler, cmake, make
git clone https://git.cyu.fr/blaar/blc.git
cd blc
mkdir blc_build && cd blc_build && cmake ..
make
sudo make install
Organization
The project is organized in different specific folders :
+-- Com_server
| +-- c_library_v2 : Mavlink v2.0 library
| +-- fly_monitor : main program
| +-- include : all header files of the application
| +-- plot : all data that can be ploted
| +-- snippet : unit test code
| +-- src : all source files of the project
| +-- include : old header files
| +-- lib_old : old Mavlink library no longer used, removal should be considered
| +-- prom_blc_channel : blc_channel functions to be compiled to generate libraries
| +-- prom_blc_core : blc_core functions to be compiled to generate libraries
+-- Promethe_scripts : scripts like joystick to run in Promethe
+-- (lib/Linux/blc) : blc libraries generated by prom_blc_channel and prom_blc_core)
How to ...
... see blc_channels ?
cd $HOME/blaar
./run.sh gnuplot/o_gnuplot /pixhawk.control.arm
./run.sh gnuplot/o_gnuplot /pixhawk.control.motors -m-1000 -M1000
... resolve blc_channels problem ?
You may have mishandled the blc_channels (changed a blc array's size, changed the name, etc). You can try to unlink channels:
blc_channels -U
If it doesn't work, you may want to wipe what's already present in "/dev/shm" and "/tmp/blc_channels.txt" (don't forget the hidden files as well). You can also run the code below (the first line generates warnings which we just get rid of by sending them to /dev/null):
rm -rf /dev/shm/.* 2> /dev/null
rm /tmp/blc_channels.txt
If you don't want to wipe, check if the informations in those places are correct and change/remove accordingly.
... resolve serial port problem ?
http://tvaira.free.fr/bts-sn/activites/preparation-ccf-e52/activite-port-serie-usb.html
... compile the project ?
Don't lose your time with greedy IDE :P. Use Cmake in the build folder.
- mkdir build
- cd build
- cmake ..
make
... execute tests ?
No unitary test support was made but the system was prepared. It's only a simple option on cmake.
... use Promethe scripts ?
To launch promethe with a script to control the drone via joystick and check feedback signals.
cd Promethe_scripts/drone_joyRemote
promethe drone_joyRemote.script drone_joyRemote.res drone_joyRemote.config
Launch in an another window testDrone (source code in test):
testDrone /dev/ttyUSB0
Other
Some links are interesting to consult in order to contribute to this program.
- https://discuss.px4.io/ -> forum for anything related to MAVSDK, QGroundControl, Pixhawk, MAVLink and PX4 firmware
- https://stackoverflow.com/questions/54620641/why-nanosleep-adds-a-constant-delay-and-how-can-i-avoid-that -> nanosleep / usleep potential offset issue
- https://www.google.com/search?client=ubuntu&channel=fs&q=mavlink+mode+guided&ie=utf-8&oe=utf-8
- https://docs.px4.io/main/en/ros/offboard_control.html
- https://docs.px4.io/v1.11/en/flight_modes/position_mc.html
- https://gitter.im/dronekit/dronekit-python/archives/2017/06/04
- ardupilot.org/copter/docs/common-mavlink-mission-command-messages-mav_cmd.html -> tone
- https://dev.px4.io/en/qgc/video_streaming.html
- https://dev.px4.io/en/advanced/parameter_reference.html -> pixhawk flight stack
- https://msgpack.org/ -> format
- https://capnproto.org/ -> format
- https://docs.qgroundcontrol.com/en/SetupView/Joystick.html JOYSTICK
- https://ardupilot.org/dev/docs/copter-commands-in-guided-mode.html#copter-commands-in-guided-mode-set-position-target-local-ned
Wiki
Author
Sylvain Colomer into the Laboratory Etis, University of Cergy-Pontoise Don't hesitate to contact me trough gitLab !