class Robot(CommandBasedRobot):
    def robotInit(self):
        subsystems.init()
        self.followJoystick = FollowJoystick()

    def teleopInit(self):
        self.followJoystick.start()
Exemplo n.º 2
0
    def teleopInit(self):
        """This function runs at the beginning of the teleop period"""

        # Here we set the drivetrain's default command to FollowJoystick().
        # Meaning that once the teleop begins, the robot will be controlled by
        # the joystick.
        self.drivetrain.setDefaultCommand(FollowJoystick())
Exemplo n.º 3
0
    def robotInit(self):
        subsystems.init()

        oi.init()
        self.teleopProgram = wpilib.command.CommandGroup()
        self.teleopProgram.addParallel(FollowJoystick())
        self.teleopProgram.addParallel(Intake())
Exemplo n.º 4
0
    def initDefaultCommand(self):
        """Sets the default command of this subsystem to the `FollowJoystick`
        command.

        This will run when nothing else is running on the `Drivetrain` subsytem.
        """
        self.setDefaultCommand(FollowJoystick())
        print("Set the default command of the `Drivetrain` to  `FollowJoystick`.")
Exemplo n.º 5
0
 def returnPIDInput(self):
     if oi.controller.getBumper(
             GenericHID.Hand.kLeft):  # return control back to controller
         FollowJoystick().start()
         return 0.5
     rod_pos = camera.get_rod_pos()
     if rod_pos is None:
         self.logger.critical("Couldn't find the rod!")
         self.is_lost = True
         if not self.is_autonomous:  # return control to controller if not in autonomous
             self.logger.critical("Returning control to the controller!")
             FollowJoystick().start()
             RumbleController(0.5).start()
         return 0.5
     else:
         self.sd.putNumber("rod/actual", rod_pos[0])
         return rod_pos[0]
    def execute(self):
        if self.timer.hasPeriodPassed(0.05):
            # for xbox controller

            # piston control
            if oi.controller.getAButton():  # open
                ControlGearMech(False).start()
            elif oi.controller.getBButton():  # close
                ControlGearMech(True).start()

                # reversing control
                # if oi.controller.getStartButton():  # reverse camera, motors, and sonar
                # if self.sd.containsKey("camera/dev"):
                #     if self.sd.getNumber("camera/dev") == 1:
                #         self.sd.putNumber("camera/dev", 2)
                #     else:
                #         self.sd.putNumber("camera/dev", 1)
                # else:
                #     self.sd.putNumber("camera/dev", 1)
                # cur_direct = self.sd.getNumber("direction")
                # if cur_direct == 1:
                #     subsystems.motors.reverseDirection()
                # else:
                #     subsystems.motors.forwardDirection()
                # self.sd.putNumber("direction", -cur_direct)

            # slow mode
            if oi.controller.getBumper(GenericHID.Hand.kRight):
                if self.right_bumper_last:
                    pass
                elif oi.divider != 1:
                    self.sd.putBoolean("slowmode", False)
                else:
                    self.sd.putBoolean("slowmode", True)
                self.right_bumper_last = True
            else:
                self.right_bumper_last = False

            # lock on
            if oi.controller.getBumper(GenericHID.Hand.kLeft):
                if self.left_bumper_last:
                    pass
                elif not self.sd.getBoolean("lockonRunning"):
                    LockOn().start()
                else:
                    self.logger.critical("Returning control to the controller!")
                    self.sd.putBoolean("lockonRunning", False)
                    RumbleController(0.5).start()
                    FollowJoystick().start()
                self.left_bumper_last = True
            else:
                self.left_bumper_last = False
Exemplo n.º 7
0
def init():
    '''
    Assign commands to button actions, and publish your joysticks so you
    can read values from them later.
    '''
    global joystick_player

    joystick_player = Joystick(0)
    set_joystick()

    trigger = JoystickButton(joystick_player, Joystick.ButtonType.kTrigger)

    trigger.whenPressed(Record(FollowJoystick()))
Exemplo n.º 8
0
    def robotInit(self):
        """
        This is a good place to set up your subsystems and anything else that
        you will need to access later.
        """
        subsystems.init()
        # Command.getRobot = lambda x=0: self
        # self.motor = singlemotor.SingleMotor()

        self.autonomousProgram = AutonomousProgram()
        """
        Since OI instantiates commands and commands need access to subsystems,
        OI must be initialized after subsystems.
        """
        oi.init()
        self.teleopProgram = FollowJoystick()
Exemplo n.º 9
0
    def robotInit(self):
        """
        We use this method to declare the various, high-level objects for the
        robot.

        For example, we can use the create a CommandGroup object to store the
        various process for our robot to run when we enable it.
        """
        subsystems.init()

        oi.init()
        self.teleopProgram = wpilib.command.CommandGroup()
        self.teleopProgram.addParallel(FollowJoystick())
        self.teleopProgram.addParallel(Shooter())

        self.autoProgram = wpilib.command.CommandGroup()
        self.autoProgram.addParallel(AutoJoystick())
        self.autoProgram.addParallel(Shooter())
        self.autoProgram.addSequential(Crossbow(0.55, 0.5))
        self.autoProgram.addSequential(Crossbow(-0.75, 1))
Exemplo n.º 10
0
 def initDefaultCommand(self):
     self.setDefaultCommand(FollowJoystick())
Exemplo n.º 11
0
 def robotInit(self):
     subsystems.init()
     self.followJoystick = FollowJoystick()