@@ -118,17 +118,18 @@ def test_power_distribution_cap_when_in_range():
118
118
input .motors .m4 = 4000
119
119
120
120
actual = cffirmware .motors_thrust_pwm_t ()
121
+ idle_thrust = cffirmware .powerDistributionGetIdleThrust ()
121
122
122
123
# Test
123
124
isCapped = cffirmware .powerDistributionCap (input , actual )
124
125
125
126
# Assert
126
127
# control.thrust will be at a (tuned) hover-state
127
128
assert not isCapped
128
- assert actual .motors .m1 == input .motors .m1
129
- assert actual .motors .m2 == input .motors .m2
130
- assert actual .motors .m3 == input .motors .m3
131
- assert actual .motors .m4 == input .motors .m4
129
+ assert actual .motors .m1 == max ( input .motors .m1 , idle_thrust )
130
+ assert actual .motors .m2 == max ( input .motors .m2 , idle_thrust )
131
+ assert actual .motors .m3 == max ( input .motors .m3 , idle_thrust )
132
+ assert actual .motors .m4 == max ( input .motors .m4 , idle_thrust )
132
133
133
134
134
135
def test_power_distribution_cap_when_all_negative ():
@@ -140,16 +141,17 @@ def test_power_distribution_cap_when_all_negative():
140
141
input .motors .m4 = - 4000
141
142
142
143
actual = cffirmware .motors_thrust_pwm_t ()
144
+ idle_thrust = cffirmware .powerDistributionGetIdleThrust ()
143
145
144
146
# Test
145
147
isCapped = cffirmware .powerDistributionCap (input , actual )
146
148
147
149
# Assert
148
150
assert not isCapped
149
- assert actual .motors .m1 == 0
150
- assert actual .motors .m2 == 0
151
- assert actual .motors .m3 == 0
152
- assert actual .motors .m4 == 0
151
+ assert actual .motors .m1 == max ( 0 , idle_thrust )
152
+ assert actual .motors .m2 == max ( 0 , idle_thrust )
153
+ assert actual .motors .m3 == max ( 0 , idle_thrust )
154
+ assert actual .motors .m4 == max ( 0 , idle_thrust )
153
155
154
156
155
157
def test_power_distribution_cap_when_all_above_range ():
@@ -203,13 +205,14 @@ def test_power_distribution_cap_reduces_thrust_equally_much_with_lower_cap():
203
205
input .motors .m4 = 0xffff + 10
204
206
205
207
actual = cffirmware .motors_thrust_pwm_t ()
208
+ idle_thrust = cffirmware .powerDistributionGetIdleThrust ()
206
209
207
210
# Test
208
211
isCapped = cffirmware .powerDistributionCap (input , actual )
209
212
210
213
# Assert
211
214
assert isCapped
212
- assert actual .motors .m1 == 0
213
- assert actual .motors .m2 == 0
214
- assert actual .motors .m3 == 1000 - 10
215
- assert actual .motors .m4 == 0xffff
215
+ assert actual .motors .m1 == max ( 0 , idle_thrust )
216
+ assert actual .motors .m2 == max ( 0 , idle_thrust )
217
+ assert actual .motors .m3 == max ( 1000 - 10 , idle_thrust )
218
+ assert actual .motors .m4 == max ( 0xffff , idle_thrust )
0 commit comments