|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
NEED Help With turning on the compressor
In C++ I just can't figure out how to turn on the compressor. So I have used this code(which is below). But whenever I turn on the robot and enable it, it just makes this very high pitched sound that only certain younger people can hear on the team. I am sure I have it wired correctly too also I have tried pretty much every wire combination for the compressor that I can think of. This isn't the only problem either, since this code is for a mecanum wheel drive whenever I enable the robot one of the talons turn one of the 4 wheels very slowly while the others remain stationary, though this code work very good without our the compressor code in it (one of the wheels don't drift).
Any help appreciated, though I have already gone through the wpilib screen steps. Any example code from previous years would also be appreciated. Here is the code #include "WPILib.h" /** * This illustrates how to use 4 Talons to drive the robot * Created from SimpleTemplate */ class RobotDemo : public SimpleRobot { RobotDrive *myRobot; // robot drive system Compressor *m_compressor; Joystick stick; // only joystick Talon talon_lf; Talon talon_rf; Talon talon_lr; Talon talon_rr; public: RobotDemo(): //myRobot(1, 2), // these must be initialized in the same order stick(1), // as they are declared above. talon_lf(1), talon_rf(2), talon_lr(3), talon_rr(4) { myRobot = new RobotDrive(talon_lf, talon_lr, talon_rf, talon_rr); myRobot->SetExpiration(0.1); m_compressor = new Compressor(4, 2); m_compressor->Start(); // invert as needed //myRobot->SetInvertedMotor(RobotDrive::kRearLeftMotor, true); myRobot->SetInvertedMotor(RobotDrive::kFrontRightMotor, true); //myRobot->SetInvertedMotor(RobotDrive::kFrontLeftMotor, true); myRobot->SetInvertedMotor(RobotDrive::kRearRightMotor, true); } // destructor. Added by brian ~RobotDemo() { delete myRobot; delete m_compressor; } /** * Drive left & right motors for 2 seconds then stop */ void Autonomous() { myRobot->SetSafetyEnabled(false); //myRobot->Drive(-0.5, 0.0); // drive forwards half speed //Wait(1.0); // for 2 seconds myRobot->Drive(0.0, 0.0); // stop robot } /** * Runs the motors with arcade steering. */ void OperatorControl() { printf("4 Talon Test\n"); myRobot->SetSafetyEnabled(true); while (IsOperatorControl()) { // arcade drive with one stick //myRobot->ArcadeDrive(stick); // drive with arcade style // macadum drive float gyroAngle = 0.0; // we don't have a gyro connected myRobot->MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick.GetZ(), gyroAngle); Wait(0.005); // wait for a motor update time } } /** * Runs during test mode */ void Test() { } }; START_ROBOT_CLASS(RobotDemo); This is the end of the code |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|