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

Add cf21bl build target #1396

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cf2",
"bolt",
"tag",
"flapper"
"flapper",
"cf21bl"
]
}
27 changes: 15 additions & 12 deletions test_python/test_power_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,18 @@ def test_power_distribution_cap_when_in_range():
input.motors.m4 = 4000

actual = cffirmware.motors_thrust_pwm_t()
idle_thrust = cffirmware.powerDistributionGetIdleThrust()

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

# Assert
# control.thrust will be at a (tuned) hover-state
assert not isCapped
assert actual.motors.m1 == input.motors.m1
assert actual.motors.m2 == input.motors.m2
assert actual.motors.m3 == input.motors.m3
assert actual.motors.m4 == input.motors.m4
assert actual.motors.m1 == max(input.motors.m1, idle_thrust)
assert actual.motors.m2 == max(input.motors.m2, idle_thrust)
assert actual.motors.m3 == max(input.motors.m3, idle_thrust)
assert actual.motors.m4 == max(input.motors.m4, idle_thrust)


def test_power_distribution_cap_when_all_negative():
Expand All @@ -140,16 +141,17 @@ def test_power_distribution_cap_when_all_negative():
input.motors.m4 = -4000

actual = cffirmware.motors_thrust_pwm_t()
idle_thrust = cffirmware.powerDistributionGetIdleThrust()

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

# Assert
assert not isCapped
assert actual.motors.m1 == 0
assert actual.motors.m2 == 0
assert actual.motors.m3 == 0
assert actual.motors.m4 == 0
assert actual.motors.m1 == max(0, idle_thrust)
assert actual.motors.m2 == max(0, idle_thrust)
assert actual.motors.m3 == max(0, idle_thrust)
assert actual.motors.m4 == max(0, idle_thrust)


def test_power_distribution_cap_when_all_above_range():
Expand Down Expand Up @@ -203,13 +205,14 @@ def test_power_distribution_cap_reduces_thrust_equally_much_with_lower_cap():
input.motors.m4 = 0xffff + 10

actual = cffirmware.motors_thrust_pwm_t()
idle_thrust = cffirmware.powerDistributionGetIdleThrust()

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

# Assert
assert isCapped
assert actual.motors.m1 == 0
assert actual.motors.m2 == 0
assert actual.motors.m3 == 1000 - 10
assert actual.motors.m4 == 0xffff
assert actual.motors.m1 == max(0, idle_thrust)
assert actual.motors.m2 == max(0, idle_thrust)
assert actual.motors.m3 == max(1000 - 10, idle_thrust)
assert actual.motors.m4 == max(0xffff, idle_thrust)
Loading