本文整理汇总了C++中Talon::SetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Talon::SetSpeed方法的具体用法?C++ Talon::SetSpeed怎么用?C++ Talon::SetSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Talon
的用法示例。
在下文中一共展示了Talon::SetSpeed方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void AutonomousType4() {
SmartDashboard::PutString("STATUS:", "STARTING AUTO 4");
//Lift, turn, drive
chainLift.SetSpeed(0.5);
while (midPoint.Get() && maxUp.Get()) {
}
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Polar(0, 0, 0.3);
if (WaitF(2.5))
return;
robotDrive.MecanumDrive_Polar(0.25, 0, 0);
if (WaitF(5.6))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0.3);
if (WaitF(2))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0);
//chainLift.SetSpeed(-0.4);
//while (maxDown.Get() && IsAutonomous()) {
//}
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Polar(0, 0, 0);
SmartDashboard::PutString("STATUS:", "AUTO 4 COMPLETE");
}
示例2: AutonomousInit
//Choose which auto to use
void AutonomousInit() {
chainLift.SetSpeed(0);
canGrabber.SetSpeed(0);
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
SmartDashboard::PutString("STATUS:", "STARTING AUTO");
robotDrive.SetSafetyEnabled(false);
chainLift.SetSafetyEnabled(false);
SmartDashboard::PutBoolean("Auto switch A: ", autoSwitch1.Get());
SmartDashboard::PutBoolean("Auto switch B: ", autoSwitch2.Get());
//Select auto type
if (autoSwitch1.Get()) {
if (autoSwitch2.Get())
AutonomousType4();
else
//1 on 2 grab n back
AutonomousType8();
} else {
if (autoSwitch2.Get())
//1 off, 2 on: grab n turn
AutonomousType10();
else {
SmartAutoPicker();
}
//Do Nothing
}
}
示例3: IsEnabled
//Grab first yellow, back up to auto zone, DON'T DROP
void AutonomousType12() {
SmartDashboard::PutString("STATUS:", "STARTING AUTO 12");
chainLift.SetSpeed(0.5);
while (IsAutonomous() && IsEnabled() && maxUp.Get() && midPoint.Get()) {
}
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Cartesian(0, 0.4, 0);
if (WaitF(3))
return;
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
SmartDashboard::PutString("STATUS:", "AUTO 12 COMPLETE");
}
示例4: TeleopPeriodic
virtual void TeleopPeriodic() {
rightDrive->SetSpeed(-(Driver->GetRawAxis(2)));
leftDrive->SetSpeed((Driver->GetRawAxis(5)));
shooterFWD->SetSpeed(-(Operator->GetRawAxis(2)));
shooterRear->SetSpeed(-(Operator->GetRawAxis(2)));
//shoioter angle
if(Operator->GetRawButton(5))
{
cout<<"Relay 1 forward"<<endl;
shooterAngle->Set(Relay::kForward);
}
if(Operator->GetRawButton(6))
{
cout<<"Relay 1 Reverse"<<endl;
shooterAngle->Set(Relay::kReverse);
}
//Fire button
if(Operator->GetRawButton(1))
{
cout<<"Relay 1 forward"<<endl;
shooterFire->Set(Relay::kForward);
}
if(Operator->GetRawButton(2))
{
cout<<"Relay 1 Reverse"<<endl;
shooterFire->Set(Relay::kReverse);
}
if(CompressorSwitch->Get() == 0){
CompressorRelay->Set(Relay::kForward);
}else{
CompressorRelay->Set(Relay::kOff);
}
//if(canPDP == 0){
// cout << "NULL" << endl;
//}else{
//canPDP->GetVoltage(Voltage) ;
//cout << "0" << endl;
//}
}
示例5: IsAutonomous
void AutonomousType2() { //Pick tote and bin, move to auto zone
SmartDashboard::PutString("STATUS:", "STARTING AUTO 2");
chainLift.SetSpeed(0.5);
while (midPoint.Get() && maxUp.Get()) {
}
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Polar(0.3, 0, 0);
if (WaitF(1.6))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0);
chainLift.SetSpeed(-0.2);
if (WaitF(0.8))
return;
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Polar(-0.3, 0, 0);
if (WaitF(1.6))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0);
chainLift.SetSpeed(-0.3);
while (maxDown.Get()) {
}
chainLift.SetSpeed(0);
robotDrive.MecanumDrive_Polar(0.2, 0, 0);
if (WaitF(2))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0);
chainLift.SetSpeed(0.4);
while (midPoint.Get() && maxUp.Get()) {
}
chainLift.SetSpeed(0);
//turn 90 deg
robotDrive.MecanumDrive_Polar(0, 0, -0.3);
if (WaitF(4))
return;
robotDrive.MecanumDrive_Polar(0.5, 0, 0);
if (WaitF(2.5))
return;
robotDrive.MecanumDrive_Polar(0, 0, 0);
chainLift.SetSpeed(-0.4);
while (maxDown.Get() && IsAutonomous()) {
}
chainLift.SetSpeed(0);
SmartDashboard::PutString("STATUS:", "AUTO 2 COMPLETE");
}
示例6: CupidShuffle
void CupidShuffle() {
SmartDashboard::PutString("STATUS:", "TIME 2 GET DOWWWWWWN");
//Tempo of song
static double tempo = 0.41666666667;
//Repeat # of times
for (int j = 0; j < 10 && IsAutonomous() && IsEnabled(); j++) {
//to the left to the left to the left to the left
for (int k = 0; k < 4; k++) {
robotDrive.MecanumDrive_Cartesian(-0.2, 0, 0);
Wait(tempo);
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
Wait(tempo);
}
//to the right to the right to the right
for (int k = 0; k < 4; k++) {
robotDrive.MecanumDrive_Cartesian(0.2, 0, 0);
Wait(tempo);
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
Wait(tempo);
}
//kick kick kick kick
for (int k = 0; k < 4; k++) {
chainLift.SetSpeed(0.3);
Wait(tempo);
chainLift.SetSpeed(-0.3);
Wait(tempo);
}
chainLift.SetSpeed(0);
//walk it by uself (turn 90)
robotDrive.MecanumDrive_Polar(0, 0, 0.3);
Wait(tempo * 8);
}
SmartDashboard::PutString("STATUS:", "GIT GUD");
}
示例7: AutonomousInit
virtual void AutonomousInit() {
shooterAngle->Set(Relay::kForward);
rightDrive->SetSpeed(0);
leftDrive->SetSpeed(0);
shooterFWD->SetSpeed(1);
shooterRear->SetSpeed(1);
sleep(4);
cout << "BEGIN" << endl;
shooterFire->Set(Relay::kForward);
sleep(1);
shooterFire->Set(Relay::kReverse);
sleep(1);
//nanosleep(6);
shooterFire->Set(Relay::kForward);
sleep(1);
shooterFire->Set(Relay::kReverse);
sleep(1);
shooterFire->Set(Relay::kForward);
sleep(1);
shooterFire->Set(Relay::kReverse);
sleep(1);
shooterFire->Set(Relay::kForward);
sleep(1);
shooterFire->Set(Relay::kReverse);
sleep(2);
shooterFWD->SetSpeed(0);
shooterRear->SetSpeed(0);
sleep(2);
shooterAngle->Set(Relay::kReverse);
cout << "END" << endl;
}
示例8: Disabled
void Disabled() {
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
chainLift.SetSpeed(0);
SmartDashboard::PutString("STATUS:", "DISABLED");
}
示例9: TeleopPeriodic
void TeleopPeriodic() {
if(tick==10) if (ds->IsSysBrownedOut()) {
ds->ReportError("[ERROR] BROWNOUT DETECTED!!");
}
if(tick == 15) if (!ds->IsNewControlData()) {
ds->ReportError(
"[ERROR] NO DATA FROM DRIVER STATION IN THIS TICK!");
}
if(tick==20) if (!ds->IsDSAttached()) {
ds->ReportError("[ERROR] DRIVER STATION NOT DETECTED!");
}
if (stick.GetRawButton(10))
zeroSanics();
if (stick.GetRawButton(8)) {
leftIRZero = 0;
rightIRZero = 0;
}
tick++;
if (liftStick.GetRawButton(2)) {
double canScale = liftStick.GetRawAxis(2);
canScale += 1;
canScale = 2 - canScale;
canScale /= 2;
canGrabber.SetSpeed(canScale);
} else if (liftStick.GetRawButton(3)) {
double canScale = liftStick.GetRawAxis(2);
canScale += 1;
canScale = 2 - canScale;
canScale /= 2;
canGrabber.SetSpeed(-canScale);
} else
canGrabber.SetSpeed(0);
double speed;
//Calculate scalar to use for POV/Adjusted drive
double scale = stick.GetRawAxis(3);
scale += 1;
scale = 2 - scale;
scale /= 2;
//Use pov/hat switch for movement if enabled
if (stick.GetRawButton(1) && stick.GetRawButton(2)) {
AutomaticLineup();
} else if (stick.GetRawButton(1)) {
double leftVolts = leftIR.GetAverageVoltage() - leftIRZero;
double rightVolts = rightIR.GetAverageVoltage() - leftIRZero;
if (rightVolts + VOLTAGE_TOLERANCE > leftVolts
&& rightVolts - VOLTAGE_TOLERANCE < leftVolts) {
robotDrive.MecanumDrive_Cartesian(0, 0, 0);
} else if (rightVolts > leftVolts)
robotDrive.MecanumDrive_Cartesian(0, 0, 0.2);
else if (leftVolts > rightVolts)
robotDrive.MecanumDrive_Cartesian(0, 0, -0.2);
} else if (stick.GetRawButton(6)) {
//Rotate
robotDrive.MecanumDrive_Polar(0, 0, scale);
} else if (stick.GetRawButton(5)) {
//Rotate
robotDrive.MecanumDrive_Polar(0, 0, -scale);
} else if (stick.GetPOV(0) != -1) {
//If POV moved, move polar (getPOV returns an angle in degrees)
robotDrive.MecanumDrive_Polar(scale, -stick.GetPOV(0), 0);
} else if (stick.GetRawButton(2)) {
//Drive with scalar
robotDrive.MecanumDrive_Cartesian(-stick.GetRawAxis(0) * scale,
stick.GetRawAxis(1) * scale, stick.GetRawAxis(2) * scale);
} else {
//Drive normally
robotDrive.MecanumDrive_Cartesian(-stick.GetX(), stick.GetY(),
stick.GetZ());
}
speed = -liftStick.GetY();
//bool canGoUp = maxUp.Get();
bool canGoUp = true;
//bool canGoDown = maxDown.Get();
bool canGoDown = true;
//If at a limit switch and moving in that direction, stop
if (speed > 0 && !canGoUp)
speed = 0;
if (speed < 0 && !canGoDown)
speed = 0;
chainLift.SetSpeed(speed);
if (tick >50) {
if (SmartDashboard::GetBoolean("Smart Dashboard Enabled")) {
//Smart Dash outputs
//SmartDashboard::PutNumber("X Acceleration: ", accel.GetX());
//SmartDashboard::PutNumber("Y Acceleration: ", accel.GetY());
//SmartDashboard::PutNumber("Z Acceleration: ", accel.GetZ());
SmartDashboard::PutBoolean("Switch 1: (up)", maxUp.Get());
SmartDashboard::PutBoolean("Switch 2: (down)", maxDown.Get());
SmartDashboard::PutBoolean("Switch 3: (mid)", midPoint.Get());
//.........这里部分代码省略.........