Skip to content

Commit 17e2972

Browse files
surfdadolukash
authored andcommitted
Turntilt fix: don't suppress it in high torque response situations
Originally I had added this turntilt suppression beacuse of my paranoia about getting taildrags on downhills when turntilt kicks in... It turns out that it was unnecessary. In the contrary: uphill/downhill berms, no matter how steep, still benefit from having turntilt. Fix: Remove turntilt suppression in high torque response situations
1 parent f70e265 commit 17e2972

3 files changed

Lines changed: 3 additions & 49 deletions

File tree

src/main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -887,14 +887,7 @@ static void refloat_thd(void *arg) {
887887
brake_tilt_winddown(&d->brake_tilt);
888888
} else {
889889
apply_noseangling(d);
890-
turn_tilt_update(
891-
&d->turn_tilt,
892-
&d->motor,
893-
&d->atr,
894-
d->imu.balance_pitch,
895-
d->noseangling_interpolated,
896-
&d->float_conf
897-
);
890+
turn_tilt_update(&d->turn_tilt, &d->motor, &d->float_conf);
898891

899892
torque_tilt_update(&d->torque_tilt, &d->motor, &d->float_conf);
900893
atr_update(&d->atr, &d->motor, &d->float_conf);

src/turn_tilt.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,7 @@ void turn_tilt_aggregate(TurnTilt *tt, const IMU *imu) {
7373
}
7474
}
7575

76-
void turn_tilt_update(
77-
TurnTilt *tt,
78-
const MotorData *md,
79-
const ATR *atr,
80-
float balance_pitch,
81-
float noseangling,
82-
const RefloatConfig *config
83-
) {
76+
void turn_tilt_update(TurnTilt *tt, const MotorData *md, const RefloatConfig *config) {
8477
if (config->turntilt_strength == 0) {
8578
return;
8679
}
@@ -127,30 +120,6 @@ void turn_tilt_update(
127120
} else {
128121
tt->target *= md->erpm_sign;
129122
}
130-
131-
// ATR interference: Reduce target during moments of high torque response
132-
float atr_min = 2;
133-
float atr_max = 5;
134-
if (sign(atr->target) != sign(tt->target)) {
135-
// further reduced turntilt during moderate to steep downhills
136-
atr_min = 1;
137-
atr_max = 4;
138-
}
139-
if (fabsf(atr->target) > atr_min) {
140-
// Start scaling turntilt when ATR>2, down to 0 turntilt for ATR > 5 degrees
141-
float atr_scaling = (atr_max - fabsf(atr->target)) / (atr_max - atr_min);
142-
if (atr_scaling < 0) {
143-
atr_scaling = 0;
144-
// during heavy torque response clear the yaw aggregate too
145-
tt->yaw_aggregate = 0;
146-
}
147-
tt->target *= atr_scaling;
148-
}
149-
if (fabsf(balance_pitch - noseangling) > 4) {
150-
// no setpoint changes during heavy acceleration or braking
151-
tt->target = 0;
152-
tt->yaw_aggregate = 0;
153-
}
154123
}
155124

156125
// Smoothen changes in tilt angle by ramping the step size

src/turn_tilt.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#pragma once
1919

20-
#include "atr.h"
2120
#include "conf/datatypes.h"
2221
#include "imu.h"
2322
#include "motor_data.h"
@@ -45,13 +44,6 @@ void turn_tilt_configure(TurnTilt *tt, const RefloatConfig *config);
4544

4645
void turn_tilt_aggregate(TurnTilt *tt, const IMU *imu);
4746

48-
void turn_tilt_update(
49-
TurnTilt *tt,
50-
const MotorData *md,
51-
const ATR *atr,
52-
float balance_pitch,
53-
float noseangling,
54-
const RefloatConfig *config
55-
);
47+
void turn_tilt_update(TurnTilt *tt, const MotorData *md, const RefloatConfig *config);
5648

5749
void turn_tilt_winddown(TurnTilt *tt);

0 commit comments

Comments
 (0)