Announcement

Collapse
No announcement yet.

Want a button to run motor to encoder value, but still respond to joystick control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Want a button to run motor to encoder value, but still respond to joystick control

    We have a linear slide that holds our harvester that is powered by a REV Core Hex motor controlled by the controller right joystick Y axis. We would like to have the slide move to a set position for scoring in the lander using the motor's encoder when we press the right bumper control, and hold that position unless joystick movement overrides it. And except when that bumper button is pushed, we need the slide to extend and retract normally using the joystick.

    Our programmers are pretty new at this so a simpler solution would be the best. Any help will be appreciated.

  • #2
    I should add that we don;t want the driver to have to hold down the bumper button, we just want it to toggle the motor to run to the same position each time the button is pressed.

    Comment


    • #3
      You could use Run_To_Position. When you push the button, it sets the target position to the value desired. RTP will actively hold the motor in that position.
      PushbotAutoDriveByEncoder example program demos RTP.

      When the joystick exceeds a value it would take the motor out of RTP. Then do normal joystick control.
      if (Math.abs(gamepad1.left_stick_y) > 0.1) myMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODE R);

      Comment

      Working...
      X