Skip to content
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

Merged
merged 3 commits into from
Feb 16, 2017

Conversation

aivian
Copy link
Contributor

@aivian aivian commented Dec 20, 2016

Fix #5927 where attitude setpoints from offboard were being overwritten by the RC channels due to some missing flags.

@LorenzMeier
Copy link
Member

Nice, thanks!

@LorenzMeier
Copy link
Member

@Tumbili @dagar Can you review for potential side-effects to standard operation? Diff looked good otherwise.

dagar
dagar previously requested changes Dec 26, 2016
/* 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 ||
Copy link
Member

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.

Copy link
Member

@dagar dagar Dec 26, 2016

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

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

@yzzir
Copy link

yzzir commented Jan 18, 2017

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?

@AndreasAntener
Copy link
Contributor

I checked the setpoint publication conditions and they are actually the same now for MC and FW.

In MC we have:
! ( offboard && ! ( position || velocity || acceleration )

Which can be written as (and should be changed into that form for readability):
! offboard || ( position || velocity || acceleration ) (brackets are also not necessary anymore)

So i think this is good to go.

@dagar
Copy link
Member

dagar commented Feb 9, 2017

I agree it looks correct now. Is anyone in a position to actually test this?

Build failure appears to be a semaphore issue, restarted.

@dagar dagar dismissed their stale review February 9, 2017 15:49

looks correct now

@aivian
Copy link
Contributor Author

aivian commented Feb 9, 2017

I got my HiL working again, so I can test in sim, but not flight. Do you have suggested cases?

@dagar
Copy link
Member

dagar commented Feb 9, 2017

Offboard mode with a range of different setpoint types. Quickly flip through stabilized, altitude and position control as well.

@AndreasAntener
Copy link
Contributor

@aivian note that #6537 just got merged, which means this would require a rebase and a quick change in the state machine helper to allow fixed-wing going into offboard again.

…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
@aivian aivian force-pushed the fw_offboard_att_sp_fix branch from d820ccb to f9de2de Compare February 13, 2017 16:57
@aivian
Copy link
Contributor Author

aivian commented Feb 13, 2017

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.

@aivian
Copy link
Contributor Author

aivian commented Feb 13, 2017

Ok, report on modes:

stabilized: works fine
position: lateral stick commands turn rate, throttle stick commands speed, pitch stick commands climb rate

OFFBOARD modes (I'm not sure how may of these should/ever worked)
accel:
input: sinusoidal y acceleration magnitude 5.0 (m/s?)
response: slightly left turn, no sinusoid, no response from sticks

rates:
input: zero rates on all axes
response: immediately rolls inverted and tries to crash

attitude:
input: sinusoidal roll angle command, 30 degree amplitude
response: tracks sinusoidal input well

local position:
input: (0, 0, 0)
output: the aircraft flies as if it is in position control mode

Copy link
Member

@dagar dagar left a 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.

@dagar
Copy link
Member

dagar commented Feb 16, 2017

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.

@aivian
Copy link
Contributor Author

aivian commented Feb 16, 2017

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.

@dagar
Copy link
Member

dagar commented Feb 16, 2017

Yes, exactly. d0b188f

@aivian
Copy link
Contributor Author

aivian commented Feb 16, 2017

done

@dagar
Copy link
Member

dagar commented Feb 16, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants