I am curious about the example openExample('px4/PlantAttitudeControllerHexacopterExample')
6 views (last 30 days)
Show older comments
I understand that I used the drone dynamic model to represent the plant model, but I would be very grateful if you could tell me how you used the dynamic equation I saw to create it. I also added the modeling I created. I would appreciate it if you could tell me the difference between it and the example.
0 Comments
Answers (1)
Aravind
on 22 Aug 2024
Hi,
From the Simulink model you provided, it appears that you've utilized Newton’s Laws of motion and Euler’s Laws of rotation to develop a dynamic model of a quadrotor. The example "px4/PlantAttitudeControllerHexacopterExample” (https://www.mathworks.com/help/releases/R2023b/supportpkg/px4/ref/plant-attitude-px4-hexacopter.html) simulates a hexacopter's dynamic model using a PX4 flight controller. While the foundational principles are similar, there are notable differences between your implementation and the example.
Firstly, your model uses the angular velocities of the motors as inputs, whereas the example employs PWM as an input, with pulse widths ranging from 1000 µs to 2000 µs. This is because, the PX4 flight controller takes the setpoint inputs from directly from the RC, which outputs PWM signals only. See https://docs.px4.io/main/en/concept/architecture.html#flight-stack for more information regarding this.
Secondly, the dynamic model in your Simulink file is based on Euler angles, which have the critical flaw of gimbal lock. For more information see, https://en.wikipedia.org/wiki/Gimbal_lock. The example uses the "6DOF (Quaternion)" block from the Aerospace toolbox. This block takes the forces and moments acting on the body as inputs and solves the linear and rotational equations of motion using quaternions instead of Euler angles. Quaternions do not suffer from gimbal lock and are therefore widely used for representing rotation. More information on the 6DOF (Quaternion) block is available here: https://www.mathworks.com/help/releases/R2023b/aeroblks/6dofquaternion.html.
The subsystem preceding the “6DOF (Quaternion) block”, whose images you shared, is used to calculate the forces and moments acting on the hexacopter. This subsystem considers air density, simulates propeller rotation, and calculates the forces and moments generated by each propeller and their effects on the hexacopter. It also accounts for forces like air drag, making the simulation more realistic.
Lastly, the example simulates an onboard IMU with noise using the "Three-axis Inertial Measurement Unit" block from the Aerospace toolbox, rather than using velocity and acceleration values directly from the dynamic model as you have done. More information regarding the "Three-axis Inertial Measurement Unit" block can be found at https://www.mathworks.com/help/releases/R2023b/aeroblks/threeaxisinertialmeasurementunit.html.
These are some of the significant differences between your implementation and the example. Hope this helps!
1 Comment
Gaetan CHESNEAU
on 11 Sep 2024
Moved: Walter Roberson
on 12 Sep 2024
Hi, and thank you a lot for your explanation. As far as I'm concerned, I would be very grateful if you could tell me how I can modify this hexacopter example step by step to obtain a PlantAttitudeControllerQuadcopterexample to simulate a F450 DIY interfaced with a Pixahwk.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!