Motor.setTimeout behavior?

How exactly does the


 Motor.setTimeout

function work? Does the timer begin as soon as the motor begins to rotate? Or only if it is trying to spin but the encoder isn’t going up? I am trying to make code to fully extend our tower using this function.

My code would look something like this:


Tower.setTimeout(1,vex::timeUnits::sec);

// Tower would be fully extended at encoder value of say 500
Tower.rotateTo(600,vex::rotationUnits::deg,100,vex::velocityUnits::pct); // Try to rotate past the full extension, then time out after it can't reach the top

2 Likes

The timeout is the length of time that the rotateTo call will wait for the motor to reach it’s target position. If the timeout occurs, the motor is sent stop. The timeout only applies to a blocking method like rotateTo, it has no meaning for the non blocking methods such as startRotateTo.

1 Like

So the timer starts as soon as the


rotateTo

command is called? Or only when the motors begin to feel resistance?

As soon as you call rotateTo

Does it stay set for the entire session or just for the duration of a rotateTo / rotateFor?

Is there a reset or we just remember to set it to some very high number (out of curiosity, is there a default) when not needed?

What kind of motor stop does it do? Forced to HOLD as per rotateTo or goes to whatever default is set?

Thanks.

1 Like

It stays set while the motor instance is valid, so if your motor is a global instance (which it usually will be in VCS) it will retain the value while your program is running.

If you set to 0, it should go back to the default value which is INT32_MAX

If the timeout happens, stop is called with current brake mode.

1 Like

@jpearman: Thank you again for your superfast response.