Source code for robot

-import wpilib
+"""
+The entry point for all robot code.
+"""
+
+
+import wpilib
 import constants
 import swerve
 import teleop
@@ -49,6 +54,13 @@ 

Source code for robot

 
 
[docs]class Robot(wpilib.IterativeRobot):
[docs] def robotInit(self): + """ + Perform initialization on robot startup. + + This function is called when the robot code starts after being powered + on; at this point everything within WPILib / NetworkTables / etc. + has been initialized. + """ constants.load_control_config() self.autoPositionSelect = wpilib.SendableChooser() @@ -68,26 +80,69 @@

Source code for robot

         )
[docs] def disabledInit(self): + """ + Called once whenever the robot is disabled. + + This can't, and probably shouldn't, do much. It could be helpful to + reload robot configuration values here (from Preferences, for instance) + for testing purposes. + """ # We don't really _need_ to reload configuration in # every init call-- it's just useful for debugging. # (no need to restart robot code just to load new values) self.drivetrain.load_config_values()
[docs] def disabledPeriodic(self): + """ + Called periodically whenever the robot is disabled. + + To be specific, this function is called whenever a new packet has been + received from the Driver Station. + + This probably shouldn't do much other than update SmartDashboard. + """ pass
[docs] def autonomousInit(self): + """ + Called once when entering Autonomous mode. + """ self.drivetrain.load_config_values() self.auto = Autonomous(self.autoPositionSelect.getSelected())
[docs] def autonomousPeriodic(self): + """ + Called periodically when in Autonomous mode. + + To be specific, this function is called whenever a new packet has been + received from the Driver Station. + + Warning: + This function **must not** block the robot program for more than + a few milliseconds at a time. Blocking will cause all sorts of + problems with the robot and may leave it unresponsive. + """ pass
[docs] def teleopInit(self): + """ + Called once when entering Teleop mode. + """ self.drivetrain.load_config_values() constants.load_control_config()
[docs] def teleopPeriodic(self): + """ + Called periodically when in Teleop mode. + + To be specific, this function is called whenever a new packet has been + received from the Driver Station. + + Warning: + This function **must not** block the robot program for more than + a few milliseconds at a time. Blocking will cause all sorts of + problems with the robot and may leave it unresponsive. + """ # For now: basic driving teleop.drive(self.control_stick, self.drivetrain) self.drivetrain.update_smart_dashboard()
@@ -102,6 +157,9 @@

Source code for robot