control: clean up stop condition indentation
This stems from parsing a whole list of stop conditions. Since there are only two now, we can drop the dramatic indentation.
@@ -193,19 +193,12 @@ pbio_error_t control_update_time_target(pbio_control_t *ctl, ustime_t time_now,
// Calculate duty signal
duty = duty_due_to_proportional + duty_due_to_derivative;
- // Check if we are at the target and standing still, with slightly different end conditions for each mode
- if (
- // Conditions for RUN_TIME command: past the total duration of the timed command
- (
- ctl->action == RUN_TIME && time_now >= ctl->trajectory.t3
- )
- ||
- // Conditions for run_stalled commands: the motor is stalled in either proportional or integral sense
- (
- ctl->action == RUN_STALLED && pbio_rate_integrator_stalled(&ctl->rate_integrator, time_now, rate_now, ctl->settings.stall_time, ctl->settings.stall_rate_limit)
- )
- )
- {
+ // Check if rate controller is stalled
+ bool stalled = pbio_rate_integrator_stalled(&ctl->rate_integrator, time_now, rate_now, ctl->settings.stall_time, ctl->settings.stall_rate_limit);
+
+ // Check if objective is completed
+ if ((ctl->action == RUN_TIME && time_now >= ctl->trajectory.t3) ||
+ (ctl->action == RUN_STALLED && stalled)) {
// Since we are stopping, the actuation is the after_stop action.
*actuation_type = ctl->after_stop;
