Ejemplo n.º 1
0
    def __init__(self):
        RobotBase.__init__(self)
        self.iterator = None
        self.earlyStop = False

        hal.report(hal.UsageReporting.kResourceType_Framework,
                   hal.UsageReporting.kFramework_Iterative)
Ejemplo n.º 2
0
    def __init__(self):
        RobotBase.__init__(self)
        self.iterator = None
        self.earlyStop = False

        hal.report(hal.UsageReporting.kResourceType_Framework,
                   hal.UsageReporting.kFramework_Timed)

        self._expirationTime = 0
        self._notifier = hal.initializeNotifier()
Ejemplo n.º 3
0
def init():
    global drive

    if drive is not None and not RobotBase.isSimulation():
        raise RuntimeError("Subsystems already init'ed")

    drive = Nomad()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
def init():
    """

    instansiates all subsystems. Needs to be a method so it isn't ran on import

    """
    global tankdrive
    global sensors
    global arm
    global smartdashboard
    global infotable
    global is_init
    """

    Some tests call startCompetition multiple times, so don't throw an error if
    called more than once in that case.

    """

    if is_init and not RobotBase.isSimulation():
        raise RuntimeError('Subsystems have already been initialized')

    if is_init:
        return

    is_init = True

    tankdrive = TankDrive()
    sensors = Sensors()
    arm = Arm()

    smartdashboard = NetworkTables.getTable('SmartDashboard')
    infotable = NetworkTables.getTable('info')
Ejemplo n.º 6
0
def init():
    global drive

    if drive is not None and not RobotBase.isSimulation():
        raise RuntimeError('Subsystems have already been initialized')

    drive = Drive(robotmap.motors.L0, robotmap.motors.L1, robotmap.motors.R0,
                  robotmap.motors.R1)
Ejemplo n.º 7
0
def init():
    global drive, oi


    if oi is not None and not RobotBase.isSimulation():
        raise RuntimeError('Subsystems have already been initialized')

    drive = Drive()

    oi = OI()
Ejemplo n.º 8
0
def init():
    '''
    Creates all subsystems. You must run this before any commands are
    instantiated. Do not run it more than once.
    '''
    global motor
    '''
    Some tests call startCompetition multiple times, so don't throw an error if
    called more than once in that case.
    '''
    if motor is not None and not RobotBase.isSimulation():
        raise RuntimeError('Subsystems have already been initialized')

    motor = SingleMotor()
