2014-06-24 16:54:17 -07:00
|
|
|
|
|
|
|
|
#include "Robot.h"
|
|
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
std::shared_ptr<DriveTrain> Robot::drivetrain;
|
|
|
|
|
std::shared_ptr<Pivot> Robot::pivot;
|
|
|
|
|
std::shared_ptr<Collector> Robot::collector;
|
|
|
|
|
std::shared_ptr<Shooter> Robot::shooter;
|
|
|
|
|
std::shared_ptr<Pneumatics> Robot::pneumatics;
|
2014-06-24 16:54:17 -07:00
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
std::unique_ptr<OI> Robot::oi;
|
2014-06-24 16:54:17 -07:00
|
|
|
|
|
|
|
|
void Robot::RobotInit() {
|
2015-07-24 19:19:40 -04:00
|
|
|
drivetrain.reset(new DriveTrain());
|
|
|
|
|
pivot.reset(new Pivot());
|
|
|
|
|
collector.reset(new Collector());
|
|
|
|
|
shooter.reset(new Shooter());
|
|
|
|
|
pneumatics.reset(new Pneumatics());
|
2014-06-24 16:54:17 -07:00
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
oi.reset(new OI());
|
2014-06-24 16:54:17 -07:00
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
// Show what command your subsystem is running on the SmartDashboard
|
|
|
|
|
SmartDashboard::PutData(drivetrain.get());
|
|
|
|
|
SmartDashboard::PutData(pivot.get());
|
|
|
|
|
SmartDashboard::PutData(collector.get());
|
|
|
|
|
SmartDashboard::PutData(shooter.get());
|
|
|
|
|
SmartDashboard::PutData(pneumatics.get());
|
2014-06-24 16:54:17 -07:00
|
|
|
|
|
|
|
|
// instantiate the command used for the autonomous period
|
2015-07-24 19:19:40 -04:00
|
|
|
autoChooser.AddDefault("Drive and Shoot", driveAndShootAuto.get());
|
|
|
|
|
autoChooser.AddObject("Drive Forward", driveForwardAuto.get());
|
|
|
|
|
SmartDashboard::PutData("Auto Mode", &autoChooser);
|
2014-06-24 16:54:17 -07:00
|
|
|
|
|
|
|
|
pneumatics->Start(); // Pressurize the pneumatics.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Robot::AutonomousInit() {
|
2015-07-24 19:19:40 -04:00
|
|
|
autonomousCommand = (Command *)autoChooser.GetSelected();
|
2014-06-24 16:54:17 -07:00
|
|
|
autonomousCommand->Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Robot::AutonomousPeriodic() {
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
Scheduler::GetInstance()->Run();
|
2014-06-24 16:54:17 -07:00
|
|
|
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.
|
2015-07-24 19:19:40 -04:00
|
|
|
if (autonomousCommand != nullptr) {
|
2014-06-24 16:54:17 -07:00
|
|
|
autonomousCommand->Cancel();
|
|
|
|
|
}
|
|
|
|
|
std::cout << "Starting Teleop" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Robot::TeleopPeriodic() {
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
Scheduler::GetInstance()->Run();
|
2014-06-24 16:54:17 -07:00
|
|
|
Log();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Robot::TestPeriodic() {
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
LiveWindow::GetInstance()->Run();
|
2014-06-24 16:54:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
START_ROBOT_CLASS(Robot)
|