Esempio n. 1
0
class Robot(wpilib.IterativeRobot):
    def robotInit(self):
        """
        This function is called upon program startup and
        should be used for any initialization code.
        """
        self.drive = Drive()
        self.stick = Joystick(0)

    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.
        """
        pass

    def autonomousPeriodic(self):
        """This function is called periodically during autonomous."""
        self.drive.moveToPosition(10000, 'left')

    def teleopInit(self):
        pass

    def teleopPeriodic(self):
        """This function is called periodically during operator control."""
        speed = self.stick.getY() * -1
        rotation = self.stick.getTwist()
        # self.drive.moveSpeed(speed, speed)
        self.drive.arcade(speed, rotation)

    def testInit(self):
        pass

    def testPeriodic(self):
        pass
Esempio n. 2
0
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.kSticks = robotmap.Sticks
        self.dStick = Joystick(self.kSticks['drive'])
        self.cStick = Joystick(self.kSticks['control'])
        self.drive = Drive(self)
        self.cubeGrabber = Grabber(self)

        # holds data from the FMS about the field elements.
        self.fielddata = None

    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.
        """
        # get field data -- currently removed until we add an IF statement
        # self.fielddata = wpilib.DriverStation.getInstance().getGameSpecificMessage()

        self.drive.driveLeftMaster.setQuadraturePosition(0, 0)
        self.drive.driveRightMaster.setQuadraturePosition(0, 0)

    def autonomousPeriodic(self):
        """This function is called periodically during autonomous."""

        ## get field data
        #if not self.fielddata:
        #self.fielddata = wpilib.DriverStation.getInstance().getGameSpecificMessage()
        #nearswitch, scale, farswitch = list(self.fielddata)

        #if self.fielddata[0] == 'R':
        #self.drive.arcade(.5, .2)
        #else:
        #self.drive.arcade(.5, -.2)

        self.drive.arcade(.5, 0)

    def teleopInit(self):
        self.drive.driveLeftMaster.setQuadraturePosition(0, 0)
        self.drive.driveRightMaster.setQuadraturePosition(0, 0)

    def teleopPeriodic(self):
        """This function is called periodically during operator control."""
        speed = self.dStick.getY() * -1
        rotation = self.dStick.getTwist()
        # self.drive.moveSpeed(speed, speed)
        self.drive.arcade(speed, rotation)

        self.cubeGrabber.grabberFunction()

    def testInit(self):
        pass

    def testPeriodic(self):
        pass
Esempio n. 3
0
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.kSticks = robotmap.Sticks
        self.dStick = Joystick(self.kSticks['drive'])
        self.cStick = Joystick(self.kSticks['control'])
        self.drive = Drive(self)
        self.cubeGrabber = Grabber(self)

        # TODO:  see examples/pacgoat/robot.py
        # we need Classes defining autonomous commands to call for Forward
        # and Reverse
        #self.autoChooser = wpilib.SendableChooser()
        #self.autoChooser.addDefault("Forward", Forward(self))
        #self.autoChooser.addObject("Reverse", Reverse(self))
        #wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)

    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.
        """
        # get field data
        #self.fielddata = wpilib.DriverStation.getInstance().getGameSpecificMessage()

    def autonomousPeriodic(self):
        """This function is called periodically during autonomous."""

        #nearswitch, scale, farswitch = list(self.fielddata)
        #
        #         if nearswitch == 'R':
        #             self.drive.arcade(.5, .2)
        #         else:
        #             self.drive.arcade(.5, -.2)
        pass

    def teleopInit(self):
        pass

    def teleopPeriodic(self):
        """This function is called periodically during operator control."""
        speed = self.dStick.getY() * -1
        rotation = self.dStick.getTwist()
        # self.drive.moveSpeed(speed, speed)

        if self.isSimulation():
            self.drive.arcade(speed, rotation)
        else:
            self.drive.arcadeWithRPM(speed, rotation, 2800)

        self.cubeGrabber.grabberFunction()

        # TODO:  need something like this in commands that autonomous or teleop
        # would run to make sure an exception doesn't crash the code during
        # competition.
        #raise ValueError("Checking to see what happens when we get an exception")

    def testInit(self):
        pass

    def testPeriodic(self):
        wpilib.LiveWindow.setEnabled(True)
        pass