Ros2 to control PID in Quad

I am starting a new research to control the QUAD (PX4) using neural network (NN) instead of PID. My target is to start simulating the drone behavior based on the NN output instead of the PID output.

I Hope to get as much info as I can from you to put me on the right path regarding :
1- can I use ROS2 to control and replace the PX4 PID output with the NN output
2- I am planing to use gazebo, PX4, and ROS2 , am I in the right path
3- is ROS2 is the right choice to communicate with the PX4 to control the ESC output
4- does ROS and Gazebo can be satisfied or I should go with ROS2
5- which is better to go with ROS2 humble or foxy for ubuntu 18.04, or i should switch to ubuntu 20.04

I do appreciate it thank you for every single advice you will provide

Hi @Khaled_Jarrah

I will try to answer your questions as best as I can, I am also developing a controller for my specific applications and I have already looked at some of the docs you need.

  1. Yes you can! Look at px4 offboard mode to understand how to set the offboard according to your needs. For a quick summary, you need to send px4 a stream of offboard messages telling the controller which set points to expect. In “position” mode you are exploiting the full cascade of PID already implemented on the board. You can go as deep as the actual commanded motor rates, but read the documentation carefully to understand how the board expects the setpoint to be encoded.

  2. I did not fully understand this question, but yes, you can use ROS2, Gazebo, and PX4, there is quite comprehensive documentation on the official guide: ROS2, Gazebo

  3. I think the answer to your questions lies in the link in 1.

  4. I would suggest to go with ROS2, from version v1.13.0 the development of the platform has shifted to ROS2. You will find it easier to get support from the community if you use ROS2

  5. Foxy has reached its end of support, I strongly suggest using Humble (I think it will be supported until 2026). Anyway, if you spend a couple of weeks learning how to use Docker, you will not need to change your Ubuntu version every time you need a different ROS version (or every time you need to work on a different project)

I hope you find it useful!

1 Like

Thank you very much for all these info. I will start reading the tutorial carefully