class MyRobot(wpilib.TimedRobot): def robotInit(self): """This function is run when the robot is first started up and should be used for any initialization code.""" self.drivetrain = DriveTrain(self) self.elevator = Elevator(self) self.wrist = Wrist(self) self.claw = Claw() self.oi = OI(self) # instantiate the command used for the autonomous period self.autonomousCommand = Autonomous(self) # Show what command your subsystem is running on the SmartDashboard wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.elevator) wpilib.SmartDashboard.putData(self.wrist) wpilib.SmartDashboard.putData(self.claw) wpilib.LiveWindow.getInstance().setEnabled(True) def autonomousInit(self): # schedule the autonomous command (example) self.autonomousCommand.start() def autonomousPeriodic(self): """This function is called periodically during autonomous""" Scheduler.getInstance().run() self.log() def teleopInit(self): # 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. 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.getInstance().updateValues() def log(self): """The log method puts interesting information to the SmartDashboard.""" self.wrist.log() self.elevator.log() self.drivetrain.log() self.claw.log()
class MyRobot(wpilib.IterativeRobot): def robotInit(self): '''This function is run when the robot is first started up and should be used for any initialization code.''' self.drivetrain = DriveTrain(self) self.elevator = Elevator(self) self.wrist = Wrist(self) self.claw = Claw() self.oi = OI(self) # instantiate the command used for the autonomous period self.autonomousCommand = Autonomous(self) # Show what command your subsystem is running on the SmartDashboard wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.elevator) wpilib.SmartDashboard.putData(self.wrist) wpilib.SmartDashboard.putData(self.claw) def autonomousInit(self): # schedule the autonomous command (example) self.autonomousCommand.start() def autonomousPeriodic(self): '''This function is called periodically during autonomous''' Scheduler.getInstance().run() self.log() def teleopInit(self): # 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. 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 log(self): '''The log method puts interesting information to the SmartDashboard.''' self.wrist.log() self.elevator.log() self.drivetrain.log() self.claw.log()
def init(): print('Subsystems init called') ''' Creates all subsystems. You must run this before any commands are instantiated. Do not run it more than once. ''' global driveline global drivelift global elevator global ramp global cargograb global hatchgrab ''' Some tests call startCompetition multiple times, so don't throw an error if called more than once in that case. ''' if (driveline) is not None and not RobotBase.isSimulation(): raise RuntimeError('Subsystems have already been initialized') driveline = TankDrive() drivelift = TankLift() elevator = Elevator() ramp = Ramp() cargograb = CargoGrab() hatchgrab = HatchGrab()
def robotInit(self): """This function is run when the robot is first started up and should be used for any initialization code.""" self.drivetrain = DriveTrain(self) self.elevator = Elevator(self) self.wrist = Wrist(self) self.claw = Claw() self.oi = OI(self) # instantiate the command used for the autonomous period self.autonomousCommand = Autonomous(self) # Show what command your subsystem is running on the SmartDashboard wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.elevator) wpilib.SmartDashboard.putData(self.wrist) wpilib.SmartDashboard.putData(self.claw)
def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ self.pneumaticControlModuleCANID = robotmap.PCM self.kDriveTrain = robotmap.DriveTrain self.kCubeGrabber = robotmap.CubeGrabber self.kElevator = robotmap.Elevator self.kSticks = robotmap.Sticks self.kClimber = robotmap.Climber self.dStick = Joystick(self.kSticks['drive']) self.cStick = Joystick(self.kSticks['control']) self.drive = Drive(self) self.cubeGrabber = cubeGrabber(self) self.elevator = Elevator(self) self.climber = Climber(self) self.sendableChooser()
def robotInit(self): '''Initialize all subsystems.''' self.drivetrain = DriveTrain(self) self.puncher = Puncher() self.claw = Claw() self.arm = Arm() self.intake = Intake() self.elevator = Elevator() self.hatch = Hatch() self.intake_winch = IntakeWinch() self.oi = OI(self)
def robotInit(self): '''Initialize all subsystems.''' self.drivetrain = DriveTrain(self) self.rear_puncher = RearPuncher() self.arm = Arm() self.intake = Intake() self.elevator = Elevator() self.hatch = Hatch() self.intake_winch = IntakeWinch() self.lift = Lift() # The "front" of the robot (which end is facing forward) self.front = -1 self.oi = OI(self)
def robotInit(self): '''This function is run when the robot is first started up and should be used for any initialization code.''' self.drivetrain = DriveTrain(self) self.elevator = Elevator(self) self.wrist = Wrist(self) self.claw = Claw() self.oi = OI(self) # instantiate the command used for the autonomous period self.autonomousCommand = Autonomous(self) # Show what command your subsystem is running on the SmartDashboard wpilib.SmartDashboard.putData(self.drivetrain) wpilib.SmartDashboard.putData(self.elevator) wpilib.SmartDashboard.putData(self.wrist) wpilib.SmartDashboard.putData(self.claw)
def robotInit(self): """ This is a good place to set up your subsystems and anything else that you will need to access later. """ # All commands can get access to the subsystems here subsystems.LEDS = LEDs() subsystems.DRIVETRAIN = Drivetrain() subsystems.ELEVATOR = Elevator() subsystems.PAYLOAD = Payload() subsystems.SERIAL = SerialEvent() subsystems.PIGEON = Pigeon() self.compressor = wpilib.Compressor(0) self.compressor.setClosedLoopControl(True) #self.compressor.start() """ Since OI instantiates commands and commands need access to subsystems, OI must be initialized after subsystems. """ subsystems.JOYSTICK = oi.get_joystick() wpilib.CameraServer.launch()
class Robot(wpilib.IterativeRobot): def robotInit(self): """ This function is called upon program startup and should be used for any initialization code. """ self.pneumaticControlModuleCANID = robotmap.PCM self.kDriveTrain = robotmap.DriveTrain self.kCubeGrabber = robotmap.CubeGrabber self.kElevator = robotmap.Elevator self.kSticks = robotmap.Sticks self.kClimber = robotmap.Climber self.dStick = Joystick(self.kSticks['drive']) self.cStick = Joystick(self.kSticks['control']) self.drive = Drive(self) self.cubeGrabber = cubeGrabber(self) self.elevator = Elevator(self) self.climber = Climber(self) self.sendableChooser() def robotPeriodic(self): pass def disabledInit(self): pass def disabledPeriodic(self): self.drive.stop() def autonomousInit(self): """This function is run once each time the robot enters autonomous mode.""" self.autonomous = Autonomous(self) self.autonomous.reset() self.drive.autoInit() def autonomousPeriodic(self): """This function is called periodically during autonomous.""" #self.autonomous.testMove(self.autonomous.WALL_TO_SCALE, -1, False) #self.autonomous.testAngle(-90, -1) #self.elevator.setElevatorPosition(self.elevator.kScale) #self.autonomous.start() self.autonomous.run() #self.elevator.setElevatorPosition(-20000) #self.autonomous.telemetry() def teleopInit(self): self.drive.teleInit() def teleopPeriodic(self): """This function is called periodically during operator control.""" speed = (self.dStick.getY() * -1)**3 rotation = self.dStick.getTwist()/(1.1+self.dStick.getRawAxis(3)) # self.drive.moveSpeed(speed, speed) self.drive.arcadeWithRPM(speed, rotation, 2800) self.cubeGrabber.grabberFunction() # self.elevator.elevatorFunction() #self.elevator.telemetry() self.climber.climberFunction() def testInit(self): pass def testPeriodic(self): wpilib.LiveWindow.setEnabled(True) pass def sendableChooser(self): self.startingChooser = SendableChooser() self.startingChooser.addDefault('Move Forward Only', '!') self.startingChooser.addObject('Starting Left', 'L') self.startingChooser.addObject('Starting Middle', 'M') self.startingChooser.addObject('Starting Right', 'R') wpilib.SmartDashboard.putData('Starting Side', self.startingChooser) self.startingDelayChooser = SendableChooser() self.startingDelayChooser.addDefault('0', 0) self.startingDelayChooser.addObject('1', 1) self.startingDelayChooser.addObject('2', 2) self.startingDelayChooser.addObject('3', 3) self.startingDelayChooser.addObject('4', 4) self.startingDelayChooser.addObject('5', 5) self.startingDelayChooser.addObject('6', 6) self.startingDelayChooser.addObject('7', 7) self.startingDelayChooser.addObject('8', 8) self.startingDelayChooser.addObject('9', 9) self.startingDelayChooser.addObject('10', 10) self.startingDelayChooser.addObject('11', 11) self.startingDelayChooser.addObject('12', 12) self.startingDelayChooser.addObject('13', 13) self.startingDelayChooser.addObject('14', 14) self.startingDelayChooser.addObject('15', 15) wpilib.SmartDashboard.putData('Delay Time(sec)', self.startingDelayChooser) self.switchOrScale = SendableChooser() self.switchOrScale.addDefault('Switch', 'Switch') self.switchOrScale.addObject('Scale', 'Scale') wpilib.SmartDashboard.putData('Switch or Scale', self.switchOrScale)