Once we finished wiring our robot, we decided to quickly throw together a program which would allow us to test all of our motors. It was simply an iterative robot which instantiated motors controllers like
Code:
Victor motor = new Victor(0);
for each motor we wanted to test, and then in TeleopPeriodic, had code that looked like:
Code:
void teleopPeriodic() {
motor.set(.5);
}
Just to see if they would run, if we hooked them up right. But when I ran this code on a motor, it behaved sluggishly and was jittery. My theory was that the set() function wasn't being called rapidly enough, so I decided to place the call in a while loop so that it would iterate faster (I know you're not supposed to do this, since it screws up the timing completely) as follows:
Code:
void teleropPeriodic() {
while(true) {
motor.set(.5)
}
}
Lo and behold, the motor ran perfectly. Isn't the iterative code supposed to iterate fast enough to run a motor? Obviously we don't want to use a while loop in our actual code, since that would literally bring the period to a halt. If you are supposed to be able to do this, what might be causing the problem for us? Thanks.