Exemplo n.º 1
0
    def robotInit( self ):
        # Motor Config
        self.PositionConfig = CANTalonConfig( wpilib.CANTalon.ControlMode.Position,
                                              wpilib.CANTalon.FeedbackDevice.QuadEncoder )
        self.PositionConfig.setPIDF( 0.5, 0.0, 2.0, 0.0 )
        self.PositionConfig.setControlSlot( 0 )
        self.PositionConfig.setRampRates( 25.0, 0.0 )
        self.PositionConfig.setBraking( False )

        self.Drive = DriveUnit(11,2, AngleConfig=self.PositionConfig, magTalon= True)
        self.Drive.setEncoderClicksRev(400000)
        # Sticks
        self.RightStick = SmartJoystick( 1, axisDeadband=0.08 )

        self.SmartDashboard = wpilib.SmartDashboard()
Exemplo n.º 2
0
class MyRobot( wpilib.IterativeRobot ):
    def robotInit( self ):
        # Motor Config
        self.PositionConfig = CANTalonConfig( wpilib.CANTalon.ControlMode.Position,
                                              wpilib.CANTalon.FeedbackDevice.QuadEncoder )
        self.PositionConfig.setPIDF( 0.5, 0.0, 2.0, 0.0 )
        self.PositionConfig.setControlSlot( 0 )
        self.PositionConfig.setRampRates( 25.0, 0.0 )
        self.PositionConfig.setBraking( False )

        self.Drive = DriveUnit(11,2, AngleConfig=self.PositionConfig, magTalon= True)
        self.Drive.setEncoderClicksRev(400000)
        # Sticks
        self.RightStick = SmartJoystick( 1, axisDeadband=0.08 )

        self.SmartDashboard = wpilib.SmartDashboard()


    def autonomousInit( self ):
        pass

    def autonomousPeriodic( self ):
        pass

    def teleopInit( self ):
        self.Drive.enable()
        print( "Enabled" )

    def teleopPeriodic( self ):
        vector = self.RightStick.getVector(compass= True, Yinv= False)
        self.Drive.setVector(vector)
        self.Drive.pushTransform()

    def testInit( self ):
        pass

    def testPeriodic( self ):
        pass

    def disabledInit( self ):
        self.Drive.disable( )