Added PacGoat code for C++.

Change-Id: I4fd19fbdc65c25c5bbcdce937a31bc6fa1c11cb4
This commit is contained in:
Alex Henning
2014-06-24 16:54:17 -07:00
parent 0d62d0985a
commit c7e17b8e35
47 changed files with 1659 additions and 4 deletions

View File

@@ -0,0 +1,90 @@
#include "Robot.h"
#include "Commands/DriveAndShootAutonomous.h"
#include "Commands/DriveForward.h"
DriveTrain* Robot::drivetrain = NULL;
Pivot* Robot::pivot = NULL;
Collector* Robot::collector = NULL;
Shooter* Robot::shooter = NULL;
Pneumatics* Robot::pneumatics = NULL;
OI* Robot::oi = NULL;
void Robot::RobotInit() {
drivetrain = new DriveTrain();
pivot = new Pivot();
collector = new Collector();
shooter = new Shooter();
pneumatics = new Pneumatics();
// Show what command your subsystem is running on the SmartDashboard
SmartDashboard::PutData(drivetrain);
SmartDashboard::PutData(pivot);
SmartDashboard::PutData(collector);
SmartDashboard::PutData(shooter);
SmartDashboard::PutData(pneumatics);
oi = new OI();
autonomousCommand = new DriveAndShootAutonomous();
lw = LiveWindow::GetInstance();
// instantiate the command used for the autonomous period
autoChooser = new SendableChooser();
autoChooser->AddDefault("Drive and Shoot", new DriveAndShootAutonomous());
autoChooser->AddObject("Drive Forward", new DriveForward());
SmartDashboard::PutData("Auto Mode", autoChooser);
pneumatics->Start(); // Pressurize the pneumatics.
}
void Robot::AutonomousInit() {
autonomousCommand = (Command*) autoChooser->GetSelected();
autonomousCommand->Start();
}
void Robot::AutonomousPeriodic() {
Scheduler::GetInstance()->Run();
Log();
}
void Robot::TeleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (autonomousCommand != NULL) {
autonomousCommand->Cancel();
}
std::cout << "Starting Teleop" << std::endl;
}
void Robot::TeleopPeriodic() {
Scheduler::GetInstance()->Run();
Log();
}
void Robot::TestPeriodic() {
lw->Run();
}
void Robot::DisabledInit() {
shooter->Unlatch();
}
void Robot::DisabledPeriodic() {
Log();
}
/**
* Log interesting values to the SmartDashboard.
*/
void Robot::Log() {
Robot::pneumatics->WritePressure();
SmartDashboard::PutNumber("Pivot Pot Value", pivot->GetAngle());
SmartDashboard::PutNumber("Left Distance", drivetrain->GetLeftEncoder()->GetDistance());
SmartDashboard::PutNumber("Right Distance", drivetrain->GetRightEncoder()->GetDistance());
}
START_ROBOT_CLASS(Robot);