Quote:
Originally Posted by JesseK
Maybe he lacked the proper people skills. Many a great idea go mutiliated or unknown because someone doesn't speak up enough or that someone lacks the insight into how to be pushy enough to make the idea become a success.
(Java-C-MPLab pseudo-goullash code)
Code:
int rand = Math.rand() * 127;
int pos_neg = Math.rand;
if(pos_neg > 0.5)
pos_neg = 1;
else
pos_neg = -1;
//Drive Motors
pwm_04=pwm_05=(rand + 127);
pwm_06=pwm_07=(rand * pos_neg + 127);
//Arm
pwm_08=255; //Arms up!
pwm_09=(rand/2*pos_neg + 127); //Wavy hands
This isn't a joke; this will be our autonomous algorithm next year if our students don't come up with anything to do in autonomous. Students be warned!
|
The only downside to this algorithm is that there is no rand() function of any kind on our controller.
The best way I've found to generate "random" numbers on Vex/FRC controllers is to start a timer at the beginning of your program, and whenever you need a random number get the modulus of the timer value when divided by a number of your choice.