class ExampleBot(CommandBasedRobot): ''' The CommandBasedRobot base class implements almost everything you need for a working robot program. All you need to do is set up the subsystems and commands. You do not need to override the "periodic" functions, as they will automatically call the scheduler. You may override the "init" functions if you want to do anything special when the mode changes. ''' def robotInit(self): ''' This is a good place to set up your subsystems and anything else that you will need to access later. ''' Command.getRobot = lambda x=0: self self.motor = singlemotor.SingleMotor() self.autonomousProgram = AutonomousProgram() ''' Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. ''' self.joystick = oi.getJoystick() def autonomousInit(self): ''' You should call start on your autonomous program here. You can instantiate the program here if you like, or in robotInit as in this example. You can also use a SendableChooser to have the autonomous program chosen from the SmartDashboard. ''' self.autonomousProgram.start()
def robotInit(self): """This function initiates the robot's components and parts""" # Here we create a function for the command class to return the robot # instance, so that we don't have to import the robot module for each # command. Command.getRobot = lambda _: self # This launches the camera server between the robot and the computer wpilib.CameraServer.launch() self.joystick = wpilib.Joystick(0) self.lr_motor = ctre.WPI_TalonSRX(1) self.lf_motor = ctre.WPI_TalonSRX(2) self.rr_motor = ctre.WPI_TalonSRX(5) self.rf_motor = ctre.WPI_TalonSRX(6) self.left = wpilib.SpeedControllerGroup(self.lf_motor, self.lr_motor) self.right = wpilib.SpeedControllerGroup(self.rf_motor, self.rr_motor) self.drivetrain_solenoid = wpilib.DoubleSolenoid(2, 3) self.drivetrain_gyro = wpilib.AnalogGyro(1) # Here we create the drivetrain as a whole, combining all the different # robot drivetrain compontents. self.drivetrain = drivetrain.Drivetrain(self.left, self.right, self.drivetrain_solenoid, self.drivetrain_gyro, self.rf_motor) self.l_gripper = wpilib.VictorSP(0) self.r_gripper = wpilib.VictorSP(1) self.grippers = grippers.Grippers(self.l_gripper, self.r_gripper) self.elevator_motor = wpilib.VictorSP(2) self.elevator_top_switch = wpilib.DigitalInput(4) self.elevator_bot_switch = wpilib.DigitalInput(5) self.elevator = elevator.Elevator(self.elevator_motor, self.elevator_top_switch, self.elevator_bot_switch) self.handles_solenoid = wpilib.DoubleSolenoid(0, 1) self.handles = handles.Handles(self.handles_solenoid) # This creates the instance of the autonomous program that will run # once the autonomous period begins. self.autonomous = AutonomousProgram() # This gets the instance of the joystick with the button function # programmed in. self.josytick = oi.getJoystick()
def autonomousInit(self): self.sd.putBoolean("isautonomous", True) UpdateNetworkTables().start() if self.sd.containsKey("autonomous/selected"): AutonomousProgram(self.sd.getString("autonomous/selected")).start() else: # if not set for some reason (bad!), just use center mode AutonomousProgram("center").start() self.logger.info("Started autonomous.")
def robotInit(self): ''' This is a good place to set up your subsystems and anything else that you will need to access later. ''' subsystems.init() self.autonomousProgram = AutonomousProgram() ''' Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. ''' oi.init()
class WOPRJR(CommandBasedRobot): def robotInit(self): subsystems.init() self.autonomousProgram = AutonomousProgram() self.teleopProgram = TankDriveJoystick() oi.init() def autonomousInit(self): self.autonomousProgram.start() def teleopInit(self): self.teleopProgram.start()
def robotInit(self): ''' This is a good place to set up your subsystems and anything else that you will need to access later. ''' Command.getRobot = lambda x=0: self self.motor = singlemotor.SingleMotor() self.autonomousProgram = AutonomousProgram() ''' Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. ''' self.joystick = oi.getJoystick()
def robotInit(self): """ This is a good place to set up your subsystems and anything else that you will need to access later. """ subsystems.init() # Command.getRobot = lambda x=0: self # self.motor = singlemotor.SingleMotor() self.autonomousProgram = AutonomousProgram() """ Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. """ oi.init() self.teleopProgram = FollowJoystick()
def robotInit(self): """ This is a good place to set up your subsystems and anything else that you will need to access later. """ Command.getRobot = lambda x=0: self self.doublemotor = doublemotor.DoubleMotor() self.singlemotor = singlemotor.SingleMotor() self.drive = ArcadeDrive.Arcade() self.autonomousProgram = AutonomousProgram() """ Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. """ self.joystick = oi.getJoystick()
def robotInit(self): subsystems.init() self.autonomousProgram = AutonomousProgram() self.teleopProgram = TankDriveJoystick() oi.init()