Wrote a custom TVLQR (Time varying LQR) controller for FW, but cannot send commands properly

Hello,

I’m working on a project which involves having fixed-wing drones track trajectories. I have written an LQR controller for our given system and have determined the appropriate commands for Thurst,Roll,Pitch, and Yaw.

u = -K(x_meas-x_desired)+u_feedforward

These outputs are properly scaled between -1 to 1 for all except thrust which is 0-1.

How can I properly send these commands to the airplane using PX4 on pixhawk? I have tried writing to actuators_direct and such but am still having trouble following the proper procedure to send the commands.

Thank you,
Zack