mapping the thrust and torques applied to the quadcopter to the PWM commands (PX4_Autopilot)
11 views (last 30 days)
Show older comments
Hello,I'm trying to implement a simple Hardware-in-the-Loop (HITL) simulation using PX4 and the UAV Toolbox Support Package for PX4 Autopilots (using PX4 Host Target). Specifically, I've customized a different controller for the quadcopter. However, I'm having trouble understanding how to use the actuator_write block. I've read the documentation, which states that the input should be between -1 and +1. How can we map the thrust and torques applied to the quadcopter to the commands u? Thanks.

0 Comments
Accepted Answer
Aditya Shah
on 20 Jan 2025
Edited: Aditya Shah
on 22 Jan 2025
Hi,
The PX4 architecture uses a "mixer" to convert high-level thrust and torque commands into actuator commands, tailored to the airframe's geometry. For more details, refer to the Control Allocation (Mixing) documentation.
For the mentioned SITL example, you can refer to the `generate_force_and_torques()` method in `~\PX4-Autopilot-1.14.3\src\modules\simulation\simulator_sih\sih.cpp`, to understand the derived quadcopter mixer matrix.
Note: The mixer defined in Simulink for this example uses a notation for roll and pitch that is opposite to that of the SIH plant mixer matrix used.
If you are not familiar with mixers and want to directly write Roll, Pitch, and Yaw values using the PX4 mixer, you can publish thrust to the uORB topic `VehicleThrustSetpoint` and roll, pitch, and yaw to `VehicleTorqueSetpoint`, respectively. Refer to this example: PX4 Hardware-in-the-Loop (HITL) Simulation with Manual Control for Fixed-Wing Plant in Simulink, which demonstrates a similar workflow for a different airframe(Plane).
Note: When writing to the uORB values, ensure that both inputs are normalized to the range [-1, 1] in the vehicle body FRD frame, where the Z-axis points downward . Additionally, with this workflow, you need to configure QGroundControl (QGC) to set the correct channels according to the plant being used.
Regards,
0 Comments
More Answers (0)
See Also
Categories
Find more on Quadcopters and Drones in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!