Motor Position Not Resetting to 0

I am having trouble with the motors’s position for our wall stake arm not resetting. In this case, when we press the down button, the arm is lowered onto a bumper and stopped. Then, when we press the left button, the motor position is supposed to be set to zero (this is the code below). However, the motor position is not resetting at all (it’s not just a few encoders off, it’s simply not resetting). I also know there is not a functional purpose to resetting the motors with the current code since the motor is just turning by a set number of turns instead of to a position, but the problem remains that the motor position won’t set to 0. What am I doing wrong?

void ButtonLeft_released() {
  isPtoOnBase = false;
  PtoCylinders.set(true);
  PtoMotorLeft.setStopping(brake);
  PtoMotorRight.setStopping(brake);
  PtoMotorLeft.setVelocity(25.0, percent);
  PtoMotorRight.setVelocity(25.0, percent);
  PtoMotorLeft.setPosition(0, degrees);
  PtoMotorLeft.resetPosition();
  PtoMotorRight.setPosition(0, degrees);
  PtoMotorRight.resetPosition();
  PtoMotorLeft.spinFor(forward, 1.22, turns, false);
  PtoMotorRight.spinFor(forward, 1.22, turns);
  PtoMotorLeft.setVelocity(100.0, percent);
  PtoMotorRight.setVelocity(100.0, percent);
}

@jpearman ?

Sorry, just looking for a quick response so I can practice scoring wall stakes for State.

So how do you know motor position is not resetting ?

perhaps post the code that doesn’t work, it’s hard to work with one function that, without more context, doesn’t make much sense.

2 Likes

Apologies, I may have phrased things in a poor / confusing manner.

I found out the issue I was having was actually a non-issue.
I was looking at the brain screen (entering the motor through the devices screen) to see if the degrees was resetting when I was using .resetPosition(). The devices screen did not show the degrees as setting to zero. However, if I printed the position of the motor out to the controller, it showed that it was 0 after I reset the position.

Thanks for taking a look at it!

yes, when using position reset in VEXcode, it’s just an offset that’s saved, would not be reflected in the motor dashboard.

2 Likes