def initialize(self):
     """Called before the Command is run for the first time."""
     # Get initial position
     current = self.robot.drivetrain.get_encoder_value()
     # Calculate and store target
     self._target_position = current + self._encoder_change
     return Command.initialize(self)
Beispiel #2
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     # Get initial position
     current = self.robot.drivetrain.get_gyro_angle()
     # Calculate and store target
     self._target_degrees = current + self._degrees_change
     return Command.initialize(self)
Beispiel #3
0
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     speed = self._speed
     time_left = self._duration - self._stopwatch.elapsed_time_in_secs()
     if (time_left < self._ramp_threshold):
         speed = speed * time_left / self._ramp_threshold
     self.robot.drivetrain.arcade_drive(speed, 0.0)
     return Command.execute(self)
Beispiel #4
0
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     dpad_y = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.DPADY)
     if dpad_y != 0.0:
         self.robot.drivetrain.arcade_drive(self.DPAD_LINEAR_SPEED * dpad_y, 0.0)
     else:
         left_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.LEFTY)
         right_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.RIGHTY)
         self.robot.drivetrain.tankDrive(left_track, right_track)
     return Command.execute(self)
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     current = self.robot.drivetrain.get_gyro_angle()
     degrees_left = self._target_degrees - current
     if (degrees_left) >= 0:
         direction = 1.0
     else:
         direction = -1.0
     turn_speed = self._speed * direction
     if degrees_left < self._ramp_threshold:
         turn_speed = turn_speed * (degrees_left) / self._ramp_threshold
     # Set drivetrain using speed and direction
     self.robot.drivetrain.arcade_drive(0.0, turn_speed)
     return Command.execute(self)
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     # Get encoder count
     current = self.robot.drivetrain.get_encoder_value()
     distance_left = self._target_position - current
     # Determine direction using target and current encoder values
     if (distance_left) >= 0:
         direction = 1.0
     else:
         direction = -1.0
     linear_drive_amount = self._speed * direction
     if (distance_left < self._ramp_threshold):
         linear_drive_amount = linear_drive_amount * (distance_left) / self._ramp_threshold
     # Set drivetrain using speed and direction
     self.robot.drivetrain.arcade_drive(linear_drive_amount, 0.0)
     return Command.execute(self)
Beispiel #7
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     # Start stopwatch
     self._stopwatch.start()
     return Command.initialize(self)
 def initialize(self):
     """Called before the Command is run for the first time."""
     return Command.initialize(self)
Beispiel #9
0
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     return Command.execute(self)