mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21: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:
@@ -204,7 +204,7 @@ void CANJaguar::InitCANJaguar()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_isInverted = false;
|
||||
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
|
||||
LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, this);
|
||||
}
|
||||
@@ -315,13 +315,13 @@ void CANJaguar::Set(float outputValue, uint8_t syncGroup)
|
||||
messageID = LM_API_VOLT_T_SET;
|
||||
if (outputValue > 1.0) outputValue = 1.0;
|
||||
if (outputValue < -1.0) outputValue = -1.0;
|
||||
dataSize = packPercentage(dataBuffer, outputValue);
|
||||
dataSize = packPercentage(dataBuffer, (m_isInverted ? -outputValue : outputValue));
|
||||
}
|
||||
break;
|
||||
case kSpeed:
|
||||
{
|
||||
messageID = LM_API_SPD_T_SET;
|
||||
dataSize = packFXP16_16(dataBuffer, outputValue);
|
||||
dataSize = packFXP16_16(dataBuffer, (m_isInverted ? -outputValue : outputValue));
|
||||
}
|
||||
break;
|
||||
case kPosition:
|
||||
@@ -339,7 +339,7 @@ void CANJaguar::Set(float outputValue, uint8_t syncGroup)
|
||||
case kVoltage:
|
||||
{
|
||||
messageID = LM_API_VCOMP_T_SET;
|
||||
dataSize = packFXP8_8(dataBuffer, outputValue);
|
||||
dataSize = packFXP8_8(dataBuffer, (m_isInverted ? -outputValue : outputValue));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -2118,6 +2118,15 @@ void CANJaguar::StopLiveWindowMode()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* Only works in PercentVbus, speed, and Voltage modes
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void CANJaguar::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
|
||||
std::string CANJaguar::GetSmartDashboardType() const
|
||||
{
|
||||
return "Speed Controller";
|
||||
|
||||
@@ -23,6 +23,7 @@ CANTalon::CANTalon(int deviceNumber)
|
||||
{
|
||||
ApplyControlMode(m_controlMode);
|
||||
m_impl->SetProfileSlotSelect(m_profile);
|
||||
m_isInverted = false;
|
||||
}
|
||||
/**
|
||||
* Constructor for the CANTalon device.
|
||||
@@ -131,7 +132,7 @@ void CANTalon::Set(float value, uint8_t syncGroup)
|
||||
switch(m_controlMode) {
|
||||
case CANSpeedController::kPercentVbus:
|
||||
{
|
||||
m_impl->Set(value);
|
||||
m_impl->Set(m_isInverted ? -value : value);
|
||||
status = CTR_OKAY;
|
||||
}
|
||||
break;
|
||||
@@ -143,12 +144,12 @@ void CANTalon::Set(float value, uint8_t syncGroup)
|
||||
case CANSpeedController::kVoltage:
|
||||
{
|
||||
// Voltage is an 8.8 fixed point number.
|
||||
int volts = int(value * 256);
|
||||
int volts = int((m_isInverted ? value: -value) * 256);
|
||||
status = m_impl->SetDemand(volts);
|
||||
}
|
||||
break;
|
||||
case CANSpeedController::kSpeed:
|
||||
status = m_impl->SetDemand(value);
|
||||
status = m_impl->SetDemand(m_isInverted ? -value : value);
|
||||
break;
|
||||
case CANSpeedController::kPosition:
|
||||
status = m_impl->SetDemand(value);
|
||||
@@ -1291,7 +1292,14 @@ void CANTalon::GetDescription(char *desc) const
|
||||
{
|
||||
sprintf(desc, "CANTalon ID %d", m_deviceNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* Only works in PercentVbus, speed, and Voltage modes
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void CANTalon::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Common interface for stopping the motor
|
||||
* Part of the MotorSafety interface
|
||||
|
||||
@@ -30,6 +30,7 @@ void Jaguar::InitJaguar()
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
|
||||
m_isInverted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +57,7 @@ Jaguar::~Jaguar()
|
||||
*/
|
||||
void Jaguar::Set(float speed, uint8_t syncGroup)
|
||||
{
|
||||
SetSpeed(speed);
|
||||
SetSpeed(m_isInverted ? -speed : speed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,13 @@ void Jaguar::Disable()
|
||||
{
|
||||
SetRaw(kPwmDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void Jaguar::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
|
||||
@@ -57,10 +57,6 @@ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel)
|
||||
InitRobotDrive();
|
||||
m_rearLeftMotor = new Talon(leftMotorChannel);
|
||||
m_rearRightMotor = new Talon(rightMotorChannel);
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
SetLeftRightMotorOutputs(0.0, 0.0);
|
||||
m_deleteSpeedControllers = true;
|
||||
}
|
||||
@@ -83,10 +79,6 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
|
||||
m_rearRightMotor = new Talon(rearRightMotor);
|
||||
m_frontLeftMotor = new Talon(frontLeftMotor);
|
||||
m_frontRightMotor = new Talon(frontRightMotor);
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
SetLeftRightMotorOutputs(0.0, 0.0);
|
||||
m_deleteSpeedControllers = true;
|
||||
}
|
||||
@@ -110,10 +102,6 @@ RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor)
|
||||
}
|
||||
m_rearLeftMotor = leftMotor;
|
||||
m_rearRightMotor = rightMotor;
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
m_deleteSpeedControllers = false;
|
||||
}
|
||||
|
||||
@@ -122,10 +110,6 @@ RobotDrive::RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor)
|
||||
InitRobotDrive();
|
||||
m_rearLeftMotor = &leftMotor;
|
||||
m_rearRightMotor = &rightMotor;
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
m_deleteSpeedControllers = false;
|
||||
}
|
||||
|
||||
@@ -150,10 +134,6 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLef
|
||||
m_rearLeftMotor = rearLeftMotor;
|
||||
m_frontRightMotor = frontRightMotor;
|
||||
m_rearRightMotor = rearRightMotor;
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
m_deleteSpeedControllers = false;
|
||||
}
|
||||
|
||||
@@ -165,10 +145,6 @@ RobotDrive::RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLef
|
||||
m_rearLeftMotor = &rearLeftMotor;
|
||||
m_frontRightMotor = &frontRightMotor;
|
||||
m_rearRightMotor = &rearRightMotor;
|
||||
for (int32_t i=0; i < kMaxNumberOfMotors; i++)
|
||||
{
|
||||
m_invertedMotors[i] = 1;
|
||||
}
|
||||
m_deleteSpeedControllers = false;
|
||||
}
|
||||
|
||||
@@ -508,10 +484,10 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation, float
|
||||
|
||||
Normalize(wheelSpeeds);
|
||||
|
||||
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_invertedMotors[kFrontRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(wheelSpeeds[kRearLeftMotor] * m_invertedMotors[kRearLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(wheelSpeeds[kRearRightMotor] * m_invertedMotors[kRearRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(wheelSpeeds[kRearLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(wheelSpeeds[kRearRightMotor] * m_maxOutput, m_syncGroup);
|
||||
|
||||
if (m_syncGroup != 0)
|
||||
{
|
||||
@@ -558,10 +534,10 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction, float rota
|
||||
|
||||
Normalize(wheelSpeeds);
|
||||
|
||||
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_invertedMotors[kFrontRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(wheelSpeeds[kRearLeftMotor] * m_invertedMotors[kRearLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(wheelSpeeds[kRearRightMotor] * m_invertedMotors[kRearRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontLeftMotor->Set(wheelSpeeds[kFrontLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontRightMotor->Set(wheelSpeeds[kFrontRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(wheelSpeeds[kRearLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(wheelSpeeds[kRearRightMotor] * m_maxOutput, m_syncGroup);
|
||||
|
||||
if (m_syncGroup != 0)
|
||||
{
|
||||
@@ -599,12 +575,12 @@ void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput)
|
||||
wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL);
|
||||
|
||||
if (m_frontLeftMotor != NULL)
|
||||
m_frontLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kRearLeftMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
|
||||
m_rearLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
|
||||
|
||||
if (m_frontRightMotor != NULL)
|
||||
m_frontRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kFrontRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kRearRightMotor] * m_maxOutput, m_syncGroup);
|
||||
m_frontRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
|
||||
m_rearRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
|
||||
|
||||
if (m_syncGroup != 0)
|
||||
{
|
||||
@@ -679,7 +655,12 @@ void RobotDrive::SetInvertedMotor(MotorType motor, bool isInverted)
|
||||
wpi_setWPIError(InvalidMotorIndex);
|
||||
return;
|
||||
}
|
||||
m_invertedMotors[motor] = isInverted ? -1 : 1;
|
||||
switch(motor){
|
||||
case kFrontLeftMotor: m_frontLeftMotor -> SetInverted(isInverted); break;
|
||||
case kFrontRightMotor: m_frontRightMotor -> SetInverted(isInverted); break;
|
||||
case kRearLeftMotor: m_rearLeftMotor -> SetInverted(isInverted); break;
|
||||
case kRearRightMotor: m_rearRightMotor -> SetInverted(isInverted); break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ void Talon::InitTalon() {
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
|
||||
m_isInverted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ Talon::~Talon()
|
||||
*/
|
||||
void Talon::Set(float speed, uint8_t syncGroup)
|
||||
{
|
||||
SetSpeed(speed);
|
||||
SetSpeed(m_isInverted ? -speed : speed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +78,13 @@ void Talon::Disable()
|
||||
{
|
||||
SetRaw(kPwmDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void Talon::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ void TalonSRX::InitTalonSRX() {
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("TalonSRX", GetChannel(), this);
|
||||
m_isInverted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,13 @@ void TalonSRX::Disable()
|
||||
{
|
||||
SetRaw(kPwmDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void TalonSRX::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
|
||||
@@ -33,6 +33,7 @@ void Victor::InitVictor() {
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
|
||||
HALReport(HALUsageReporting::kResourceType_Victor, GetChannel());
|
||||
m_isInverted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +60,7 @@ Victor::~Victor()
|
||||
*/
|
||||
void Victor::Set(float speed, uint8_t syncGroup)
|
||||
{
|
||||
SetSpeed(speed);
|
||||
SetSpeed(m_isInverted ? -speed: speed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +80,13 @@ void Victor::Disable()
|
||||
{
|
||||
SetRaw(kPwmDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void Victor::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Write out the PID value as seen in the PIDOutput base object.
|
||||
*
|
||||
|
||||
@@ -31,6 +31,7 @@ void VictorSP::InitVictorSP() {
|
||||
|
||||
HALReport(HALUsageReporting::kResourceType_VictorSP, GetChannel());
|
||||
LiveWindow::GetInstance()->AddActuator("VictorSP", GetChannel(), this);
|
||||
m_isInverted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ VictorSP::~VictorSP()
|
||||
*/
|
||||
void VictorSP::Set(float speed, uint8_t syncGroup)
|
||||
{
|
||||
SetSpeed(speed);
|
||||
SetSpeed(m_isInverted ? -speed: speed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +70,13 @@ float VictorSP::Get() const
|
||||
{
|
||||
return GetSpeed();
|
||||
}
|
||||
|
||||
/**
|
||||
* common interface for inverting direction of a speed controller
|
||||
* @param isInverted The state of inversion true is inverted
|
||||
*/
|
||||
void VictorSP::SetInverted(bool isInverted){
|
||||
m_isInverted = isInverted;
|
||||
}
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user