Whenever you work with the position of a motor, you usually tare the motor at its current position so that position is set to be the zero position. However, I do not want to waste time in autonomous setting to that position and then taring (if thats a word) it.
My question is it possible to set a certain position like -227 to the zero position instead of setting the current position of the motor as the zero position?
void autonomous() {
pros::Motor motor (1);
motor.move_absolute(100, 100); // Moves 100 units forward
motor.move_absolute(100, 100); // This does not cause a movement
motor.set_zero_position(80);
motor.move_absolute(100, 100); // Moves 120 units forward
}
if the line "motor.set_zero_position(80); " set the current encoder position as 80. Next line tell motor to move to absolute value of 100. Shouldn’t the motor only move 20 units forward?
It sets the zero position, from which all other positions are measured, to 80 units. Not 80 relative to where you are now. Just 80 in the “global” reference frame.
So zero sets the specified position to zero and adjusts the current position relative to that (new current val = old current val - specified zero val).
And, tare sets both the zero position and current position to 0.
Is there any difference in the time it takes to perform these two operations? I would guess nothing noticeable but I could be wrong. Which would mean that @Barin suggestion would be the most efficient.