Go to Post If they had kids, they would be a super-breed of robot builders and drivers, and would win dozens of awards per season. - smurfgirl [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-01-2015, 20:14
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Packages/Importing problem with FRC Java

So currently I am trying to use the following VALID java statement:

public Executor executor = Executors.newSingleThreadExecutor();

It requires these two imports:

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

which require this package:

package java.util.concurrent;

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.

Also, are threads allowed to be used?
Reply With Quote
  #2   Spotlight this post!  
Unread 06-01-2015, 20:17
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Packages/Importing problem with FRC Java

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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 06-01-2015, 20:24
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Re: Packages/Importing problem with FRC Java

We are using the new 2015 roboRIO.

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.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-01-2015, 20:43
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

Just use the command-based template. No reason to rewrite the wheel.
__________________
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
  #5   Spotlight this post!  
Unread 06-01-2015, 20:45
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Packages/Importing problem with FRC Java

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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #6   Spotlight this post!  
Unread 06-01-2015, 20:51
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Packages/Importing problem with FRC Java

Quote:
Originally Posted by Team3266Spencer View Post
Just use the command-based template. No reason to rewrite the wheel.
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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #7   Spotlight this post!  
Unread 06-01-2015, 20:52
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Re: Packages/Importing problem with FRC Java

Alright, thanks!

I'll start transitioning to Eclipse and let you know the results.
Reply With Quote
  #8   Spotlight this post!  
Unread 06-01-2015, 20:54
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Packages/Importing problem with FRC Java

You've probably already seen this, but in case you haven't, this will help with the installation and setup: http://wpilib.screenstepslive.com/s/...eclipse-c-java
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #9   Spotlight this post!  
Unread 06-01-2015, 23:09
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Re: Packages/Importing problem with FRC Java

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);
    }

Last edited by TeamMarcies : 06-01-2015 at 23:12.
Reply With Quote
  #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
  #11   Spotlight this post!  
Unread 06-01-2015, 23:17
cgmv123's Avatar
cgmv123 cgmv123 is offline
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,085
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: Packages/Importing problem with FRC Java

Quote:
Originally Posted by TeamMarcies View Post
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?
Add
Code:
Timer.delay(0.005);
at the end of your loop and you should be fine.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)

Reply With Quote
  #12   Spotlight this post!  
Unread 06-01-2015, 23:46
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Re: Packages/Importing problem with FRC Java

Greatly appreciate the help guys, thanks!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi