Ejemplo n.º 1
0
    def robotInit(self):
        """
        This is a good place to set up your subsystems and anything else that
        you will need to access later.
        """
        # Define Robot getter
        Command.getRobot = lambda: self

        # Create subsystems
        self.liftElevator = LiftElevator()
        self.drivetrain = DriveTrain()
        self.intakeOutput = IntakeOutput()

        self.compressor = Compressor()
        self.compressor.start()

        # Shuffleboard options

        # Autonomous commands
        # self.autonomousCommand = DelayedDriveToBaseLine()
        self.autonomousCommand = DriveToBaseLine()
        """
        Since OI instantiates commands and commands need access to subsystems,
        OI must be initialized after subsystems.
        """
        self.oi = OI()
Ejemplo n.º 2
0
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """
        # make this true to ignore joystick errors
        self.debug = False

        self.enabled_time = 0
        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.navigation = Navigation(self)
        self.pneumatics = Pneumatics(self)
        self.peripherals = Peripherals(self)
        #wpilib.SmartDashboard.putData(self.drivetrain)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        wpilib.SmartDashboard.putData(Scheduler.getInstance())
        # instantiate the command used for the autonomous period
        self.autonomousCommand = None
Ejemplo n.º 3
0
    def robotInit(self):
        '''Initialize all subsystems.'''
        self.drivetrain = DriveTrain(self)
        self.shooter = Shooter(self)
        self.intake_sub = Intake_Sub(self)
        self.shifter = Shifter(self)
        self.blocker = Blocker(self)
        self.climbmotors = Climbmotors(self)
        self.climbpistons = Climbpistons(self)
        self.agitator = Agitator(self)

        wpilib.SmartDashboard.putStringArray(
            "Auto List",
            ["Far Left", "Far Right", "Center", "Center Low Goal", "Default"])
        """self.autoChooser.addOption("Far Left", AutoFarLeft)
        self.autoChooser.addOption("Far Right", AutoFarRight)
        self.autoChooser.addOption("Center", AutoShoot)
        self.autoChooser.addOption("Center Low Goal", AutoCenterLowGoal)
        self.autoChooser.setDefaultOption("Default", AutoBackupShoot)
        wpilib.SmartDashboard.putData('Select Autonomous...', self.autoChooser)"""

        # The "front" of the robot (which end is facing forward)
        self.front = -1

        self.oi = OI(self)
Ejemplo n.º 4
0
    def robotInit(self):
        '''Initialize all subsystems.'''
        self.drivetrain = DriveTrain(self)
        self.shooter = Shooter(self)
        self.intake_sub = Intake_Sub(self)
        self.shifter = Shifter(self)

        # The "front" of the robot (which end is facing forward)
        self.front = -1

        self.oi = OI(self)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    def robotInit(self):
        print("[Robot] Initializing")
        logging.basicConfig(level=logging.DEBUG)

        print("[Robot] Starting network tables server")
        NetworkTables.initialize()

        print("[Robot] Setting up systems")
        self.cargosystem = CargoSystem(self)
        self.climbsystem = ClimbSystem(self)
        self.drivetrain = DriveTrain(self)
        self.hatchsystem = HatchSystem(self)

        self.oi = OI(self)

        # setup autonomous type
        print("[Robot] Setting up autonomous")
        scAutonomousType = wpilib.SendableChooser()
        scAutonomousType.setDefaultOption("1. Driver Controlled", 100)
        scAutonomousType.addOption       ("2. Timed Just Drive Forward", 200)
        scAutonomousType.addOption       ("3. Motion Profile Just Drive Forward", 300)
        scAutonomousType.addOption       ("4. Total Autonomous", 400)
        wpilib.SmartDashboard.putData    ("Anonomous Type", scAutonomousType)   

        # setup robot positions
        scRobotPosition = wpilib.SendableChooser()
        scRobotPosition.setDefaultOption("1. Upper Left" , 1)
        scRobotPosition.addOption       ("2. Lower Left" , 2)
        scRobotPosition.addOption       ("3. Centre"     , 3)
        scRobotPosition.addOption       ("4. Upper Right", 4)
        scRobotPosition.addOption       ("5. Lower Right", 5)
        wpilib.SmartDashboard.putData   ("Robot Position", scRobotPosition)

        # setup hatch positions
        scHatchPosition = wpilib.SendableChooser()
        scHatchPosition.setDefaultOption("1. Back"       , 10)
        scHatchPosition.addOption       ("2. Middle"     , 20)
        scHatchPosition.addOption       ("3. Front"      , 30)
        wpilib.SmartDashboard.putData   ("Hatch Position", scHatchPosition)

        # wpilib.CameraServer.launch("d:\\jet\\projects\\python\\RobotPy\\src\\vision.py:main")
        # wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putNumber("H-Lower", 0)
        wpilib.SmartDashboard.putNumber("H-Upper", 180)
        wpilib.SmartDashboard.putNumber("S-Lower", 0)
        wpilib.SmartDashboard.putNumber("S-Upper", 255)
        wpilib.SmartDashboard.putNumber("V-Lower", 0)
        wpilib.SmartDashboard.putNumber("V-Upper", 255)
Ejemplo n.º 8
0
 def robotInit(self):
     self.activated = False
     """Robot-wide initialization code should go here."""
     #SwiftCameraServer().launch('camera1.py:main')
     #SwiftCameraServer().launch('camera2.py:main')
     wpilib.CameraServer.launch()
     self.configuration = constants.COMP_BOT
     self.arm = Arm(self)
     self.drivetrain = DriveTrain(self)
     self.pneumatic = Pneumatic(self)
     self.compressor = wpilib.Compressor()
     self.camera_servo_1 = CameraServo(self, constants.CAMERA_1_PWM,
                                       constants.CAMERA_1_DEFAULT)
     self.camera_servo_2 = CameraServo(self, constants.CAMERA_2_PWM,
                                       constants.CAMERA_2_DEFAULT)
     self.oi = OI(self)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
    def robotInit(self):
        '''Initialize all subsystems.'''
        self.drivetrain = DriveTrain(self)
        self.shooter = Shooter(self)
        self.intake_sub = Intake_Sub(self)
        self.shifter = Shifter(self)
        self.blocker = Blocker(self)
        self.climbmotors = Climbmotors(self)
        self.climbpistons = Climbpistons(self)
        self.agitator = Agitator(self)


        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.setDefaultOption("Drive", DriveAutonomous(self))

        # The "front" of the robot (which end is facing forward)
        self.front = -1

        self.oi = OI(self)
Ejemplo n.º 11
0
    def robotInit(self):
        """Robot-wide initialization code should go here"""
        super().__init__()

        if self.isReal():  # use the real drive train
            self.drivetrain = DriveTrain(self)
        else:  # use the simulated drive train
            #self.drivetrain = DriveTrainSim(self)
            self.drivetrain = DriveTrainSim(self)

        self.shooter = Shooter(self)
        self.vision = Vision()

        # oi MUST be created after all other subsystems since it uses them
        self.oi = OI(self)

        self.enabled_time = 0  # something is especially weird with the sim about this needing to be initialized in robotInit

        self.autonomousCommand = None  # initialize the placeholder command for autonomous
Ejemplo n.º 12
0
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """

        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.collector = Collector(self)
        self.shooter = Shooter(self)
        self.pneumatics = Pneumatics(self)
        self.pivot = Pivot(self)
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.collector)
        wpilib.SmartDashboard.putData(self.shooter)
        wpilib.SmartDashboard.putData(self.pneumatics)
        wpilib.SmartDashboard.putData(self.pivot)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        #instantiate the command used for the autonomous period
        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.addDefault("Drive and Shoot",
                                    DriveAndShootAutonomous(self))
        self.autoChooser.addObject("Drive Forward", DriveForward(self))
        wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)

        self.autonomousCommand = None

        # Pressurize the pneumatics
        self.pneumatics.start()
