-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed wing offboard attitude setpoint fix #6112
Conversation
Nice, thanks! |
/* advertise and publish */ | ||
_attitude_sp_pub = orb_advertise(_attitude_setpoint_id, &_att_sp); | ||
if (!(_control_mode.flag_control_offboard_enabled && | ||
!(_control_mode.flag_control_position_enabled || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't cover altitude control mode where position, velocity, acceleration are off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a bit easier to read like this.
!(A && !B) === !A || B
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll confess to some unfamiliarity with the flag structure, but wouldn't altitude control mode trigger climb rate enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can see them here - https://github.com/PX4/Firmware/blob/master/src/modules/commander/commander.cpp#L3630
So isn't this wrong for altitude control mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will work for altitude control. tecs will provide a pitch setpoint, so the L1 controller should publish. The climb rate control flag will prevent the attitude controller from overwriting from the sticks. I'm not sure where the roll command comes from here, but I don't think this update changes that.
Am I missing something there? I'm away from my HiL setup right now so I can't test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For altitude control mode we need fw_pos_ctrl to publish an attitude setpoint when position, velocity, acceleration flags are false. The roll comes from the stick input, but currently that's handled in fw_pos_ctrl.
What about other offboard setpoints with position or altitude?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah that will need a check on the climb rate control flag. I think that the other offboard modes should set control_mode flags such that it'll work with a check on climb rate.
I'm having all kinds of trouble with the HiL right now so I can't test unfortunately. Will report back when I get it working.
I'm a little confused on the changes. Isn't the fw position controller code changes to control when to publish the attitude setpoint needed only to prevent the fw position controller from overwriting the published attitude setpoint when a MAVLINK_MSG_ID_SET_ATTITUDE_TARGET message is received? Otherwise wouldn't the same code in the mc position controller also be incorrect? |
I checked the setpoint publication conditions and they are actually the same now for MC and FW. In MC we have: Which can be written as (and should be changed into that form for readability): So i think this is good to go. |
I agree it looks correct now. Is anyone in a position to actually test this? Build failure appears to be a semaphore issue, restarted. |
I got my HiL working again, so I can test in sim, but not flight. Do you have suggested cases? |
Offboard mode with a range of different setpoint types. Quickly flip through stabilized, altitude and position control as well. |
…de. Fixes PX4#5927 Fixed wing controller was ignoring attitude setpoints from OFFBOARD. The controller never read the flags indicating that the aircraft was in offboard mode so it would generate stabilized mode commands from the manual inputs. and overwrite the OFFBOARD setpoints. A flag was added to fw_att_control_main to prevent generating these setpoints when in offboard mode. A flag was also added to fw_pos_control_l1_main which prevents publishing setpoints from the l1 controller as well (after dagar's suggestion: PX4#5927) fixed code formatting with the fix_code_style script attitude setpoint publish logic modified for clarity fixed formatting errors rebased from px4 master
d820ccb
to
f9de2de
Compare
I think I got the rebase done properly. For testing I've re-enabled offboard by simply removing the check for vehicle type. I'm not sure if that's the right solution or if this thread/patch is the right place to address it. |
Ok, report on modes: stabilized: works fine OFFBOARD modes (I'm not sure how may of these should/ever worked) rates: attitude: local position: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This actually needs a tiny change here to allow offboard for FW. https://github.com/PX4/Firmware/blob/master/src/modules/commander/state_machine_helper.cpp#L456 You can either add that here, or I'll make the change after this is merged. It's something I only recently changed in master. |
Just remove the check for rotary wing? If that's all it is I can add it super-quick, my local version already has that done so I could test. |
Yes, exactly. d0b188f |
done |
Thanks! |
Fix #5927 where attitude setpoints from offboard were being overwritten by the RC channels due to some missing flags.