UAV toolbox support package for PX4 : can I use CAN protocol GPS with custom flight algorithm?

Hello,
I am trying to use CAN protocol GPS module(here+ or here3 gps module) with uploading my custom flight control algorithm.
I select custom flight controller algorithm, and therefore mc_att_control and mc_pos_control module is disabled while all other modules(navigator or commander, etc) are still alive.
I uploaded my custom flight algorithm and connected CAN GPS module but seems Pixhawk4 board cannot recognize the CAN GPS.
I changed parameter UAVCAN_ENABLE to 1 to enable uavcan protocol, but this is not worked.
When I upload the original PX4 firmware, CAN GPS automatically is detected and can be used.
So I suspect uploading custom algorithm somehow affects the communication between CAN GPS and Pixhawk4 board.
Is there any method to use CAN GPS with uploading my custom flight algorithm?
Or, is it possible that uploading my custom flight algorithm affects the connection between peripheral hardware and Pixhawk board?
Thank you for Reading
Jongwon Lee

5 Comments

Hi,
If you can provide few more details it will be helpful. Which MATLAB version are you using? Are you using the rCS or rc.tx as the startup script?. First verify, if uavcan module is running with the custom flight control algorithm. You can connect to NSH console or MAVLink console and verify the status of uavcan using 'uavcan status' command. If uavcan module is not running try starting it manually using 'uavcan start' command. Just to make sure, I hope you have rebooted the board after setting parameter UAVCAN_ENABLE to 1.
Sorry for my vague description.
I am using 2021b version and I am using default start script(rCS), not custom startup script.
Also, I selected px4 fmu default when I built the firmware.
I typed uavcan start command, and MAVLink console says it already started.
After I upload my control algorithm and connect to the power, gps blinks for a while but doesn't blink after.
However, PX4 firmware blinks the LED in gps continuously.
So I suspect the board and GPS cannot communicate well.
If you need any other information, please notice me because I am not sure which information is helpful to solve this problem.
Thank you
You mentioned that when you used the original PX4 as it is (without Simulink in picture), UAVCAN GPS was working as expected. Did you directly downloaded the original PX4 executable or cloned a separate PX4 firmware sources and build it? Just to get some more insights, I would recommend trying out some simple model in Simulink instead of the custom controller and see if that is helping. If uavcan module is running, you can also see if the vehicle_gps_position uORB message is getting publihsed with correct data.
I directly downloaded the original PX4 software from QGroundControl.
As you said, I uploaded simple meaningless Simulink model which is shown below(Basic setting : rCS script and px4_fmuv5_default was not changed). It is just reading uorb message and no control algorithm is built.
After I uploaded it, I stopped and re-started the uavcan module and tried to read vehicle_gps_position uORB message as you mentioned. The result is shown below.
Warning message "GNSS ORB fd 7" was shown, and it said vehicle_gps_position uorb message is not published. It seems a little strange because only mc_pos_control and mc_att_control modules are commented in rc.mc_apps. For specific information, rc.mc_apps code configuration is shown below.
For comparison, I do the same when I uploaded original PX4 Firmware via QGroundControl. Result is shown below.
When I started uavcan module, there was no warning and can read vehicle_gps_position though I was in indoor so gps data was not obtained.
Also, there is one more evidence that px4 simulink app is not affecting to this uavcan module. I stopped px4 simulink app, re-start the uavcan module and read gps data but result was same as the figure at top one.
I hope this can help you to answer your question. In my opinion, "GNSS ORB fd 7" warning or not published vehicle_gps_position is where I should find more.
Thank you,
Jongwon Lee
Hi Jongwon Lee,
Thanks for sharing the details. Yeah I agree with your observations, The warning with GNSS is the right place to investigate further. Why is the different behaviour with original PX4 and custom controller in PX4 is surprising to me also. One small catch I can think of is the PX4 Firmware versions. PX4 Support package is based on v1.10.2 and I am not sure what firmware version you may be downloading from QGroundControl. My guess is that this may be a latest version and that may be the reason for difference in behaviour. You can verify the firmware version with 'ver git' command in NSH console. I would recommend uploading PX4 v1.10.2 original firmware from QGC to have an apple to apple comparison.
Thanks,
Arun

Sign in to comment.

 Accepted Answer

I agree with your observations, The warning with GNSS is the right place to investigate further. Why is the different behaviour with original PX4 and custom controller in PX4 is surprising. One small catch I can think of is the PX4 Firmware versions. PX4 Support package is based on v1.10.2 and I am not sure what firmware version you may be downloading from QGroundControl. My guess is that this may be a latest version and that may be the reason for difference in behaviour. You can verify the firmware version with 'ver git' command in NSH console.

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!