def robotInit(self): """ This function is run when the robot is first started up and should be used for any initialization code. """ # Initialize the subsystems self.drivetrain = DriveTrain(self) self.collector = Collector(self) self.shooter = Shooter(self) self.pneumatics = Pneumatics(self) self.pivot = Pivot(self) wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.collector) wpilib.SmartDashboard.putData(self.shooter) wpilib.SmartDashboard.putData(self.pneumatics) wpilib.SmartDashboard.putData(self.pivot) # This MUST be here. If the OI creates Commands (which it very likely # will), constructing it during the construction of CommandBase (from # which commands extend), subsystems are not guaranteed to be # yet. Thus, their requires() statements may grab null pointers. Bad # news. Don't move it. self.oi = OI(self) #instantiate the command used for the autonomous period self.autoChooser = wpilib.SendableChooser() self.autoChooser.addDefault("Drive and Shoot", DriveAndShootAutonomous(self)) self.autoChooser.addObject("Drive Forward", DriveForward(self)) wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser) self.autonomousCommand = None # Pressurize the pneumatics self.pneumatics.start()
def robotInit(self): '''Initialize all subsystems.''' self.drivetrain = DriveTrain(self) self.shooter = Shooter(self) self.intake_sub = Intake_Sub(self) self.shifter = Shifter(self) self.blocker = Blocker(self) self.climbmotors = Climbmotors(self) self.climbpistons = Climbpistons(self) self.agitator = Agitator(self) wpilib.SmartDashboard.putStringArray( "Auto List", ["Far Left", "Far Right", "Center", "Center Low Goal", "Default"]) """self.autoChooser.addOption("Far Left", AutoFarLeft) self.autoChooser.addOption("Far Right", AutoFarRight) self.autoChooser.addOption("Center", AutoShoot) self.autoChooser.addOption("Center Low Goal", AutoCenterLowGoal) self.autoChooser.setDefaultOption("Default", AutoBackupShoot) wpilib.SmartDashboard.putData('Select Autonomous...', self.autoChooser)""" # The "front" of the robot (which end is facing forward) self.front = -1 self.oi = OI(self)
def robotInit(self): '''Initialize all subsystems.''' self.drivetrain = DriveTrain(self) self.shooter = Shooter(self) self.intake_sub = Intake_Sub(self) self.shifter = Shifter(self) # The "front" of the robot (which end is facing forward) self.front = -1 self.oi = OI(self)
def robotInit(self): '''Initialize all subsystems.''' self.drivetrain = DriveTrain(self) self.shooter = Shooter(self) self.intake_sub = Intake_Sub(self) self.shifter = Shifter(self) self.blocker = Blocker(self) self.climbmotors = Climbmotors(self) self.climbpistons = Climbpistons(self) self.agitator = Agitator(self) self.autoChooser = wpilib.SendableChooser() self.autoChooser.setDefaultOption("Drive", DriveAutonomous(self)) # The "front" of the robot (which end is facing forward) self.front = -1 self.oi = OI(self)
def robotInit(self): """Robot-wide initialization code should go here""" super().__init__() if self.isReal(): # use the real drive train self.drivetrain = DriveTrain(self) else: # use the simulated drive train #self.drivetrain = DriveTrainSim(self) self.drivetrain = DriveTrainSim(self) self.shooter = Shooter(self) self.vision = Vision() # oi MUST be created after all other subsystems since it uses them self.oi = OI(self) self.enabled_time = 0 # something is especially weird with the sim about this needing to be initialized in robotInit self.autonomousCommand = None # initialize the placeholder command for autonomous
def robotInit(self): Command.getRobot = lambda _: self wpilib.CameraServer.launch('vision.py:main') NetworkTables.initialize(server='10.56.54.2') self.rf_motor = ctre.WPI_VictorSPX(1) self.rr_motor = ctre.WPI_VictorSPX(2) self.lf_motor = ctre.WPI_VictorSPX(5) self.lr_motor = ctre.WPI_VictorSPX(4) self.drive = wpilib.drive.MecanumDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor) self.drivetrain = Drivetrain(self.drive) self.shooter_motor = ctre.WPI_VictorSPX(3) self.shooter = Shooter(self.shooter_motor) self.intake_belt_motor = wpilib.Victor(0) self.intake_belt = ConveyorBelt(self.intake_belt_motor) self.magazine_belt_motor = wpilib.Victor(1) self.magazine_belt = ConveyorBelt(self.magazine_belt_motor, negate=True) self.shooter_belt_motor = wpilib.Victor(2) self.shooter_belt = ConveyorBelt(self.shooter_belt_motor, negate=True) self.conveyor_mode = 0 self.joystick = oi.get_joystick()
class Robot(wpilib.IterativeRobot): """This is the main class for running the PacGoat code.""" def robotInit(self): """ This function is run when the robot is first started up and should be used for any initialization code. """ # Initialize the subsystems self.drivetrain = DriveTrain(self) self.collector = Collector(self) self.shooter = Shooter(self) self.pneumatics = Pneumatics(self) self.pivot = Pivot(self) wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.collector) wpilib.SmartDashboard.putData(self.shooter) wpilib.SmartDashboard.putData(self.pneumatics) wpilib.SmartDashboard.putData(self.pivot) # This MUST be here. If the OI creates Commands (which it very likely # will), constructing it during the construction of CommandBase (from # which commands extend), subsystems are not guaranteed to be # yet. Thus, their requires() statements may grab null pointers. Bad # news. Don't move it. self.oi = OI(self) #instantiate the command used for the autonomous period self.autoChooser = wpilib.SendableChooser() self.autoChooser.addDefault("Drive and Shoot", DriveAndShootAutonomous(self)) self.autoChooser.addObject("Drive Forward", DriveForward(self)) wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser) self.autonomousCommand = None # Pressurize the pneumatics self.pneumatics.start() def autonomousInit(self): self.autonomousCommand = self.autoChooser.getSelected() self.autonomousCommand.start() def autonomousPeriodic(self): """This function is called periodically during autonomous""" Scheduler.getInstance().run() self.log() def teleopInit(self): """This function is called at the beginning of operator control.""" #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 self.autonomousCommand is not None: self.autonomousCommand.cancel() def teleopPeriodic(self): """This function is called periodically during operator control.""" Scheduler.getInstance().run() self.log() def testPeriodic(self): """This function is called periodically during test mode.""" wpilib.LiveWindow.run() def disabledInit(self): self.shooter.unlatch() def disabledPeriodic(self): """This function is called periodically while disabled.""" self.log() def log(self): self.pneumatics.writePressure() wpilib.SmartDashboard.putNumber("Pivot Pot Value", self.pivot.getAngle()) wpilib.SmartDashboard.putNumber( "Left Distance", self.drivetrain.getLeftEncoder().getDistance()) wpilib.SmartDashboard.putNumber( "Right Distance", self.drivetrain.getRightEncoder().getDistance())
class Robot(wpilib.IterativeRobot): """This is the main class for running the PacGoat code.""" def robotInit(self): """ This function is run when the robot is first started up and should be used for any initialization code. """ # Initialize the subsystems self.drivetrain = DriveTrain(self) self.collector = Collector(self) self.shooter = Shooter(self) self.pneumatics = Pneumatics(self) self.pivot = Pivot(self) wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.collector) wpilib.SmartDashboard.putData(self.shooter) wpilib.SmartDashboard.putData(self.pneumatics) wpilib.SmartDashboard.putData(self.pivot) # This MUST be here. If the OI creates Commands (which it very likely # will), constructing it during the construction of CommandBase (from # which commands extend), subsystems are not guaranteed to be # yet. Thus, their requires() statements may grab null pointers. Bad # news. Don't move it. self.oi = OI(self) #instantiate the command used for the autonomous period self.autoChooser = wpilib.SendableChooser() self.autoChooser.addDefault("Drive and Shoot", DriveAndShootAutonomous(self)) self.autoChooser.addObject("Drive Forward", DriveForward(self)) wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser) self.autonomousCommand = None # Pressurize the pneumatics self.pneumatics.start() def autonomousInit(self): self.autonomousCommand = self.autoChooser.getSelected() self.autonomousCommand.start() def autonomousPeriodic(self): """This function is called periodically during autonomous""" Scheduler.getInstance().run() self.log() def teleopInit(self): """This function is called at the beginning of operator control.""" #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 self.autonomousCommand is not None: self.autonomousCommand.cancel() def teleopPeriodic(self): """This function is called periodically during operator control.""" Scheduler.getInstance().run() self.log() def testPeriodic(self): """This function is called periodically during test mode.""" wpilib.LiveWindow.run() def disabledInit(self): self.shooter.unlatch() def disabledPeriodic(self): """This function is called periodically while disabled.""" self.log() def log(self): self.pneumatics.writePressure() wpilib.SmartDashboard.putNumber("Pivot Pot Value", self.pivot.getAngle()) wpilib.SmartDashboard.putNumber("Left Distance", self.drivetrain.getLeftEncoder().getDistance()) wpilib.SmartDashboard.putNumber("Right Distance", self.drivetrain.getRightEncoder().getDistance())