Ejemplo n.º 13
0
    def robotInit(self):
        """
        Robot-wide initialization code goes here.  For the command-based programming framework,
        this means creating the subsytem objects and the operator input object.  BE SURE TO CREATE
        THE SUBSYTEM OBJECTS BEFORE THE OPERATOR INPUT OBJECT (since the operator input object
        will almost certainly have subsystem dependencies).  For further information on the
        command-based programming framework see:
        wpilib.screenstepslive.com/s/currentCS/m/java/l/599732-what-is-command-based-programming
        """
        # Create the subsytems and the operator interface objects
        self.driveTrain = DriveTrain(self)
        self.boom = Boom(self)
        self.intakeMotors = IntakeMotors(self)
        self.intakePneumatics = IntakePneumatics(self)
        self.oi = OI(self)

        # Create the smartdashboard object
        self.smartDashboard = SmartDashboard()

        # Create the sendable choosers to get the autonomous preferences
        self.startSpotChooser = SendableChooser()
        self.startSpotChooser.addObject("Start Left", 'Left')
        self.startSpotChooser.addObject("Start Right", 'Right')
        self.startSpotChooser.addDefault("Start Middle", 'Middle')
        self.smartDashboard.putData("Starting Spot", self.startSpotChooser)

        self.scaleDisableChooser = SendableChooser()        
        self.scaleDisableChooser.addObject("Enable Scale", 'Scale')
        self.scaleDisableChooser.addDefault("Disable Scale", 'No Scale')
        self.smartDashboard.putData("Scale Enable", self.scaleDisableChooser)

        # Build up the autonomous dictionary.  Fist key is the starting position.  The second key is the switch.  The third key is the scale.
        self.chooserOptions = {"Left": {"R": {"R": {"No Scale": {'command': AutonForward},
                                                    "Scale": {'command': AutonForward}
                                                    },
                                              "L": {"No Scale": {'command': AutonForward},
                                                    "Scale": {'command': AutonForward}
                                                    },
                                              },
                                        "L": {"R": {"No Scale": {'command': AutonLeftStartLeftSwitch},
                                                    "Scale": {'command': AutonLeftStartLeftSwitch}
                                                    },
                                              "L": {"No Scale": {'command': AutonLeftStartLeftSwitch},
                                                    "Scale": {'command': AutonLeftStartLeftSwitch}
                                                    },
                                              },
                                        },
                               "Middle": {"R": {"R": {"No Scale": {'command': AutonMiddleStartRightSwitch},
                                                      "Scale": {'command': AutonMiddleStartRightSwitch}
                                                      },
                                                "L": {"No Scale": {'command': AutonMiddleStartRightSwitch},
                                                      "Scale": {'command': AutonMiddleStartRightSwitch}
                                                      },
                                                },
                                          "L": {"R": {"No Scale": {'command': AutonMiddleStartLeftSwitch},
                                                      "Scale": {'command': AutonMiddleStartLeftSwitch}
                                                      },
                                                "L": {"No Scale": {'command': AutonMiddleStartLeftSwitch},
                                                      "Scale": {'command': AutonMiddleStartLeftSwitch}
                                                      },
                                                },
                                          },
                               "Right": {"R": {"R": {"No Scale": {'command': AutonRightStartRightSwitch},
                                                     "Scale": {'command': AutonRightStartRightSwitch}
                                                     },
                                               "L": {"No Scale": {'command': AutonRightStartRightSwitch},
                                                     "Scale": {'command': AutonRightStartRightSwitch}
                                                     },
                                               },
                                         "L": {"R": {"No Scale": {'command': AutonForward}, 
                                                     "Scale": {'command': AutonForward}
                                                     },
                                               "L": {"No Scale": {'command': AutonForward},
                                                     "Scale": {'command': AutonForward}
                                                     },
                                               },
                                         },
                               }

        # Create a timer for data logging
        self.timer = Timer()

        # Create the camera server
        CameraServer.launch()

        # Boom state start at the scale
        self.boomState = BOOM_STATE.Scale
