Skip to content

Commit 9aa4538

Browse files
authored
Merge pull request #1396 from bitcraze/rik/bl
Add cf21bl build target
2 parents 7f1f782 + 7a66c4c commit 9aa4538

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

build_targets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"cf2",
44
"bolt",
55
"tag",
6-
"flapper"
6+
"flapper",
7+
"cf21bl"
78
]
89
}

test_python/test_power_distribution.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ def test_power_distribution_cap_when_in_range():
118118
input.motors.m4 = 4000
119119

120120
actual = cffirmware.motors_thrust_pwm_t()
121+
idle_thrust = cffirmware.powerDistributionGetIdleThrust()
121122

122123
# Test
123124
isCapped = cffirmware.powerDistributionCap(input, actual)
124125

125126
# Assert
126127
# control.thrust will be at a (tuned) hover-state
127128
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)
132133

133134

134135
def test_power_distribution_cap_when_all_negative():
@@ -140,16 +141,17 @@ def test_power_distribution_cap_when_all_negative():
140141
input.motors.m4 = -4000
141142

142143
actual = cffirmware.motors_thrust_pwm_t()
144+
idle_thrust = cffirmware.powerDistributionGetIdleThrust()
143145

144146
# Test
145147
isCapped = cffirmware.powerDistributionCap(input, actual)
146148

147149
# Assert
148150
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)
153155

154156

155157
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():
203205
input.motors.m4 = 0xffff + 10
204206

205207
actual = cffirmware.motors_thrust_pwm_t()
208+
idle_thrust = cffirmware.powerDistributionGetIdleThrust()
206209

207210
# Test
208211
isCapped = cffirmware.powerDistributionCap(input, actual)
209212

210213
# Assert
211214
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

Comments
 (0)