def __init__(self):
     super().__init__()
     self.diabloDrive = RobotDrive(wpilib.Spark(robotMap.L1DRIVE),
                                   wpilib.Spark(robotMap.L2DRIVE),
                                   wpilib.Spark(robotMap.R1DRIVE),
                                   wpilib.Spark(robotMap.R2DRIVE))
     self.diabloDrive.frontLeftMotor.enableDeadbandElimination(True)
     self.diabloDrive.frontRightMotor.enableDeadbandElimination(True)
     self.diabloDrive.rearLeftMotor.enableDeadbandElimination(True)
     self.diabloDrive.rearRightMotor.enableDeadbandElimination(True)
 def __init__(self):
     super().__init__()
     self.diabloDrive = RobotDrive(wpilib.Spark(robotMap.L1DRIVE),
                                   wpilib.Spark(robotMap.L2DRIVE),
                                   wpilib.Spark(robotMap.R1DRIVE),
                                   wpilib.Spark(robotMap.R2DRIVE))
     print("Drive Has been created")
     self.diabloDrive.frontLeftMotor.enableDeadbandElimination(True)
     print("front left motor channel: {}\n".format(
         self.diabloDrive.frontLeftMotor.getChannel()))
     print("front left motor deadband elimination: {}\n".format(
         hal.getPWMEliminateDeadband(
             self.diabloDrive.frontLeftMotor.handle)))
     self.diabloDrive.frontRightMotor.enableDeadbandElimination(True)
     self.diabloDrive.rearLeftMotor.enableDeadbandElimination(True)
     self.diabloDrive.rearRightMotor.enableDeadbandElimination(True)
 def __init__(self):
     super().__init__()
     self.diabloDrive = RobotDrive(ctre.CANTalon(1), ctre.CANTalon(3),
                                   ctre.CANTalon(4), ctre.CANTalon(2))
示例#4
0
    def _init_components(self):
        self._max_speed = self._config.getfloat(self._general_section,
                                                Drivetrain._max_speed_key)
        self._modifier_scaling = self._config.getfloat(
            self._general_section, Drivetrain._modifier_scaling_key)
        self._dpad_scaling = self._config.getfloat(
            self._general_section, Drivetrain._dpad_scaling_key)

        if self._config.getboolean(Drivetrain._left_encoder_section,
                                   Drivetrain._enabled_key):
            self._left_encoder_a_channel = self._config.getint(
                self._left_encoder_section, Drivetrain._a_channel_key)
            self._left_encoder_b_channel = self._config.getint(
                self._left_encoder_section, Drivetrain._b_channel_key)
            self._left_encoder_reversed = self._config.getboolean(
                self._left_encoder_section, Drivetrain._reversed_key)
            self._left_encoder_type = self._config.getint(
                self._left_encoder_section, Drivetrain._type_key)
            if self._left_encoder_a_channel and self._left_encoder_b_channel and self._left_encoder_type:
                self._left_encoder = Encoder(self._left_encoder_a_channel,
                                             self._left_encoder_b_channel,
                                             self._left_encoder_reversed,
                                             self._left_encoder_type)

        if self._config.getboolean(Drivetrain._right_encoder_section,
                                   Drivetrain._enabled_key):
            self._right_encoder_a_channel = self._config.getint(
                self._right_encoder_section, Drivetrain._a_channel_key)
            self._right_encoder_b_channel = self._config.getint(
                self._right_encoder_section, Drivetrain._b_channel_key)
            self._right_encoder_reversed = self._config.getboolean(
                self._right_encoder_section, Drivetrain._reversed_key)
            self._right_encoder_type = self._config.getint(
                self._right_encoder_section, Drivetrain._type_key)
            if self._right_encoder_a_channel and self._right_encoder_b_channel and self._right_encoder_type:
                self._right_encoder = Encoder(self._right_encoder_a_channel,
                                              self._right_encoder_b_channel,
                                              self._right_encoder_reversed,
                                              self._right_encoder_type)

        if self._config.getboolean(Drivetrain._gyro_section,
                                   Drivetrain._enabled_key):
            gyro_channel = self._config.getint(self._gyro_section,
                                               Drivetrain._channel_key)
            self._gyro = ADXRS450_Gyro(gyro_channel)

        if self._config.getboolean(Drivetrain._left_motor_section,
                                   Drivetrain._enabled_key):
            self._left_motor = VictorSP(
                self._config.getint(self._left_motor_section,
                                    Drivetrain._channel_key))

        if self._config.getboolean(Drivetrain._right_motor_section,
                                   Drivetrain._enabled_key):
            self._right_motor = VictorSP(
                self._config.getint(self._right_motor_section,
                                    Drivetrain._channel_key))

        if self._left_motor and self._right_motor:
            self._robot_drive = RobotDrive(self._left_motor, self._right_motor)
            self._robot_drive.setSafetyEnabled(False)
            self._robot_drive.setInvertedMotor(
                RobotDrive.MotorType.kRearLeft,
                self._config.getboolean(Drivetrain._left_motor_section,
                                        Drivetrain._inverted_key))
            self._robot_drive.setInvertedMotor(
                RobotDrive.MotorType.kRearRight,
                self._config.getboolean(Drivetrain._right_motor_section,
                                        Drivetrain._inverted_key))