Autonomous Code does not advance to the next line

Hi, I am having a problem with my autonomous code not advancing to the next line of code after one specific line. My program is simple: Lifting the arms up 1 inch [with two motors for the upper and two motors for the lower], drive forward 36 inches, Lift the arms to max, drive forward 12 inches, turn right. The problem is that after it lifts the arms to max, it just stops and won’t go to the next line. Below is the program. Thanks in advance for any help.
// “when autonomous” hat block
int onauton_autonomous_0() {
bottomlift.spinToPosition(-10.0, degrees, true);
toplift.spinToPosition(-10.0, degrees, true);
bottomlift.setRotation(-10.0, degrees);
toplift.setRotation(-10.0, degrees);
Drivetrain.driveFor(forward, 36.0, inches, true);
bottomlift.spinToPosition(-180.0, degrees, true);
toplift.spinToPosition(-180.0, degrees, true);
Drivetrain.driveFor(forward, 12.0, inches, true);
Drivetrain.turnFor(right, 123.5, degrees, true);
return 0;

You’ve asked a motor to spin to certain position and not proceed through the code until it has reached that position. And it is not proceeding through the code, so…


Hi u89djt, Thank you for your reply. I am not that great in programming. This is actually my first try at this. I apologize for the slow understanding. My robot actually went through the process of lifting the arms to max. My question is how do I know that it has not completed it’s task? Or, should I put in the line of the lifting to time out for a couple of seconds after it goes through that line? The first lift introduction to lift about 1 inch went through just fine and it proceeded to the drive forward line. Thank you again for your help.

No-one is when they start :slight_smile: I think you should find out what the range of motion of the mechanism is and print it to the screen or to the controller. Your suggestion of timing out is good. You’ll see 3D printers knock axes against the limits to find out where they are - go ahead and do something like that.
I’m guessing that you got the first four lines from somewhere that was actually using “,false” for waiting till completion and using a timeout? With “,true”, the setRotation statements are redundant since you’ve assumed you must have got there.

u89djt, thank you again. I am a team member of four. We’ve been scratching our heads on this like crazy. The first hurdle was the 90 degree turn. I discovered that I have to make compensation to make it turn at exactly 90 degrees; hence the 123 turn there in the code. Anyways, thank you again for your time in helping me out with this. Greatly appreciated. You have a good day.

1 Like

Maybe there’s a general observation that you can work with: I’ve seen that people new to programing don’t immediately internalize the idea that you’re responsible for every little thing that happens, and that means that every single token in the code has specific meaning and implications, so if you’re lost, go through and make sure you know why every word, symbol and lineis there. “Why is that there?” “Dunno” is a classic recipe for lost hours. :slight_smile:

u89djt, thanks again.