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

mc_att_control: remove direct setting of att sp in Stabilized #22644

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

sfuhrer
Copy link
Contributor

@sfuhrer sfuhrer commented Jan 16, 2024

Currently in the MC attitude controller, in Stabilized mode, the generated attitude setpoints are copied inside the module to where they are used (plus also published over uORB).
Here I propose to remove this internal copying and only publish it to the uorb topic, which is subscribed to in the same module.

This "should" have no behavior change - unless we deem the passing of the attitude setpoint over uorb less stable and want to keep the internal copying of it through setAttitudeSetpoint(). I propose this change to be able to remove the "if(vtol_transition)" and keep the controller flows as consistent as possible.

Context: #22584 (comment)

FYI @MaEtUgR

Instead of directly setting the attitude setpoint for usage inside the same module
only publish it to the uorb topic, which is subscribed to in the same module.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
@dagar
Copy link
Member

dagar commented Jan 16, 2024

uorb less stable and want to keep the internal copying of it through setAttitudeSetpoint(). I propose this change to be able to remove the "if(vtol_transition)" and keep the controller flows as consistent as possible.

It's not less stable or anything, but one problem with the change given the current structure is that now the attitude setpoint is delayed by one iteration. Probably not even noticeable, but it's unnecessary input latency we should be able to easily avoid with a slightly different structure.

Could you simply move "check for new attitude setpoint" to right before the attitude controller is run (_attitude_control.update(q))? You'll need to make sure the heading reset is still correct, but otherwise that seems fine.

// Check for new attitude setpoint
if (_vehicle_attitude_setpoint_sub.updated()) {
vehicle_attitude_setpoint_s vehicle_attitude_setpoint;
if (_vehicle_attitude_setpoint_sub.copy(&vehicle_attitude_setpoint)
&& (vehicle_attitude_setpoint.timestamp > _last_attitude_setpoint)) {
_attitude_control.setAttitudeSetpoint(Quatf(vehicle_attitude_setpoint.q_d), vehicle_attitude_setpoint.yaw_sp_move_rate);
_thrust_setpoint_body = Vector3f(vehicle_attitude_setpoint.thrust_body);
_last_attitude_setpoint = vehicle_attitude_setpoint.timestamp;
}
}

…sage

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
@sfuhrer
Copy link
Contributor Author

sfuhrer commented Jan 22, 2024

uorb less stable and want to keep the internal copying of it through setAttitudeSetpoint(). I propose this change to be able to remove the "if(vtol_transition)" and keep the controller flows as consistent as possible.

It's not less stable or anything, but one problem with the change given the current structure is that now the attitude setpoint is delayed by one iteration. Probably not even noticeable, but it's unnecessary input latency we should be able to easily avoid with a slightly different structure.

Could you simply move "check for new attitude setpoint" to right before the attitude controller is run (_attitude_control.update(q))? You'll need to make sure the heading reset is still correct, but otherwise that seems fine.

// Check for new attitude setpoint
if (_vehicle_attitude_setpoint_sub.updated()) {
vehicle_attitude_setpoint_s vehicle_attitude_setpoint;
if (_vehicle_attitude_setpoint_sub.copy(&vehicle_attitude_setpoint)
&& (vehicle_attitude_setpoint.timestamp > _last_attitude_setpoint)) {
_attitude_control.setAttitudeSetpoint(Quatf(vehicle_attitude_setpoint.q_d), vehicle_attitude_setpoint.yaw_sp_move_rate);
_thrust_setpoint_body = Vector3f(vehicle_attitude_setpoint.thrust_body);
_last_attitude_setpoint = vehicle_attitude_setpoint.timestamp;
}
}

Good point. Done it in 6173323. I don't see an issue with it neither, neither with the order (run generate_attitude_setpoint() before the pulling of the attitude_setpoint), nor with that now the attitude_setpoint is only pulled when run_att_ctrl is actually true.

@MaEtUgR MaEtUgR self-requested a review January 23, 2024 16:52
@mrpollo
Copy link
Contributor

mrpollo commented Jan 30, 2024

@MaEtUgR would appreciate your review with fresh eyes!
Note: Double check possibly yaw reset race conditions.

@dagar dagar merged commit 982c998 into main Feb 6, 2024
91 checks passed
@dagar dagar deleted the pr-mc-att-c-stabilized-pass-att-uorb-main branch February 6, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants