void UpdateDashboard() { float r = 0.00001 * i; SmartDashboard::PutNumber("State", currentState + r); SmartDashboard::PutNumber("PID Turn Error", turnController->GetError() + r); SmartDashboard::PutNumber("PID Target", turnController->GetSetpoint() + r); // SmartDashboard::PutBoolean("Straight", straight); SmartDashboard::PutData("test", turnController); SmartDashboard::PutNumber("Yaw:", ahrs->GetYaw() + r); SmartDashboard::PutNumber("Roll:", ahrs->GetRoll() + r); SmartDashboard::PutNumber("Pitch", ahrs->GetPitch() + r); SmartDashboard::PutNumber("Scissor 1", pdp->GetCurrent(1) + r); SmartDashboard::PutNumber("Scissor 2", pdp->GetCurrent(2) + r); SmartDashboard::PutNumber("Left Drive 1", pdp->GetCurrent(12) + r); SmartDashboard::PutNumber("Left Drive 2", pdp->GetCurrent(13) + r); SmartDashboard::PutNumber("Right Drive 1", pdp->GetCurrent(14) + r); SmartDashboard::PutNumber("Right Drive 2", pdp->GetCurrent(15) + r); SmartDashboard::PutNumber("Constant Lift", constantLift); SmartDashboard::PutNumber("Rotate Rate", rotateRate + r); i = (i + 1) % 2; printf("2.1"); // .PutLong("test1.2", 1337); printf("2.2"); // mqServer.PutDouble("test",DriverStation::GetInstance().GetMatchTime()); printf("2.3"); // mqServer.PutString("test1.1","YOLO_SWAGINS"); printf("2.4"); // SmartDashboard::PutString("test1.2", mqServer.GetString("test1.1")); // SmartDashboard::PutNumber("test1", mqServer.GetDouble("test")); // SmartDashboard::PutNumber("test1.3", mqServer.GetLong("test1.2")); // SmartDashboard::PutNumber("test2", DriverStation::GetInstance().GetMatchTime()); }
/** * Drive based upon joystick inputs, and automatically control * motors if the robot begins tipping. */ void OperatorControl() { robotDrive.SetSafetyEnabled(false); while (IsOperatorControl() && IsEnabled()) { double xAxisRate = stick.GetX(); double yAxisRate = stick.GetY(); double pitchAngleDegrees = ahrs->GetPitch(); double rollAngleDegrees = ahrs->GetRoll(); if ( !autoBalanceXMode && (fabs(pitchAngleDegrees) >= fabs(kOffBalanceThresholdDegrees))) { autoBalanceXMode = true; } else if ( autoBalanceXMode && (fabs(pitchAngleDegrees) <= fabs(kOnBalanceThresholdDegrees))) { autoBalanceXMode = false; } if ( !autoBalanceYMode && (fabs(pitchAngleDegrees) >= fabs(kOffBalanceThresholdDegrees))) { autoBalanceYMode = true; } else if ( autoBalanceYMode && (fabs(pitchAngleDegrees) <= fabs(kOnBalanceThresholdDegrees))) { autoBalanceYMode = false; } // Control drive system automatically, // driving in reverse direction of pitch/roll angle, // with a magnitude based upon the angle if ( autoBalanceXMode ) { double pitchAngleRadians = pitchAngleDegrees * (M_PI / 180.0); xAxisRate = sin(pitchAngleRadians) * -1; } if ( autoBalanceYMode ) { double rollAngleRadians = rollAngleDegrees * (M_PI / 180.0); yAxisRate = sin(rollAngleRadians) * -1; } try { // Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation. robotDrive.MecanumDrive_Cartesian(xAxisRate, yAxisRate,stick.GetZ()); } catch (std::exception ex ) { std::string err_string = "Drive system error: "; err_string += ex.what(); DriverStation::ReportError(err_string.c_str()); } Wait(0.005); // wait 5ms to avoid hogging CPU cycles } }