mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Added tests for motor inversions.
This commit squashes all of Patrick's eleven commits into one so that things are a bit more sane. The original commit messages and change ids (for gerrit) can be found below. Testing Motor Inversion Feature (Java tests only so far) Change-Id: I44cd9b5a3fe066e1071316831dde14bff5ec3bd9 Test 2 of java testing for Motor Inverting Change-Id: I96cc0534bb1d28a70d10c582f0b40ea3a2d83cab Added another test to try to track down issue with InvertingMotor jaguar and Talon Change-Id: I9b5292315c93ec0d568d53a6bcdac5b998a6d857 More Testing on the Inverting motors with jaguars and talons. Change-Id: I896210a54903e3c0af68e8c41360c165cf9c3122 Added C++ integration Tests for the motor inversion. Change-Id: I81af5d4aab78d755340d99608b838046bf7ddda1 C++ tests for Motor Inversion now without crashing Change-Id: Ifdecdbfc1aeb18aafb2b4c63709b27636074a274 More testing of inverted motors (now with c++ tests) Talon seems not to be working on test rig Also added a CANJaguartest file in java since was missing Currently porting the CANJaguar tests from c++ to java Change-Id: Ib578d6ee1256ac31ddf20603aa6f24adde08065b Another attempt at adding java tests for can jaguar inversion. Change-Id: I971a886a4e555ada5bd15a814094da2a1eb5c8e1 Minor changes and attempt to rerun tests after yesterday's jenkins crash. Change-Id: I7ed0904d4243499c3246e9c39e5493d0d9c962c5 All motor inversion tests should be working now. Talon on the test rig has been fixed. Change-Id: I20bd6d7486b758ce1ce47ac799150475b3152b6f Updated Inversion tests again. Should work this time. (worked on the test rig prior) Change-Id: Ifdf222d5e5733fe802f29e7d939b72e84972e8da Added tests for motor inversions. This commit squashes all of Patrick's eleven commits into one so that things are a bit more sane. The original commit messages and change ids (for gerrit) can be found below. Testing Motor Inversion Feature (Java tests only so far) Change-Id: I44cd9b5a3fe066e1071316831dde14bff5ec3bd9 Test 2 of java testing for Motor Inverting Change-Id: I96cc0534bb1d28a70d10c582f0b40ea3a2d83cab Added another test to try to track down issue with InvertingMotor jaguar and Talon Change-Id: I9b5292315c93ec0d568d53a6bcdac5b998a6d857 More Testing on the Inverting motors with jaguars and talons. Change-Id: I896210a54903e3c0af68e8c41360c165cf9c3122 Added C++ integration Tests for the motor inversion. Change-Id: I81af5d4aab78d755340d99608b838046bf7ddda1 C++ tests for Motor Inversion now without crashing Change-Id: Ifdecdbfc1aeb18aafb2b4c63709b27636074a274 More testing of inverted motors (now with c++ tests) Talon seems not to be working on test rig Also added a CANJaguartest file in java since was missing Currently porting the CANJaguar tests from c++ to java Change-Id: Ib578d6ee1256ac31ddf20603aa6f24adde08065b Another attempt at adding java tests for can jaguar inversion. Change-Id: I971a886a4e555ada5bd15a814094da2a1eb5c8e1 Minor changes and attempt to rerun tests after yesterday's jenkins crash. Change-Id: I7ed0904d4243499c3246e9c39e5493d0d9c962c5 All motor inversion tests should be working now. Talon on the test rig has been fixed. Change-Id: I20bd6d7486b758ce1ce47ac799150475b3152b6f Updated Inversion tests again. Should work this time. (worked on the test rig prior) Change-Id: Ifdf222d5e5733fe802f29e7d939b72e84972e8da
This commit is contained in:
@@ -27,6 +27,11 @@ static constexpr double kCurrentTolerance = 0.1;
|
||||
|
||||
static constexpr double kVoltageTolerance = 0.1;
|
||||
|
||||
static constexpr double kMotorVoltage = 5.0;
|
||||
|
||||
static constexpr double kMotorPercent = 0.5;
|
||||
|
||||
static constexpr double kMotorSpeed = 100;
|
||||
class CANJaguarTest : public testing::Test {
|
||||
protected:
|
||||
CANJaguar *m_jaguar;
|
||||
@@ -73,6 +78,39 @@ protected:
|
||||
Wait(totalTime / 50.0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* returns the sign of the given number
|
||||
*/
|
||||
int SignNum(double value){
|
||||
return -(value<0) + (value>0);
|
||||
}
|
||||
void InversionTest(float motorValue, float delayTime = kMotorTime){
|
||||
m_jaguar->EnableControl();
|
||||
m_jaguar->SetInverted(false);
|
||||
SetJaguar(delayTime,motorValue);
|
||||
double initialSpeed = m_jaguar->GetSpeed();
|
||||
m_jaguar->Set(0.0);
|
||||
m_jaguar->SetInverted(true);
|
||||
SetJaguar(delayTime,motorValue);
|
||||
double finalSpeed = m_jaguar->GetSpeed();
|
||||
//checks that the motor has changed direction
|
||||
EXPECT_FALSE(SignNum(initialSpeed) == SignNum(finalSpeed))
|
||||
<< "CAN Jaguar did not invert direction positive. Initial speed was: "
|
||||
<< initialSpeed << " Final displacement was: " << finalSpeed
|
||||
<< " Sign of initial displacement was: " << SignNum(initialSpeed)
|
||||
<< " Sign of final displacement was: " << SignNum(finalSpeed);
|
||||
SetJaguar(delayTime,-motorValue);
|
||||
initialSpeed = m_jaguar->GetSpeed();
|
||||
m_jaguar->Set(0.0);
|
||||
m_jaguar->SetInverted(false);
|
||||
SetJaguar(delayTime,-motorValue);
|
||||
finalSpeed = m_jaguar->GetSpeed();
|
||||
EXPECT_FALSE(SignNum(initialSpeed) == SignNum(finalSpeed))
|
||||
<< "CAN Jaguar did not invert direction negative. Initial displacement "
|
||||
"was: " << initialSpeed << " Final displacement was: " << finalSpeed
|
||||
<< " Sign of initial displacement was: " << SignNum(initialSpeed)
|
||||
<< " Sign of final displacement was: " << SignNum(finalSpeed);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -423,3 +461,28 @@ TEST_F(CANJaguarTest, FakeLimitSwitchReverse) {
|
||||
EXPECT_GT(m_jaguar->GetPosition(), initialPosition)
|
||||
<< "CAN Jaguar should have moved forwards while the reverse limit was on";
|
||||
}
|
||||
/**
|
||||
*Tests that inversion works in voltage mode
|
||||
*/
|
||||
TEST_F(CANJaguarTest, InvertingVoltageMode){
|
||||
m_jaguar->SetVoltageMode(CANJaguar::QuadEncoder, 360);
|
||||
m_jaguar->EnableControl();
|
||||
InversionTest(kMotorVoltage);
|
||||
}
|
||||
|
||||
/**
|
||||
*Tests that inversion works in percentMode
|
||||
*/
|
||||
TEST_F(CANJaguarTest, InvertingPercentMode){
|
||||
m_jaguar->SetPercentMode(CANJaguar::QuadEncoder, 360);
|
||||
m_jaguar->EnableControl();
|
||||
InversionTest(kMotorPercent);
|
||||
}
|
||||
/**
|
||||
* Tests that inversion works in SpeedMode
|
||||
*/
|
||||
TEST_F(CANJaguarTest, InvertingSpeedMode){
|
||||
m_jaguar->SetSpeedMode(CANJaguar::QuadEncoder, 360, 0.1f, 0.005f, 0.00f);
|
||||
m_jaguar->EnableControl();
|
||||
InversionTest(kMotorSpeed, kMotorTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user