View Single Post
  #3   Spotlight this post!  
Unread 26-03-2012, 23:55
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Check My Autonomous Code

In your attached code, you have two while loops.

The one on the top has some useless logic in there with the < 0 thing since you're giving it values of 0.3 and 0, the value will never be less than 0. I think you're trying to code in protection so the motor never goes in reverse, right? Or is your logic backwards and you want to use the AND to enable the motor output? I'm not sure what's going on here. You might want to think it out on paper. Also, you should GET your references outside of the while loop to reduce CPU load.

The one on the bottom definitely won't work the way you think it will.
I think you want your robot to move forward 5 feet, stop, and lower the bridge arm, right? Look where your while loop is located. It will execute the sequence diagram with every loop. So you'll be telling your drive motors to move, then stop, move then stop... Another issue is where your bridge switch GET method is located, outside of the while loop. The switch will only be read once, then that's it. Your motor output will never be controlled. And again, some useless logic. Is 1 < 0? No, you know that, so why have that in your program. Since you're using an AND, and you have a constant FALSE being pushed in it, it will always be false, which will cause your bridge arm motor to be on the full time.

Also, good job using the Select on the second sequence. Why not use it for the motor values in the first sequence?

Don't forget to add a small Wait timer to each while loop. Not having this will cause the CPU to spike out to 100% and hog all resources.

One last additional thing. You should re-enable the safety config for your drive motors once you're done with autonomous. Really, it's not needed. As long as you update your motors every 100ms, you'll be fine.

And as Jay1986 said, make sure to reset your encoders before using them.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364

Last edited by RyanN : 26-03-2012 at 23:59.
Reply With Quote