SET_ATTITUDE_TARGET control with fixed wing

I’m successfully controlling a fixed wing plane in SITL but am in need of a better explanation of the message. I’m using the quaternion to command roll and pitch but don’t know what values to pass in. At first since the rates are in radians/second I figured the quaternion would be in radians, so if my desired attitude is a 25 degree bank I would pass in radians(25) into the x value of the quaternion, but it seems to bank more. With pitch it is even more sensitive. Can someone explain to me the units of the quaternion and how I can translate a desired bank angle into the Q? Thanks

You need to convert first. https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
There are helper functions directly in mavlink. https://github.com/mavlink/c_library_v1/blob/e93ac62981a338a7c823364e7c4ff1077e3f8fc1/mavlink_conversions.h

@dagar Thank you very much!!!

I’m also having issues understanding how to use SET_ATTITUDE_TARGET. My understanding is the q value is for the attitude quaternion so whatever the value we set here is the attitude set point we want to achieve. So are the body rates specifying how fast to move to these positions?

I want to minimize the inputs to control the quadcopter so I’m trying to understand when to set only q (as the OP is doing) or both q and the rates. If my understanding above is correct, if only q is set what rates are used?

I’m in offboard mode but would like to control the quadcopter the same way as in manual mode (i.e. control by roll pitch yaw thrust). I’ve tried to use SET_ATTITUDE_TARGET with only the body rates but I don’t get the expected performance unless I also set q.

Thanks for the help

My guess is that there are default parameters set in PX4 for roll, pitch, and yaw rates so the it will be limitted to those unless you directly specify in that message.

Yea looks like you are right, digging into the code I found this,

So if you only specify the attitude quaternion and thrust, it will calculate the optimal rates for you, and then make sure they are within rage. From QGC you can change these rate constraints by MC_PITCHRATE_MAX, MC_ROLLRATE_MAX, MC_YAWRATE_MAX

Please correct me if I’m wrong

@dagar How does the yaw input for attitude target affect the plane? I’ve been using 0 and just roll and pitch but wasn’t sure if the 0 yaw would have impact for fixed wing attitude control

Do you use the SET_ATTITUDE_TARGET control for fixed wing in offboard mode? I try to make my fixed wing enter the offboard mode, but it failed.

@zhanghouxin07 What version of the firmware are you using? Fixed wing offboard mode has been enabled pretty recently.

the firmware version used is 1.9.0dev in gazebo simulation. Could you tell me which version supports the offboard mode?
I have been done some works in rotated-wing uavs, and I implemented all the mode in rotatedwing. now, I use the almost same codes to complete my fixed wing work. I’m not sure that if the process of entering the offboard mode is same as the rotated-wing.
thx a lot

aha, I try to enter offboard again. I found that the fixed wing should take off first, then it can enter Offboard mode successfully. In previous work for fw, I implement the same process with rotated-wing, for instance, auto takeoff.

thx again for your nice help.
If you have any questions, we can further communicate via mail or others.

Is quaternion control for FW via ROS2 possible/enabled? I can control the aircraft successfully by publishing Euler angles via the VehicleAttitudeSetpoint message on the /fmu/in/vehicle_attitude_setpoint topic. However, if I assign a quaternion to q_d in the VehicleAttitudeSetpoint message, nothing happens…
Thanks!

@spin It is not supported, but would be interesting to add.

The main reason is that yaw is normally controlled for minimizing sideslip, and not independentlyncontrolled. Therefore the fixed wing attitude control does not really control for a full quaternion reference

@Jaeyoung-Lim Thanks for your quick answer! That makes total sense.

A little bit off the topic but would be interesting to know, too: Is direct actuator control possible for FW vis ROS2? I have added

  - topic: /fmu/in/manual_control_setpoint
    type: px4_msgs::msg::ManualControlSetpoint

In dds_topics.yaml and tried to set the roll, pitch, yaw, throttle attributes in the ManualControlSetpoint message, but the vehicle didn’t respond to that. Would be interesting for Sys ID…

@spin You can publish anything you want, it will be just uORB messages.

If you publish manual setpoints you need to be in a flight mode that uses it.

For direct actuator control it is agnostic to vehicle type