Installing PX4 on the Raspberry Pi 3

Hello,

I am trying to install PX4 on a Raspberry Pi 3.
I am using the image provided by the EMLID project.
I followed the steps provided in the PX4 documentation and was able to make posix_rpi_native. The only problem I met was that there is no repository providing cmake 3.4.3 for the Raspberry Pi so I compiled it form source.

It seems that the make posix_rpi_native command went well:

[ 97%] Building CXX object src/modules/systemlib/CMakeFiles/modules__systemlib.dir/hysteresis/hysteresis.cpp.o
[ 97%] Building C object src/modules/systemlib/CMakeFiles/modules__systemlib.dir/param/param.c.o
[ 97%] Building C object src/modules/systemlib/CMakeFiles/modules__systemlib.dir/print_load_posix.c.o
[ 98%] Building C object src/modules/systemlib/CMakeFiles/modules__systemlib.dir/hx_stream.c.o
[ 98%] Linking CXX static library libmodules__systemlib.a
[ 98%] Built target modules__systemlib
Scanning dependencies of target px4
[100%] Building CXX object src/firmware/posix/CMakeFiles/px4.dir/__/__/platforms/posix/main.cpp.o
[100%] Linking CXX executable px4
[100%] Built target px4

The documentation then says to run PX4 by typing:

./build_posix_rpi_native/src/firmware/posix/px4 ./posix-configs/rpi/px4.config

But when I run this command on my RPi3, it seems that there is an Unkown error:

pi@localhost:~/src/Firmware $ ./build_posix_rpi_native/src/firmware/posix/px4 ./posix-configs/rpi/px4.config
data path: ./posix-configs/rpi/px4.config
ERROR [Unknown] Error expected 2 position arguments, got 1
./px4 [-d] data_directory startup_config [-h]
   -d            - Optional flag to run the app in daemon mode and does not listen for user input.
                   This is needed if px4 is intended to be run as a upstart job on linux
<data_directory> - directory where romfs and posix-configs are located
<startup_config> - config file for starting/stopping px4 modules
   -h            - help/usage information
Restoring terminal

I am little bit lost about this error message, could you please help me with this ?

Thanks,
Ilyass

I’m not into PX4 myself that much (yet), but what the error says is that you provide too few arguments for ./px4, as the very helpful error message says, you need to provide two arguments, but only gave one (namely <data_directory> - directory where romfs and posix-configs are located, in your case that was ./posix-configs/rpi/px4.config). The second argument (the one that is missing) is the <startup_config> - config file for starting/stopping px4 modules.

I.e. your call to ./px4 should look similar to this:

pi@localhost:~/src/Firmware $ ./build_posix_rpi_native/src/firmware/posix/px4 ./posix-configs/rpi/px4.config <startupConfig, e.g. ./posix-configs/rpi/px4-startup.config if such a thing exists>

But I don’t know where you can find the actual startup-config, sry – but I’m sure some of the guys here can help you.

That got changed recently, and we need to update the docs. I believe you can do this on the raspi:

./build_posix_rpi_native/src/firmware/posix/px4 . ./posix-configs/rpi/px4.config

Note the additional dot for the data directory. It should point to the Firmware dir.

I have same issue for staring PX4 on Raspberry+Navio and solved by this change.
Actually, there are some minor requirement of update on px4 document.

I just pushed a change on master to make the <data_directory> argument optional, so the previous commands work again.

Thank you very much !
Everything is working now.

My current problem is that I am trying to run PX4 with a sensor board different from the Navio. I would like to modify the px4.config file, but I cannot find a documentation or resources explaining how I can do that to use different sensors.
Any idea where that file is ?

Thanks
PS: Maybe I should create a new issue for this ?

Most of this is quite new and still shifting, so there is not much documentation on this (yet). All the commands starting with df_ in px4.config are sensor drivers (including the name of the sensor). So for your board, you have to know which sensors it provides (and the bus type), and then add the appropriate start command to the config, if the driver already exists. Currently these are supported: https://github.com/PX4/Firmware/tree/master/src/platforms/posix/drivers. Otherwise a new driver has to be added.

Once properly wired, the GPS worked just fine.
I will now take a look at the /platforms/posix/drivers/ and try to write the drivers for the sensors I have.
Do you perhaps have any documentation or resources I should take a look to make this easier ?

Thank you

Nice! You will have to add the actual driver into https://github.com/PX4/DriverFramework (submodule in src/lib/DriverFramework). /platforms/posix/drivers/ only contains the PX4-specific wrapper code to publish the sensor data via uORB. I suggest you copy an existing driver that seems closest to your device and start adjusting it.

Btw there are more drivers in https://github.com/PX4/Firmware/tree/master/src/drivers, but these are mostly for NuttX.

Hi Ilyass,

After installing Navio on RP3, how did you test the real-time performance?

I tried to use cyclictest; does not work. Have you tried the test?

Thank you,