Ejemplo n.º 14
0
    def robotInit(self):
        """
        Robot-wide initialization code goes here.  For the command-based programming framework,
        this means creating the subsytem objects and the operator input object.  BE SURE TO CREATE
        THE SUBSYTEM OBJECTS BEFORE THE OPERATOR INPUT OBJECT (since the operator input object
        will almost certainly have subsystem dependencies).  For further information on the
        command-based programming framework see:
        wpilib.screenstepslive.com/s/currentCS/m/java/l/599732-what-is-command-based-programming
        """
        # Create the subsytems and the operator interface objects
        self.driveTrain = DriveTrain(self)
        self.boom = Boom(self)
        self.intakeMotors = IntakeMotors(self)
        self.intakePneumatics = IntakePneumatics(self)
        self.oi = OI(self)

        # Create the smartdashboard object
        self.smartDashboard = SmartDashboard()

        # Create the sendable choosers to get the autonomous preferences
        self.scoringElementChooser = SendableChooser()
        self.scoreScale = ScoreScale()
        self.scoreSwitch = ScoreSwitch()
        self.scoringElementChooser.addObject("Score Scale", self.scoreScale)
        self.scoringElementChooser.addObject("Score Switch", self.scoreSwitch)
        self.scoringElementChooser.addDefault("Score Scale", self.scoreScale)
        self.smartDashboard.putData("Score Field Element",
                                    self.scoringElementChooser)

        self.crossFieldChooser = SendableChooser()
        self.crossFieldEnable = CrossFieldEnable()
        self.crossFieldDisable = CrossFieldDisable()
        self.crossFieldChooser.addObject("Cross Field Enable",
                                         self.crossFieldEnable)
        self.crossFieldChooser.addObject("Cross Field Disable",
                                         self.crossFieldDisable)
        self.crossFieldChooser.addDefault("Cross Field Disable",
                                          self.crossFieldDisable)
        self.smartDashboard.putData("Cross Field Enable",
                                    self.crossFieldChooser)

        self.positionChooser = SendableChooser()
        self.startingLeft = StartingLeft()
        self.startingRight = StartingRight()
        self.startingMiddle = StartingMiddle()
        self.positionChooser.addObject("Start Left", self.startingLeft)
        self.positionChooser.addObject("Start Right", self.startingRight)
        self.positionChooser.addObject("Start Middle", self.startingMiddle)
        self.positionChooser.addDefault("Start Middle", self.startingMiddle)
        self.smartDashboard.putData("Starting Position", self.positionChooser)

        # Create a timer for data logging
        self.timer = Timer()

        # Create the camera server
        CameraServer.launch()

        # Boom state start at the scale
        self.boomState = BOOM_STATE.Scale

        self.autonForward = AutonForward(self)
        self.autonMiddleStartLeftSwitch = AutonMiddleStartLeftSwitch(self)
        self.autonLeftStartLeftScale = AutonLeftStartLeftScale(self)

        # Output debug data to the smartdashboard
        if LOGGER_LEVEL == logging.DEBUG:
            #=======================================================================================
            # self.smartDashboard.putNumber("RightEncPos", 0.0)
            # self.smartDashboard.putNumber("RightActPos", 0.0)
            # self.smartDashboard.putNumber("RightEncVel", 0.0)
            # self.smartDashboard.putNumber("RightActVel", 0.0)
            # self.smartDashboard.putNumber("RightPrimaryTarget", 0.0)
            # self.smartDashboard.putNumber("RightPrimaryError", 0.0)
            # self.smartDashboard.putNumber("TimeStamp", 0.0)
            # self.smartDashboard.putNumber("LeftEncPos", 0.0)
            # self.smartDashboard.putNumber("LeftActPos", 0.0)
            # self.smartDashboard.putNumber("LeftEncVel", 0.0)
            # self.smartDashboard.putNumber("LeftActVel", 0.0)
            # self.smartDashboard.putNumber("LeftPrimaryTarget", 0.0)
            # self.smartDashboard.putNumber("LeftPrimaryError", 0.0)
            # self.smartDashboard.putNumber("RightTopBufferCount", 0.0)
            # self.smartDashboard.putNumber("LeftTopBufferCount", 0.0)
            # self.smartDashboard.putNumber("LeftBottomBufferCount", 0.0)
            # self.smartDashboard.putNumber("RightBottomBufferCount", 0.0)
            #=======================================================================================
            self.smartDashboard.putNumber("EncPos", 0.0)
            self.smartDashboard.putNumber("ActPos", 0.0)
            self.smartDashboard.putNumber("EncVel", 0.0)
            self.smartDashboard.putNumber("ActVel", 0.0)
            self.smartDashboard.putNumber("PrimaryTarget", 0.0)
            self.smartDashboard.putNumber("PrimaryError", 0.0)
            self.smartDashboard.putNumber("TimeStamp", 0.0)