View Single Post
  #10   Spotlight this post!  
Unread 06-01-2015, 23:16
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Packages/Importing problem with FRC Java

Quote:
Originally Posted by TeamMarcies View Post
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:

Code:
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);
    }
Just do it this way:

Code:
public void run() {
        R.autonomousCounter = 0;
        while ((Math.floor(R.autonomousCounter / loopsPerSecond)) < seconds) {
            if (forward) {
                theRobot.drive(-robotDriveSpeed, gyro.getAngle() * gyroModifierSpeed);
            }else if (!forward) {
                theRobot.drive(robotDriveSpeed, gyro.getAngle() * gyroModifierSpeed);
            }
        }
        theRobot.drive(0.0, 0.0);
    }
I still wouldn't be worrying with threads though.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote