From 7db59d197aafb4edce9bf5ebc614a27e3a092f5e Mon Sep 17 00:00:00 2001 From: Rik <49898887+gemenerik@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:22:00 +0200 Subject: [PATCH 1/2] Add cf21bl build target --- build_targets.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_targets.json b/build_targets.json index 67db9ea837..66a95545d8 100644 --- a/build_targets.json +++ b/build_targets.json @@ -3,6 +3,7 @@ "cf2", "bolt", "tag", - "flapper" + "flapper", + "cf21bl" ] } From 7a66c4cf72e8dad89c30ce487d9851ea66bd417d Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Wed, 7 Aug 2024 13:08:33 +0200 Subject: [PATCH 2/2] Fix power distribution tests for platforms with idle thrust --- test_python/test_power_distribution.py | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test_python/test_power_distribution.py b/test_python/test_power_distribution.py index e794147531..f090a9e445 100644 --- a/test_python/test_power_distribution.py +++ b/test_python/test_power_distribution.py @@ -118,6 +118,7 @@ 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) @@ -125,10 +126,10 @@ def test_power_distribution_cap_when_in_range(): # 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(): @@ -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(): @@ -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)