pidtuner / pidtuner.github.io

Free PID Controller gains tuning tool
GNU General Public License v3.0
239 stars 27 forks source link

support PX4 autopilot flight logs #11

Open dagar opened 3 years ago

dagar commented 3 years ago

Would it be possible to add support for PX4 autopilot flight logs? PX4 is an open source autopilot project that runs on a wide range of hardware ranging from hobbyist to professional and supports many different types of vehicles (multicopters, planes, hybrid VTOLs, etc).

If there's interest in this I'd be happy to go into detail about which fields to access sensor data, actuators, etc.

pidtuner commented 3 years ago

If there a lot of demand for this, we can figure something out. What we need are the signals that come in and out of the PIDs used in the control software.

@alex-spataru, maybe this is something you would like to collaborate in?

pidtuner commented 3 years ago

@dagar the variables that we need for PID tuning are the time, the val argument of the pid_calculate function and the pid->last_output.

If you tell me how we can get those variables from a log, I can help with the PID tuning.

Maybe @LorenzMeier can help with this information?

Also, could you point out to a cheap toy plane or multicopter that uses the PX4 autopilot software?

dagar commented 3 years ago

@dagar the variables that we need for PID tuning are the time, the val argument of the pid_calculate function and the pid->last_output.

If you tell me how we can get those variables from a log, I can help with the PID tuning.

The multicopter rate controller is here (not using that old pid library). https://github.com/PX4/PX4-Autopilot/blob/f9d8c613b048f58eb3110e9af13cb3a89c4c866f/src/modules/mc_rate_control/RateControl/RateControl.cpp#L60-L75 Controller diagram. https://docs.px4.io/master/en/flight_stack/controller_diagrams.html#multicopter-angular-rate-controller

From the ulg the inputs are vehicle_angular_velocity, vehicle_angular_acceleration, and vehicle_rates_setpoint. The output is actuator_controls.

Also, could you point out to a cheap toy plane or multicopter that uses the PX4 autopilot software?

Here are some options for kits.

Alternatively I'd be happy to send you a flight controller if you want to build your own multicopter or put it in a plane.

You can also do quite a lot in simulation using gazebo or other options. https://docs.px4.io/master/en/simulation/gazebo.html

skorokithakis commented 3 years ago

The PixHawk is pretty expensive as far as controllers go, this Omnibus F4 clone runs ArduPilot, INAV, Betaflight and, I assume, PX4.

It would be great if we could have support for those firmwares as well, and we can already get CSV logs of various telemetry from them, but I'm not quite sure which parameters you'd need logs for to support them.

pidtuner commented 3 years ago

Ideally, I would like to get an already assembled drone Where I can test and log data, so I can focus merely on the PID tuning issue (wish I had the time to build something).

Something like Omnibus F4 sounds good, supporting Betaflight and PX4 (since I could also use it for the Betaflight issue), but already assembled and in the price range of the Crazyflie (250-300 bucks).

My goal here is not to become a drone enthusiast, wish I could, but figure out how the pidtuner can be used to tune drone's PIDs.

The best approach is to find the PID code in the source code to pin-point the variables of interest. We need the exact variable that come in the PID (to compute the error) and right out of the PID (to compute the values that eventually end up in the motors). Then get some user data, and see how we progress.

So if you have any log data, please share it, preferably data where the PID gains are not well adjusted (bad performance). This kind of data gives more information relevant to tuning.