Go to Post FIRST is not about robots or which roller coaster we get to ride... it is about people. - Andy Baker [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 13-09-2011, 18:41
jhellr13 jhellr13 is offline
Registered User
FRC #4272
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: US
Posts: 187
jhellr13 is an unknown quantity at this point
Java Code Help

Hey guys
I am the programmer on my team, and I am trying to make the transition to java from LabVIEW. I want to get make the labview code from last year into java so i can experiment. I am currently taking ap computer science, and have some knowledge of how java works, but not great at doing the code yet.I have the java code from an alumni from 2 years ago, but it a little too complex for me at this stage. I tried replicating this code for what our robot currently does, but I have no clue if it will work let alone if it is right.
I basically tried to make an arcade drive where the right joystick is the drivestick, and to make the arm operate on the left joystick as the y axis. The arm runs with a Relay. I don't have an autonomous, so i just left that blank. I also am unsure of how to make the dial on the bottom of the joystick control the speed of the drivetrain. It basically worked where if the dial was at the top, the speed was the highest, middle was middle speed, and at the bottom, the speed was low. I do not know how to implement this, if anyone can help.
If anyone can look over the attached code, it would be greatly appreciated. Any helpful tips or corrections would be a great help.
Attached Files
File Type: zip 2011Bot.zip (7.5 KB, 23 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 13-09-2011, 23:19
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: Java Code Help

Personally, I would say that you are trying to do too much right now. It is better to KEEP THINGS SIMPLE!!!!
Using multiple files is great, but to a large degree, it is more clutter than it is helpful, espcially at the stage you are in. You could combine all of your code into Main.java and it would make life simpler IMO.

On a different note, this code:
Code:
 Joystick stick = (lstick.getRawButton(1));
           if (stick.getRawButton(1)) arm.raiseLowArm();
is not doing what you want to (which I am assuming is to raise the arm when you press the trigger.) I think you are looking for something closer to:
Code:
 if (lstick.getRawButton(1)))
			  *relay_obj*.set(Relay.Value.kForward);
when *relay_obj* is a relay object created in the Main.java file. It really helps to look at the documentation for this stuff, which is included locally with the netbeans plugin at C:\Users\*username*\sunspotfrcsdk\doc\javadoc\edu\ wpi\first\wpilibj.

Concerning your ArcadeDrive class, it is already defined for you in RobotDrive, so there is no point in rewriting it. Also, you never call a method that would set the wheel speeds or change the state of the relay, so the code will do nothing visible to the operator. Try creating a robotDrive object and calling the arcadeDrive method on that object.....again, read the documentation here.

Feel free to PM me if you need anything else!
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
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 22: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