First, the valid motor power range is between -100 to 100. Your code is assigning 10000 as the motor power. That's way too big. Secondly, what do you want to use to determine how to stop the robot? There are many ways to do autonomous:
- Most commonly, people do dead-reckoning (basically timed drive). You turn the motor on for a set time period and turn it off. For example:
- You can also do autonomous with feedback from sensors. For driving the robot, you typically use the encoders for determining the distance of the drive and the gyro to determine the heading of the robot. How precise do you want to control the robot? If you want really precise, you may need to use PID control (i.e. slow down when you are approaching your target). Many people typically do not use PID control, so they will just read the sensors and stop when you reach or exceed the target distance (or heading) such as the following:
Whereas PID control can slow down and even go backward to make sure you are on-target precisely. But tuning PID constants is very tedious. See my previous thread on the subject.
viewtopic.php?f=52&t=3152