Auto won't run

Can anyone tell me why my code won’t work?

When I enable the robot, the motors output like they are supposed to for a half second, then seems to hang. The probes stop updating and the motors stop running. Can anyone tell me why this is?
https://i.imgur.com/cJqSXUz.png

Update: This is not specific to this auto mode, this is happening in all my auto modes.

Update: I dropped a bit of sample code in the auto mode selector, and it worked perfectly, so it must be an issue with my code

Your drive motors are being commanded only once. Things will work better if you add a While around the drive code, with a Wait of 10 or 20 ms to keep the loop from eating up all the CPU time.

The Gyro Get Angle will have to be duplicated inside the loop for the 90 degree turn. (You can’t communicate time-varying values into or out of a loop; they take their inputs once when the loop first begins, and produce an output once the loop finally finishes.)

The motor stopping is probably the safety config kicking in. I am guessing you enabled it in begin. You could either turn it off for auto, or make the the calls less than 100 ms apart.

If you message me I will give you the code that we use for Auto. I think you will find that it is very straight forward and easy to use.

Thank you so much, I did that and now the drive works perfectly!

I have another problem, if its not a bother:

After the pistons clamp, it doesn’t move to the next part of the flat sequence structure. Can anyone spot the problem? I’ve been looking at it for the past hour.

Your “Turn 90 degrees” frame sets the drive state to 4, which I see is supposed to turn at 30% power. But then it immediately sets the state to 3 while it waits for the turn to complete. I assume drive state 3 just sits there doing nothing. Get rid of that extraneous 3 -> State3 underneath the gyro angle indicator in the while loop.

(I suggest that you move the frame labels from above the flat sequence to actually inside the frames they are labeling. That way they will stay connected to the code they are describing if you ever rearrange things.)

Here is the example code. Let me know if you have any questions.

How do I attach a zip file?

Another try at it.

First 2015.zip (65.9 KB)


First 2015.zip (65.9 KB)