コード例 #1
0
 def __init__(self, robot):
     super().__init__()
     self.addSequential(CloseClaw(robot))
     self.addSequential(WaitForPressure(robot), 2)
     if robot.isReal():
         # NOTE: Simulation doesn't currently have the concept of hot.
         self.addSequential(CheckForHotGoal(robot, 2))
     self.addSequential(SetPivotSetpoint(robot, 45))
     self.addSequential(DriveForward(robot, 8, 0.3))
     self.addSequential(Shoot(robot))
コード例 #2
0
ファイル: oi.py プロジェクト: jgrussjr/robotpy-examples
    def __init__(self, robot):
        self.joystick = wpilib.Joystick(0)

        JoystickButton(self.joystick, 12).whenPressed(LowGoal(robot))
        JoystickButton(self.joystick, 10).whenPressed(Collect(robot))

        JoystickButton(self.joystick,
                       11).whenPressed(SetPivotSetpoint(robot, Pivot.SHOOT))
        JoystickButton(self.joystick,
                       9).whenPressed(SetPivotSetpoint(robot,
                                                       Pivot.SHOOT_NEAR))

        DoubleButton(self.joystick, 2, 3).whenActive(Shoot(robot))

        # SmartDashboard Buttons
        SmartDashboard.putData("Drive Forward", DriveForward(robot, 2.25))
        SmartDashboard.putData("Drive Backward", DriveForward(robot, -2.25))
        SmartDashboard.putData("Start Rollers",
                               SetCollectionSpeed(robot, Collector.FORWARD))
        SmartDashboard.putData("Stop Rollers",
                               SetCollectionSpeed(robot, Collector.STOP))
        SmartDashboard.putData("Reverse Rollers",
                               SetCollectionSpeed(robot, Collector.REVERSE))
コード例 #3
0
ファイル: robot.py プロジェクト: virtuald/examples
    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()