-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ (Tests): Update & create new tests
- Loading branch information
Showing
7 changed files
with
164 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "PIDRotation.hpp" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
using namespace leka; | ||
|
||
class PIDRotationTest : public ::testing::Test | ||
{ | ||
protected: | ||
PIDRotationTest() = default; | ||
|
||
// void SetUp() override {} | ||
// void TearDown() override {} | ||
|
||
PIDRotation pid {}; | ||
|
||
float yaw = 0.F; | ||
|
||
float halfturn_error_speed = 1.85F; //? mapSpeed(180 * (Kp + Kd)/KDeltaT) | ||
float one_turn_error_speed = 3.55000019F; //? mapSpeed(360 * (Kp + Kd)/KDeltaT) | ||
float two_turn_error_speed = 6.95000029F; //? mapSpeed(720 * (Kp + Kd)/KDeltaT) | ||
}; | ||
|
||
TEST_F(PIDRotationTest, initialization) | ||
{ | ||
ASSERT_NE(&pid, nullptr); | ||
} | ||
|
||
TEST_F(PIDRotationTest, processRotationAngleDefaultPosition) | ||
{ | ||
auto target = 0.F; | ||
|
||
auto speed = pid.processRotationAngle(target, yaw); | ||
|
||
EXPECT_EQ(speed, 0.F); | ||
} | ||
|
||
TEST_F(PIDRotationTest, processRotationAngleHalfTurn) | ||
{ | ||
auto target = 180.F; | ||
|
||
auto speed = pid.processRotationAngle(target, yaw); | ||
|
||
EXPECT_EQ(speed, halfturn_error_speed); | ||
} | ||
|
||
TEST_F(PIDRotationTest, processRotationAngleOneTurn) | ||
{ | ||
auto target = 360.F; | ||
|
||
auto speed = pid.processRotationAngle(target, yaw); | ||
|
||
EXPECT_EQ(speed, one_turn_error_speed); | ||
} | ||
|
||
TEST_F(PIDRotationTest, processRotationAngle2Turn) | ||
{ | ||
auto target = 720.F; | ||
|
||
auto speed = pid.processRotationAngle(target, yaw); | ||
|
||
EXPECT_EQ(speed, two_turn_error_speed); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "PIDStabilization.hpp" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
using namespace leka; | ||
|
||
class PIDStabilizationTest : public ::testing::Test | ||
{ | ||
protected: | ||
PIDStabilizationTest() = default; | ||
|
||
// void SetUp() override {} | ||
// void TearDown() override {} | ||
|
||
PIDStabilization pid {}; | ||
|
||
EulerAngles target {.pitch = 0.F, .roll = 0.F, .yaw = 0.F}; | ||
EulerAngles current {}; | ||
|
||
float quarterturn_error_speed = 1.F; //? mapSpeed(90 * (Kp + Kd)/ KDeltaT) | ||
float halfturn_error_speed = 1.85F; //? mapSpeed(180 * (Kp + Kd)/ KDeltaT) | ||
}; | ||
|
||
TEST_F(PIDStabilizationTest, initialization) | ||
{ | ||
ASSERT_NE(&pid, nullptr); | ||
} | ||
|
||
TEST_F(PIDStabilizationTest, processStabilizationAngleDefaultPosition) | ||
{ | ||
current = {.pitch = 0.F, .roll = 0.F, .yaw = 0.F}; | ||
|
||
auto [speed, direction] = pid.processStabilizationAngle(target, current); | ||
|
||
EXPECT_EQ(speed, 0.F); | ||
EXPECT_EQ(direction, Rotation::clockwise); | ||
} | ||
|
||
TEST_F(PIDStabilizationTest, processStabilizationAngleRolledOverAHalfRight) | ||
{ | ||
current = {.pitch = 0.F, .roll = 0.F, .yaw = 180.F}; | ||
|
||
auto [speed, direction] = pid.processStabilizationAngle(target, current); | ||
|
||
EXPECT_EQ(speed, halfturn_error_speed); | ||
EXPECT_EQ(direction, Rotation::counterClockwise); | ||
} | ||
|
||
TEST_F(PIDStabilizationTest, processStabilizationAngleRolledOverAQuarterRight) | ||
{ | ||
current = {.pitch = 0.F, .roll = 0.F, .yaw = 90.F}; | ||
|
||
auto [speed, direction] = pid.processStabilizationAngle(target, current); | ||
|
||
EXPECT_EQ(speed, quarterturn_error_speed); | ||
EXPECT_EQ(direction, Rotation::counterClockwise); | ||
} | ||
|
||
TEST_F(PIDStabilizationTest, processStabilizationAngleRolledOverAQuarterLeft) | ||
{ | ||
current = {.pitch = 0.F, .roll = 0.F, .yaw = -90.F}; | ||
|
||
auto [speed, direction] = pid.processStabilizationAngle(target, current); | ||
|
||
EXPECT_EQ(speed, quarterturn_error_speed); | ||
EXPECT_EQ(direction, Rotation::clockwise); | ||
} | ||
|
||
TEST_F(PIDStabilizationTest, processStabilizationAngleRolledOverAHalfLeft) | ||
{ | ||
current = {.pitch = 0.F, .roll = 0.F, .yaw = -180.F}; | ||
|
||
auto [speed, direction] = pid.processStabilizationAngle(target, current); | ||
|
||
EXPECT_EQ(speed, halfturn_error_speed); | ||
EXPECT_EQ(direction, Rotation::clockwise); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.