Which isn’t found according to Netbeans but is found when I am working with a default java project.
Is this simply not allowed to be used?
I am wanting to use threads in autonomous mode and through that, use Executors that will allow threads to be placed in queue so I can have them executed in the order I have threads be executed in.
Is this code for the roboRIO, and if so, how did you set up your project for Netbeans. If you manually set up the project for Netbeans that might have something to do with it.
I’ve been programming for the team for 2 years and I’ve just decided to go ahead and clean up our messy code and start using threads to make things easier.
I have set up the project properly.
File -> New Project - > Java FRC -> IterativeRobot
I know it’s working because it’s recognizing the FRC java API which I am knees deep in with the code. It’s just this problem where I can’t seem to import a java utility I need for threads.
Are you using Netbeans? Netbeans is not officially supported anymore, so I suspect you are either trying to use the 2014 plugins or you have something wrong with how you tried to integrate the 2015 API into Netbeans.
I would try using Eclipse to test and make sure your code works in the official environment.
I also recommend using the command-based system. It gives you a lot of the advantages of multithreaded code without worrying about race conditions, deadlocks and other threading weirdness. You will also be able to get more help from other teams.
Yep! Eclipse did the trick. Thanks guys. I’ll be sure to check out the command-based programming - it seems neat.
Just one quick question: Am I able to do a while(true) loop in a thread and have it persistently be doing something or will it crash the network/roboRIO?
Basically what I’m doing here:
public void run() {
R.autonomousCounter = 0;
while (true) {
if ((Math.floor(R.autonomousCounter / loopsPerSecond)) < seconds) {
if (forward) {
theRobot.drive(-robotDriveSpeed, gyro.getAngle() * gyroModifierSpeed);
}else if (!forward) {
theRobot.drive(robotDriveSpeed, gyro.getAngle() * gyroModifierSpeed);
}
}else{
break;
}
}
theRobot.drive(0.0, 0.0);
}