Hi everyone, I am trying to simulate Px4 controller, however I wanna change the drone dynamics. Is there any straightforward tool I can work with? The Matlab UAV toolboxâ€™s attitude controller is not the same as the quaternion based one we have in PX4. I am working to simply implement it in Matlab, however after around 3 weeks I was not successful. I have some issues in mimicing the px4 controller. I would appreciate it if anyone can help me. I need this tool to verify my experiments and I have to do it ASAP since I have a qualifying exam in the following month.

My exact problems are:

First, how do you define the delta_T setpoint using the quaternion based attitude controller? Is it right to say delta_T = (desired acceleration magnitude - current acceleration magnitude)*1/g*MPC_THR_HOVER?

And second, when I use a mixer matrix like [1 1*l -1*l 1*C_R; 1 -1*l 1*l 1*C_R; 1 1*l 1*l -1*C_R; 1 -1*l -1*l -1*C_R], (where l is the vehicle arm distance and C_R is considered to estimate the motorsâ€™ induced torque (in body z direction)) and multiply it to[delta_T_sp; delta_q_sp; delta_p_sp; delta_r_sp], I will get values between -0.2 and 1. I think it should not give us negative values. Am I right? So then What should we do to just linearly estimate the induced forces and torques?

I tried to find my answers in px4 c++ source codes but I could not since I am not a professional c++ coder.