Pot Values During Autonomous

I am trying to move my TrayMotor to a certain point according to my pot values, my solution in driver control doesn’t seem to work in the autonomous period. I tried plugging this function in autonomous and it did not stop the tray motor once it reached its position. Any help? Language: Python

if TrayPot.value(RotationUnits.DEG) < 135:
TrayMotor.spin(DirectionType.FWD,25,VelocityUnits.PCT)
else:
TrayMotor.stop(BrakeType.HOLD)

Do you have that statement wrapped in a loop? If you don’t it will be evaluated once and then the program will move on, probably never stopping the lift.

2 Likes

In autonomous you don’t generally have while loops. In order for this to update motor power it must be checked regularly. If you are doing something else simultaneously consider multithreading

1 Like

This would be the exact purpose of a while loop.

1 Like

I posted the same time you did, I wasn’t commenting on what you said.

I was just saying that often times simple autons don’t work around loop,s but if you use PID you’d need them.

1 Like