Offboard control with Attitude and Velocity or Position for Z control

Is it possible to create a method to command PX4 using offboard mode with attitude for roll, pitch, yaw and position or velocity command for Z instead of thrust?

Have you considered using MAVSDK? Check the API for offboard here:

Yes I am already looking into MAVSDK. But the main problem I have is that the command structures dont have the combination I am looking for.

For example,
the struct Attitude has roll, pitch, yaw and thrust
instead, I was looking for a struct that has roll, pitch, yaw and down_velocity

Right, so you would basically want the same interface as ALTCTL. I think this would have to be added to the offboard plugin. Would you be interested in making a pull request to add it?

Yes I would like to add it. I think that this will need a new MAVlink message (having roll, pitch, yaw and down_velocity) which means that PX4 also has to be changed for this new message.

Do you see any way of doing this without a new MAVlink message?

Could we assemble it using the existing messages? Presumably we have to send two messages but it should work.

Actually, taking a step back: why do you need roll/pitch/yaw instead of velocities?

I had tried sending two messages but it didn’t work as I wanted.
I created 2 functions in MAVSDK. One sends just the down_speed by using position_setpoint message in MAVlink (everything else other than down_speed was ignored using the ignore mask) and other which sends just the quaternion using the attitude_setpoint message in MAVlink (everything else other than the quaternion was ignored using the ignore mask). But this did not work as I wanted.

The application for which I am working on this modifications includes the operation of a drone in close proximity to big structures which demand a fine control. I already have a high level control ready and working which commands roll, pitch and yaw to the drone with an another flight controller stack. but I am planning to move to PX4 for better flexibility in modifications.

Ok, I understand. If the flight controller has good localization / position estimation then velocity control should work equally well though, at least if tuned well.

Agreed. But it is kinda an unknown which I wanted to eliminate which is why I decided to go about the atti commands.
Coming back to sending the mixed command of attitude and velocity. I was not able to use 2 commands to command atti in one and velocity in the other one. maybe I am doing it in a wrong way! Any comments on that?

I would have to try that and debug in the Firmware what exactly happens. Unless @MaEtUgR knows?

Ok. I am trying it on my side by adding a new MAVlink message but it would be good to know if there is an easier way.

I don’t think an additional messages resolves it. It rather needs fixing in the controllers where the data is consumed.

Oh! Do you mean the controllers inside PX4 firmware?

Yes that’s what I mean.

I guess the mc_att_control module might need changes to use z velocity instead of thrust. It will be quite a modification! Please let me know if you find out anything!