mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
// Copyright (c) FIRST and other WPILib contributors.
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
#include "Robot.h"
|
|
|
|
#include <frc/DataLogManager.h>
|
|
#include <frc/DriverStation.h>
|
|
#include <frc/smartdashboard/SmartDashboard.h>
|
|
#include <frc2/command/CommandScheduler.h>
|
|
|
|
Robot::Robot() {
|
|
// Start recording to data log
|
|
frc::DataLogManager::Start();
|
|
|
|
// Record DS control and joystick data.
|
|
// Change to `false` to not record joystick data.
|
|
frc::DriverStation::StartDataLog(frc::DataLogManager::GetLog(), true);
|
|
}
|
|
|
|
/**
|
|
* This function is called every 20 ms, no matter the mode. Use
|
|
* this for items like diagnostics that you want to run during disabled,
|
|
* autonomous, teleoperated and test.
|
|
*
|
|
* <p> This runs after the mode specific periodic functions, but before
|
|
* LiveWindow and SmartDashboard integrated updating.
|
|
*/
|
|
void Robot::RobotPeriodic() {
|
|
frc2::CommandScheduler::GetInstance().Run();
|
|
}
|
|
|
|
/**
|
|
* This function is called once each time the robot enters Disabled mode. You
|
|
* can use it to reset any subsystem information you want to clear when the
|
|
* robot is disabled.
|
|
*/
|
|
void Robot::DisabledInit() {}
|
|
|
|
void Robot::DisabledPeriodic() {}
|
|
|
|
/**
|
|
* This autonomous runs the autonomous command selected by your {@link
|
|
* RobotContainer} class.
|
|
*/
|
|
void Robot::AutonomousInit() {
|
|
m_autonomousCommand = m_container.GetAutonomousCommand();
|
|
|
|
if (m_autonomousCommand != nullptr) {
|
|
m_autonomousCommand->Schedule();
|
|
}
|
|
}
|
|
|
|
void Robot::AutonomousPeriodic() {}
|
|
|
|
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 (m_autonomousCommand != nullptr) {
|
|
m_autonomousCommand->Cancel();
|
|
m_autonomousCommand = nullptr;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is called periodically during operator control.
|
|
*/
|
|
void Robot::TeleopPeriodic() {}
|
|
|
|
/**
|
|
* This function is called periodically during test mode.
|
|
*/
|
|
void Robot::TestPeriodic() {}
|
|
|
|
#ifndef RUNNING_FRC_TESTS
|
|
int main() {
|
|
return frc::StartRobot<Robot>();
|
|
}
|
|
#endif
|