3 #include <frc/commands/Scheduler.h> 4 #include <frc/smartdashboard/SmartDashboard.h> 29 void Log(std::string message){
35 for (
auto const& i: input) {
36 std::cout << i << std::endl;
41 double duration = (double)(current - start) / CLOCKS_PER_SEC;
42 std::cout <<
"-- " << duration <<
" since boot --" << std::endl;
54 std::cout <<
" Welcome 5024!" << std::endl;
55 std::cout <<
"-------------------" << std::endl;
56 std::cout <<
"Robot Starting.." << std::endl;
59 Header(
"Creating Subsystems.. ");
74 Header(
"Creating Commands.. ");
89 Header(
"Starting CameraServer.. ");
95 Header(
"Setting camera config.. ");
96 std::ifstream visionSettingsFile(
"/home/lvuser/deploy/config.json");
97 std::string visionSettings((std::istreambuf_iterator<char>(visionSettingsFile)), (std::istreambuf_iterator<char>()));
98 this->
visionCam.SetConfigJson(visionSettings);
99 this->
frontCam.SetConfigJson(visionSettings);
103 Header(
"Resetting Gyro.. ");
104 this->
pGyro =
new AHRS(frc::SPI::kMXP);
105 this->
pGyro->Reset();
109 Header(
"Connecting to telemetry table.. ");
110 this->
ntTelemetry = NetworkTable::GetTable(
"SmartDashboard/Telemetry");
131 float gyroAngle = this->
pGyro->GetAngle();
133 this->
ntTelemetry->PutBoolean(
"DSconn", dsAttached);
134 this->
ntTelemetry->PutBoolean(
"FMSconn", fmsAttached);
150 Header(
"Robot disabling.. ");
187 Header(
"AutonomousInit starting.. ");
191 Header(
"Resetting gyro.. ");
192 this->
pGyro->Reset();
198 frc::Scheduler::GetInstance()->Run();
211 Header(
"Teleop commands starting.. ");
218 frc::Scheduler::GetInstance()->Run();
238 case ClimbManager::ClimbState::kInactive:
243 case ClimbManager::ClimbState::kActive:
247 if (this->
pClimb !=
nullptr) {
252 case ClimbManager::ClimbState::kAuto:
260 Log(
"ClimbManager's climb state was invalid, setting to Inactive");
265 if(this->
driverStation.GetAlliance() == frc::DriverStation::Alliance::kBlue){
272 }
else if(this->
driverStation.GetAlliance() == frc::DriverStation::Alliance::kRed){
287 #ifndef RUNNING_FRC_TESTS 291 Log(
"FATAL!!! Robot program finished!!!");
static CrawlDrive * m_CrawlDrive
Pointer for the DriveTrain.
TriggerDrive * pTriggerDrive
Pointer for the TriggerDrive command.
void SharedInit()
Used to initalize commands for both auto and teleop. (2019 only)
ClimbManager * pClimbManager
Pointer for the climb management command.
An interface command for toggleing the gripper.
void Release()
Release pressure.
void RobotInit() override
Runs once on robot boot.
A subsystem that interfaces with the robot's cCompressor.
static Arm * m_Arm
Pointer for the Arm.
An interface command for driving the robot with an xbox controller.
PullLeg * pPullLeg
Pointer for the leg debugging command.
An interface command for activating the Pull Arm on the robot.
static cCompressor * m_cCompressor
Pointer for the cCompressor.
static Flap * m_Flap
Pointer for the Cargo Flap.
An interface command for activating the Pull Arm on the robot.
A subsystem that interfaces with the drivebase on the robot.
A subsytem that interfaces with the climberbase on the robot.
void DisabledPeriodic() override
Runs in a loop while the robot is disabled.
void TestPeriodic() override
Runs in a loop during test mode.
Operator Interface allows various commands to access the xbox controllers through the DriverStation...
frc::DriverStation & driverStation
DriverStation instance.
An interface command for driving the robot with an xbox controller.
Climb * pClimb
Pointer for the climb control command.
ControlHatchGripper * pControlHatchGripper
Pointer for the finger control command.
void AutonomousPeriodic() override
Runs in a loop during auto.
void vector_print(std::vector< std::string > const &input)
cs::UsbCamera frontCam
Variable for the front camera.
void RobotPeriodic() override
Runs in a loop while the robot is turned on in any mode.
ControlCargo * pControlCargo
Pointer for the cargo control command.
void UpdateRumble(void)
Updates whether the controller should be rumbleing or not.
AutoClimbHigh * pAutoClimbHigh
Pointer for the auto high climb command.
static Slider * m_Slider
Pointer for the Slider.
std::shared_ptr< NetworkTable > ntTelemetry
A pointer to the /SmartDashboard/Telemetry table.
bool IsClimbing()
Returns whether the robot is in the middle of climbing.
frc::XboxController * pJoyOp
An interface command for driving the robot with an xbox controller.
static OI * m_oi
Pointer for the Operator Interface (OI)
std::vector< std::string > logBuffer
PullArm * pPullArm
Pointer for the arm debugging command.
static Piston * m_Piston
Pointer for the Piston.
static HatchGripper * m_HatchGripper
Pointer for the Hatch Gripper.
void Display(clock_t start, clock_t current)
void AutonomousInit() override
Runs once at the start of auto. Usually while the announcer starts counting down from 3...
static DriveTrain * m_DriveTrain
Pointer for the DriveTrain.
void SharedPeriodic()
Runs during teleop and auto.
static ClimbState CurrentClimbState
cs::UsbCamera visionCam
Variable for the Vision camera.
A subsystem that interfaces with the drivebase on the robot.
#define CAMERASERVER_VISION_CAMERA
void Log(std::string message)
Main robot class that is called by wpilib.
void DisabledInit() override
Runs once every time the robot is disabled.
An interface command for driving the robot with an xbox controller.
void Append(LedColour colour)
ControlSlider * pControlSlider
Pointer for the ControlSlider command.
static Leg * m_Leg
Pointer for the Leg.
static Light * m_Light
Pointer for the Light.
void TeleopInit() override
Runs once at the start of teleop when the bell sounds.
ControlCompressor * pControlCompressor
Pointer for the ControlCompressor command.
void TeleopPeriodic() override
Runs in a loop during teleop.
An interface command for toggleing the gripper.
#define CAMERASERVER_DRIVER_CAMERA
ControlLight * pControlLight
Pointer for the vision light control command.
A subsystem that controls the Arm of the robot.