Ejemplo n.º 9
0
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
    '''
    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()
Ejemplo n.º 10
0
def init():
    '''
    Creates all subsystems. You must run this before any commands are
    instantiated. Do not run it more than once.
    '''
    global drive, move

    '''
    Some tests call startCompetition multiple times, so don't throw an error if
    called more than once in that case.
    '''
    if (drive is not None) and (move is not None) and not RobotBase.isSimulation():
        raise RuntimeError('Subsystems have already been initialized')

    drive = MechenumDrive()
    move = MechenumMove();
Ejemplo n.º 11
0
def init():
    """
    Creates all subsystems. You must run this before any commands are
    instantiated. Do not run it more than once.
    """
    global motors, gear_mech, climbing_mech, dumper
    '''
    Some tests call startCompetition multiple times, so don't throw an error if
    called more than once in that case.
    '''
    if motors is not None and not RobotBase.isSimulation():  # pragma: no cover
        raise RuntimeError('Subsystems have already been initialized')

    motors = Motors()

    gear_mech = GearMech()

    climbing_mech = ClimbingMech()

    dumper = Dumper()
Ejemplo n.º 12
0
    def diagnosticsToSmartDash(self):
        # Add position, velocity, and angle values to the SmartDash.

        SmartDashboard.putNumber(
            "Left Encoder",
            self.getLeftPosition() / robotMap.countsPerRevolution)
        SmartDashboard.putNumber(
            "Right Encoder",
            self.getRightPosition() / robotMap.countsPerRevolution)
        #         SmartDashboard.putNumber("Left Velocity", self.getLeftVelocity())
        #         SmartDashboard.putNumber("Right Velocity", self.getRightVelocity())

        if RobotBase.isReal():
            SmartDashboard.putNumber("Left Speed",
                                     self.l1.getMotorOutputPercent())
            SmartDashboard.putNumber("Right Speed",
                                     self.r1.getMotorOutputPercent())

        SmartDashboard.putNumber("Gyro Angle", self.gyro.getAngle())
        SmartDashboard.putNumber("Barometric Pressure",
                                 self.gyro.getBarometricPressure())
Ejemplo n.º 13
0
 def __init__(self):
     RobotBase.__init__(self)
     self.iterator = None
     self.earlyStop = False
Ejemplo n.º 14
0
    def __init__(self):
        super().__init__()
        # Initialize and calibrate the NavX-MXP.
        self.gyro = AHRS.create_spi(wpilib.SPI.Port.kMXP)
        self.gyro.reset()

        # Initialize motors.
        self.l1 = ctre.wpi_talonsrx.WPI_TalonSRX(robotMap.left1)
        self.l2 = ctre.wpi_talonsrx.WPI_TalonSRX(robotMap.left2)
        self.r1 = ctre.wpi_talonsrx.WPI_TalonSRX(robotMap.right1)
        self.r2 = ctre.wpi_talonsrx.WPI_TalonSRX(robotMap.right2)

        # Select a sensor for PID.
        self.l1.configSelectedFeedbackSensor(
            FeedbackDevice.CTRE_MagEncoder_Relative, 0, robotMap.ctreTimeout)
        self.r1.configSelectedFeedbackSensor(
            FeedbackDevice.CTRE_MagEncoder_Relative, 0, robotMap.ctreTimeout)

        # Left sensor runs in reverse so the phase must be set for PID.
        self.l1.setSensorPhase(True)
        self.r1.setSensorPhase(True)

        # Invert motor output as necessary.
        self.r1.setInverted(True)
        self.r2.setInverted(True)

        # Set secondary motors to follow primary motor speed.
        self.l2.follow(self.l1)
        self.r2.follow(self.r1)

        # Set talons to brake automatically.
        self.l1.setNeutralMode(NeutralMode.Brake)
        self.l2.setNeutralMode(NeutralMode.Brake)
        self.r1.setNeutralMode(NeutralMode.Brake)
        self.r2.setNeutralMode(NeutralMode.Brake)

        # If code is running on a RoboRio, configure current limiting.
        if RobotBase.isReal():
            self.l1.configPeakCurrentLimit(robotMap.peakCurrent,
                                           robotMap.ctreTimeout)
            self.l1.configPeakCurrentDuration(robotMap.peakTime,
                                              robotMap.ctreTimeout)
            self.l1.configContinuousCurrentLimit(robotMap.continuousCurrent,
                                                 robotMap.ctreTimeout)
            self.l1.enableCurrentLimit(True)

            self.l2.configPeakCurrentLimit(robotMap.peakCurrent,
                                           robotMap.ctreTimeout)
            self.l2.configPeakCurrentDuration(robotMap.peakTime,
                                              robotMap.ctreTimeout)
            self.l2.configContinuousCurrentLimit(robotMap.continuousCurrent,
                                                 robotMap.ctreTimeout)
            self.l2.enableCurrentLimit(True)

            self.r1.configPeakCurrentLimit(robotMap.peakCurrent,
                                           robotMap.ctreTimeout)
            self.r1.configPeakCurrentDuration(robotMap.peakTime,
                                              robotMap.ctreTimeout)
            self.r1.configContinuousCurrentLimit(robotMap.continuousCurrent,
                                                 robotMap.ctreTimeout)
            self.r1.enableCurrentLimit(True)

            self.r2.configPeakCurrentLimit(robotMap.peakCurrent,
                                           robotMap.ctreTimeout)
            self.r2.configPeakCurrentDuration(robotMap.peakTime,
                                              robotMap.ctreTimeout)
            self.r2.configContinuousCurrentLimit(robotMap.continuousCurrent,
                                                 robotMap.ctreTimeout)
            self.r2.enableCurrentLimit(True)

        # Reset max recorded velocities
        self.maxRecordedLeftVelocity = 0
        self.maxRecordedRightVelocity = 0

        self.r1.configNeutralDeadband(0.1, 10)
        self.r2.configNeutralDeadband(0.1, 10)
        self.l1.configNeutralDeadband(0.1, 10)
        self.l2.configNeutralDeadband(0.1, 10)