Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
DriveBoard.cc File Reference

Unit test for DriveBoard driver class. More...

Include dependency graph for DriveBoard.cc:

Classes

class  DriveBoardTests
 Unit Test Class for the DriveBoard. More...

Functions

 TEST_F (DriveBoardTests, DoesNotLeak)
 Test for memory leaks.
 TEST_F (DriveBoardTests, Leaks)
 This should fail when the –check_for_leaks command line flag is specified.
 TEST_F (DriveBoardTests, CalculateMove_ZeroSpeedZeroHeading)
 Verify that CalculateMove returns near-zero powers with zero speed/heading.
 TEST_F (DriveBoardTests, SendDrive_UpdatesDrivePowers)
 Verify that SendDrive sets DrivePowers and GetDrivePowers matches them.
 TEST_F (DriveBoardTests, SendStop_StopsTheDrive)
 Verify that calling SendStop sets the powers to zero.

Detailed Description

Unit test for DriveBoard driver class.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2024-10-26

Function Documentation

◆ TEST_F() [1/5]

TEST_F ( DriveBoardTests ,
DoesNotLeak  )

Test for memory leaks.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2024-10-26
85{
86 DriveBoard* pDriveBoard = new DriveBoard();
87 ASSERT_NE(pDriveBoard, nullptr);
88 delete pDriveBoard;
89 pDriveBoard = nullptr;
90}
This class handles communication with the drive board on the rover by sending RoveComm packets over t...
Definition DriveBoard.h:35

◆ TEST_F() [2/5]

TEST_F ( DriveBoardTests ,
Leaks  )

This should fail when the –check_for_leaks command line flag is specified.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2024-10-26
99{
100 DriveBoard* pDriveBoard = new DriveBoard();
101 EXPECT_TRUE(pDriveBoard != nullptr);
102}

◆ TEST_F() [3/5]

TEST_F ( DriveBoardTests ,
CalculateMove_ZeroSpeedZeroHeading  )

Verify that CalculateMove returns near-zero powers with zero speed/heading.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2025-01-31
111{
112 // Test with eArcadeDrive
113 diffdrive::DrivePowers stArcadeDriveResultPowers = m_pDriveBoard->CalculateMove(0.0, 0.0, 0.0, diffdrive::DifferentialControlMethod::eArcadeDrive);
114
115 // We expect zero drive power when speed & heading are both zero.
116 EXPECT_NEAR(stArcadeDriveResultPowers.dLeftDrivePower, 0.0, 1e-6);
117 EXPECT_NEAR(stArcadeDriveResultPowers.dRightDrivePower, 0.0, 1e-6);
118
119 // Test with eCurvatureDrive
120 diffdrive::DrivePowers stCurvatureDriveResultPowers = m_pDriveBoard->CalculateMove(0.0, 0.0, 0.0, diffdrive::DifferentialControlMethod::eCurvatureDrive);
121
122 // We expect zero drive power when speed & heading are both zero.
123 EXPECT_NEAR(stCurvatureDriveResultPowers.dLeftDrivePower, 0.0, 1e-6);
124 EXPECT_NEAR(stCurvatureDriveResultPowers.dRightDrivePower, 0.0, 1e-6);
125}
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73

◆ TEST_F() [4/5]

TEST_F ( DriveBoardTests ,
SendDrive_UpdatesDrivePowers  )

Verify that SendDrive sets DrivePowers and GetDrivePowers matches them.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2025-01-31
134{
135 diffdrive::DrivePowers stPowers;
136 stPowers.dLeftDrivePower = 0.5;
137 stPowers.dRightDrivePower = -0.5;
138
139 m_pDriveBoard->SetMaxDriveEffort(1.0);
140 m_pDriveBoard->SendDrive(stPowers, false);
141
142 // The output drive powers will changed depending on what the drive board effort limits are.
143 diffdrive::DrivePowers stCurrentPowers = m_pDriveBoard->GetDrivePowers();
144 EXPECT_DOUBLE_EQ(stCurrentPowers.dLeftDrivePower, 0.5);
145 EXPECT_DOUBLE_EQ(stCurrentPowers.dRightDrivePower, -0.5);
146}

◆ TEST_F() [5/5]

TEST_F ( DriveBoardTests ,
SendStop_StopsTheDrive  )

Verify that calling SendStop sets the powers to zero.

Author
Targed (ltkli.nosp@m.onel.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
Date
2025-01-31
155{
156 diffdrive::DrivePowers stPowers;
157 stPowers.dLeftDrivePower = 1.0;
158 stPowers.dRightDrivePower = 1.0;
159
160 m_pDriveBoard->SendDrive(stPowers, false);
161 m_pDriveBoard->SendStop();
162
163 diffdrive::DrivePowers stCurrentPowers = m_pDriveBoard->GetDrivePowers();
164 EXPECT_DOUBLE_EQ(stCurrentPowers.dLeftDrivePower, 0.0);
165 EXPECT_DOUBLE_EQ(stCurrentPowers.dRightDrivePower, 0.0);
166}