Go to Post Waiting for the kick off is like studing the molecular structure of grass while being hit on the head by a frying pan - infinitydex [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-01-2014, 23:11
Zaque Zaque is offline
FF: Bobo Brigade
AKA: Zachary H.
FRC #3352 (Flaming Monkeys)
Team Role: Programmer
 
Join Date: Mar 2013
Rookie Year: 2013
Location: Belvidere, Illinois
Posts: 91
Zaque has a spectacular aura aboutZaque has a spectacular aura aboutZaque has a spectacular aura about
How to make a "Custom VI" in Java?

Hello all,

In the past, our team has used LABView to program our robots. This year, we have switched over to Java. In LV, I could make custom vi's to do, for example, ramping. I have a small understanding of the concepts needed to do this in java, but it is very, very hazy, so if anyone could point me to a tutorial or other documentation on how to do this, I would much appreciate it.

Thanks,
Zaque
__________________
Zaque (Zach) H.
President
Programming/Electrical Lead
  #2   Spotlight this post!  
Unread 18-01-2014, 23:16
Christopher149 Christopher149 is offline
Registered User
FRC #0857 (Superior Roboworks) FTC 10723 (SnowBots)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2007
Location: Houghton, MI
Posts: 1,101
Christopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond reputeChristopher149 has a reputation beyond repute
Re: How to make a "Custom VI" in Java?

Not a tutorial, but a "custom VI" in Java would essentially be a method/function. Further, you can spread your methods across several classes to group them (such as a 'shooter' class, or a 'vision targeting' class).

Hope this points you in a helpful direction (too close to bed to find a good tutorial for you).
  #3   Spotlight this post!  
Unread 19-01-2014, 00:58
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 89
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: How to make a "Custom VI" in Java?

You can take a look at the WPI site:
http://wpilib.screenstepslive.com/s/3120/m/7885

Another resource is the samples that are installed with NetBeans. In NetBeans, go to:
File -> New Project -> Samples -> FRC Java

There are three basic "styles" of programming a robot in Java: BasicRobot, IterativeRobot, and CommandBased. I will let you read about the differences elsewhere, but I thought you should know that there are three different paradigms.

Finally, if you do a search on ChiefDelphi, you will find other teams that link to tutorials on their sites.

Good luck!
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
  #4   Spotlight this post!  
Unread 19-01-2014, 01:05
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 430
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: How to make a "Custom VI" in Java?

Here's a rate limiter we had in our code from last year.

Code:
        /**
         * A simple rate limiter.
         * http://www.chiefdelphi.com/forums/showpost.php?p=1212189&postcount=3
         * 
         * @param input the input value (speed from command/joystick)
         * @param speed the speed currently being traveled at
         * @param posRateLimit the rate limit for accelerating
         * @param negRateLimit the rate limit for decelerating
         * @return the new output speed (rate limited)
         */
        public static double rateLimit(double input, double speed,
                        double posRateLimit, double negRateLimit) {
                if (input > 0) {
                        if (input > (speed + posRateLimit)) {
                          //Accelerating positively
                          speed = speed + posRateLimit;
                        } else if (input < (speed - negRateLimit)) {
                          //Decelerating positively 
                          speed = speed - negRateLimit;
                        } else {
                          speed = input;
                        }
                } else {
                        if (input < (speed - posRateLimit)) {
                          //Accelerating negatively
                          speed = speed - posRateLimit;
                        } else if (input > (speed + negRateLimit)) {
                           //Decelerating negatively
                          speed = speed + negRateLimit;
                        } else {
                          speed = input;
                        }
                }
                return speed;
        }
You would/could call it like this:
Code:
newLeftSpeed = rateLimit(newLeftSpeed, currentLeftSpeed, 0.15, 0.15);
newRightSpeed = rateLimit(newRightSpeed, currentRightSpeed, 0.15, 0.15);

drivetrain.tankDrive(newLeftSpeed, newRightSpeed);
Where the current and new variables used above are class variables used to keep track of speed between loop iterations, and the tank drive just passes the values it receives on to the motor controllers for each side of the drivetrain. The new speed variables could be coming right off your joysticks if using this code in teleop.

Also note, that the code uses the term speed to refer to the commanded value sent out to the motor controller (between 1.0 and -1.0). This is really just the voltage the motor controller will be commanded to output and doesn't have any direct correlation to the speed of travel of the robot. This code doesn't, and isn't intended to, make use of any sensor values in the rate limiter.

If you can post what type of java project you're working in (Simple Robot, Iterative Robot, or Command Based) we could help suggest how to integrate the code a little better.
__________________
http://team2168.org
  #5   Spotlight this post!  
Unread 19-01-2014, 13:54
Zaque Zaque is offline
FF: Bobo Brigade
AKA: Zachary H.
FRC #3352 (Flaming Monkeys)
Team Role: Programmer
 
Join Date: Mar 2013
Rookie Year: 2013
Location: Belvidere, Illinois
Posts: 91
Zaque has a spectacular aura aboutZaque has a spectacular aura aboutZaque has a spectacular aura about
Re: How to make a "Custom VI" in Java?

Thanks for all the responses! Since this is our first year with java, we figured we should start with SimpleRobot and learn iterative or command-based during the off-season.
__________________
Zaque (Zach) H.
President
Programming/Electrical Lead
Closed Thread


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 02:30.

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