Fix tests
This commit is contained in:
parent
047f1dac29
commit
4f71f939e0
@ -93,7 +93,7 @@ float DifferentialDrive::GetAngularVelocity() {
|
||||
leftSpeed = leftSpeed * rpsToMs; // in meters per second
|
||||
rightSpeed = rightSpeed * rpsToMs; // in meters per second
|
||||
|
||||
float angularSpeed = (rightSpeed - leftSpeed) / 2;
|
||||
float angularSpeed = (leftSpeed - rightSpeed) / 2;
|
||||
float angularDistance = wheelSeparation / 2 * Angle::pi;
|
||||
float rotationsPerSecond = angularSpeed / angularDistance;
|
||||
float degreesPerSecond = Angle::Normalize(360 * rotationsPerSecond);
|
||||
|
@ -130,7 +130,7 @@ TEST(BB2B, ObstacleLeft) {
|
||||
DifferentialDrive *propulsion = new DifferentialDrive(motorLeft, motorRight);
|
||||
propulsion->SetDimensions(
|
||||
1 / Angle::pi, // we use this, such that motor speed 1 -> velocity 1 m/s
|
||||
4 / Angle::pi); // we use this, such that angular velocity will be 180
|
||||
8 / Angle::pi); // we use this, such that angular velocity will be 90
|
||||
// degrees per second
|
||||
|
||||
Roboid *roboid = new Roboid(perception, propulsion);
|
||||
@ -205,11 +205,10 @@ TEST(BB2B, ObstacleLeft) {
|
||||
Polar velocity =
|
||||
diffDrive->GetVelocity(); // this depends on the wheel diameter.
|
||||
EXPECT_FLOAT_EQ(velocity.distance, 0.0F);
|
||||
EXPECT_FLOAT_EQ(velocity.angle, 0.0F);
|
||||
|
||||
float angularVelocity =
|
||||
diffDrive->GetAngularVelocity(); // this also depends on wheel separation
|
||||
EXPECT_FLOAT_EQ(angularVelocity, 180.0F);
|
||||
EXPECT_FLOAT_EQ(angularVelocity, 90.0F);
|
||||
|
||||
#pragma endregion
|
||||
}
|
||||
@ -232,7 +231,7 @@ TEST(BB2B, ObstacleRight) {
|
||||
DifferentialDrive *propulsion = new DifferentialDrive(motorLeft, motorRight);
|
||||
propulsion->SetDimensions(
|
||||
1 / Angle::pi, // we use this, such that motor speed 1 -> velocity 1 m/s
|
||||
4 / Angle::pi); // we use this, such that angular velocity will be 180
|
||||
8 / Angle::pi); // we use this, such that angular velocity will be 90
|
||||
// degrees per second
|
||||
|
||||
Roboid *roboid = new Roboid(perception, propulsion);
|
||||
@ -304,14 +303,11 @@ TEST(BB2B, ObstacleRight) {
|
||||
EXPECT_FLOAT_EQ(rightActualSpeed, 1.0F);
|
||||
|
||||
// Roboid velocity
|
||||
Polar velocity =
|
||||
diffDrive->GetVelocity(); // this depends on the wheel diameter.
|
||||
Polar velocity = diffDrive->GetVelocity();
|
||||
EXPECT_FLOAT_EQ(velocity.distance, 0.0F);
|
||||
EXPECT_FLOAT_EQ(velocity.angle, 0.0F);
|
||||
|
||||
float angularVelocity =
|
||||
diffDrive->GetAngularVelocity(); // this also depends on wheel separation
|
||||
EXPECT_FLOAT_EQ(angularVelocity, -180.0F);
|
||||
float angularVelocity = diffDrive->GetAngularVelocity();
|
||||
EXPECT_FLOAT_EQ(angularVelocity, -90.0F);
|
||||
|
||||
#pragma endregion
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.13) # CMake version check
|
||||
Project(RoboidControlTestNew)
|
||||
Project(RoboidControlTest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11) # Enable c++11 standard
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
@ -22,16 +22,16 @@ include_directories(
|
||||
enable_testing()
|
||||
|
||||
add_executable(
|
||||
RoboidControlTestNew
|
||||
RoboidControlTest
|
||||
"BB2B_Test.cc"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
RoboidControlTestNew
|
||||
RoboidControlTest
|
||||
gtest_main
|
||||
RoboidControl
|
||||
VectorAlgebra
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(RoboidControlTestNew)
|
||||
gtest_discover_tests(RoboidControlTest)
|
||||
|
Loading…
x
Reference in New Issue
Block a user