Go to Post if you've got the guts you will get the job done. - JamesCH95 [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 28-01-2011, 14:39
mastergamer1231's Avatar
mastergamer1231 mastergamer1231 is offline
Registered User
FRC #0869
 
Join Date: Jan 2009
Location: Middlesex
Posts: 8
mastergamer1231 is an unknown quantity at this point
Exclamation How do I upload code to the Robot with Java?

Hi everyone,

Our team has just realised something, we don't know how to upload code with Java! This is our first year with Java and we have Netbeans 6.9.1.

Thanks in advance!
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2011, 15:16
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: How do I upload code to the Robot with Java?

First question: have you reimaged the cRio to accept Java?

Assuming you have sorted that out it's pretty simple. You connect your computer to the cRio with a crossover cable, and then in Netbeans hit "Run". The actual routines to copy it over to the bot are handled by Netbeans.
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2011, 21:57
el-zoroo el-zoroo is offline
Chief Operating Officer
AKA: Zuhair
FRC #2374 (Crusaderbots)
Team Role: Leadership
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Beaverton, OR
Posts: 13
el-zoroo is an unknown quantity at this point
Re: How do I upload code to the Robot with Java?

Hi,

In the ideal world, the steps to download Java are:

1) Reimage the cRIO with the Java specific image.
2) Update Netbeans with the FRC plugins.
3) In Netbeans, in Tools>Options>Misc>FRC Configuration, update the Team Number.
4) Hit Run and cross your fingers

I assume all your networking is up and running properly (i.e., you should be able to ping the cRIO).

You can find more detailed information at How to Build and Load Programming in LabVIEW, C++, and Java

Hope that helps!
Reply With Quote
  #4   Spotlight this post!  
Unread 31-01-2011, 18:02
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: How do I upload code to the Robot with Java?

Quote:
Originally Posted by wdell View Post
First question: have you reimaged the cRio to accept Java?

Assuming you have sorted that out it's pretty simple. You connect your computer to the cRio with a crossover cable, and then in Netbeans hit "Run". The actual routines to copy it over to the bot are handled by Netbeans.
It should be noted that while many of the instructional documents that FIRST provides say that the user should use a crossover cable, it is only necessary between the camera and the cRIO. The bridge, classmate, and most other modern devices (computers, routers, etc.) have auto switching ports that will make a non crossover cable into a crossover if needed. This makes it a lot easier to acquire cables since crossovers are hard to find.
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
Reply With Quote
  #5   Spotlight this post!  
Unread 31-01-2011, 20:04
Omgsar's Avatar
Omgsar Omgsar is offline
Registered User
AKA: Evan Gray
FRC #2745 (S.A.R.)
Team Role: Programmer
 
Join Date: Apr 2009
Rookie Year: 2008
Location: San Antonio
Posts: 7
Omgsar is an unknown quantity at this point
Re: How do I upload code to the Robot with Java?

Our team is having the same issue,
Code:
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: PWM channel 3 on module 4 is already allocated
[cRIO]     at edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:112)
[cRIO]     at edu.wpi.first.wpilibj.PWM.<init>(PWM.java:141)
[cRIO]     at edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java:33)
[cRIO]     at edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:41)
[cRIO]     at edu.wpi.first.wpilibj.RobotDrive.<init>(RobotDrive.java:110)
[cRIO]     at edu.wpi.first.wpilibj.templates.Team2745Robot.<init>(Team2745Robot.java:27)
[cRIO]     in virtual method #11 of com.sun.squawk.Klass(bci=53)
[cRIO]     at com.sun.squawk.imp.MIDletMainWrapper.main(99)
[cRIO]     in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO]     at com.sun.squawk.Isolate.run(1506)
[cRIO]     at java.lang.Thread.run(231)
[cRIO]     in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO]     in static method #3 of com.sun.squawk.VM(bci=6)
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2011, 20:28
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: How do I upload code to the Robot with Java?

code plz?
Reply With Quote
  #7   Spotlight this post!  
Unread 31-01-2011, 20:31
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: How do I upload code to the Robot with Java?

Quote:
Originally Posted by Omgsar View Post
Our team is having the same issue,
Code:
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: PWM channel 3 on module 4 is already allocated
[cRIO]     at edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:112)
[cRIO]     at edu.wpi.first.wpilibj.PWM.<init>(PWM.java:141)
[cRIO]     at edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java:33)
[cRIO]     at edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:41)
[cRIO]     at edu.wpi.first.wpilibj.RobotDrive.<init>(RobotDrive.java:110)
[cRIO]     at edu.wpi.first.wpilibj.templates.Team2745Robot.<init>(Team2745Robot.java:27)
[cRIO]     in virtual method #11 of com.sun.squawk.Klass(bci=53)
[cRIO]     at com.sun.squawk.imp.MIDletMainWrapper.main(99)
[cRIO]     in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO]     at com.sun.squawk.Isolate.run(1506)
[cRIO]     at java.lang.Thread.run(231)
[cRIO]     in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO]     in static method #3 of com.sun.squawk.VM(bci=6)
You allocated the same PWM twice. Look in your code for the following line:
Code:
new PWM(3);
If you find two of them, delete one of them. If you find one, something else is wrong and I can't help unless I get more code.
Reply With Quote
  #8   Spotlight this post!  
Unread 31-01-2011, 21:10
Omgsar's Avatar
Omgsar Omgsar is offline
Registered User
AKA: Evan Gray
FRC #2745 (S.A.R.)
Team Role: Programmer
 
Join Date: Apr 2009
Rookie Year: 2008
Location: San Antonio
Posts: 7
Omgsar is an unknown quantity at this point
Re: How do I upload code to the Robot with Java?

Here are all of our declarations:
Code:
 public Joystick leftStick = new Joystick(1);
    public Joystick rightStick = new Joystick(2);
  public Jaguar jagFrontLeft = new Jaguar(1);
  public Jaguar jagFrontRight = new Jaguar(2);
   public Jaguar jagBackLeft = new Jaguar(3);
    public Jaguar jagBackRight = new Jaguar(4);
    public RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
    public Gyro roboGyro = new Gyro(7);
    double leftX =0;
    double leftY =0;
    double rotationRate =0;
    double gyroAngle =0;
    int i = 0;
Reply With Quote
  #9   Spotlight this post!  
Unread 31-01-2011, 21:37
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: How do I upload code to the Robot with Java?

Quote:
Originally Posted by buildmaster5000 View Post
It should be noted that while many of the instructional documents that FIRST provides say that the user should use a crossover cable, it is only necessary between the camera and the cRIO. The bridge, classmate, and most other modern devices (computers, routers, etc.) have auto switching ports that will make a non crossover cable into a crossover if needed. This makes it a lot easier to acquire cables since crossovers are hard to find.
Thank you! I've been using a crossover cable that for some reason needs one particular end plugged into the cRio, and it's driving me nuts. I do it all wireless now so I don't have to keep track of that $@#$@#$@#$@# cable!
Reply With Quote
  #10   Spotlight this post!  
Unread 31-01-2011, 21:40
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: How do I upload code to the Robot with Java?

Quote:
Originally Posted by Omgsar View Post
Our team is having the same issue,
Code:
(Team2745Robot.java:27)
If I'm reading that right look at line 27 in Team2745.java. Or post the first 27 lines of that class so we can take a look at it.
Reply With Quote
  #11   Spotlight this post!  
Unread 31-01-2011, 21:49
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: How do I upload code to the Robot with Java?

kk, in your declarations most of that doesn't need to be public. Try:

Code:
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
Jaguar jagFrontLeft = new Jaguar(1);
Jaguar jagFrontRight = new Jaguar(2);
Jaguar jagBackLeft = new Jaguar(3);
Jaguar jagBackRight = new Jaguar(4);
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
Gyro roboGyro = new Gyro(7);
double leftX =0;
double leftY =0;
double rotationRate =0;
double gyroAngle =0;
int i = 0;
Here's the first chunk of mine:

Code:
package edu.wpi.first.wpilibj.templates;

/**
 * @author   William Dell
 * @author   Team 647
 * @version  v7, January 29, 2011
 * @version  FRC Java version 2011.4
 */

import edu.wpi.first.wpilibj.SimpleRobot;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;

import edu.wpi.first.wpilibj.Gyro;

import edu.wpi.first.wpilibj.Victor;
// import edu.wpi.first.wpilibj.Jaguar;  // for change to production bot
import edu.wpi.first.wpilibj.RobotDrive;

public class Main extends SimpleRobot {

    DStation station; // consolidated, simplified dash and driver station
    Joystick controllerOne = new Joystick(1);
    Timer timer = new Timer(); // one timer to rule them all....
    Gyro spinGyro = new Gyro(1);
    Kamera cam;  // consolidated web cam controller
    
    //------------Drive System-----------------//
    Victor leftFrontVictor = new Victor(1);
    Victor rightFrontVictor = new Victor(2);
    RobotDrive drive = new RobotDrive(leftFrontVictor, rightFrontVictor);

    /*  4 motor drive for production bot commented out here
    Jaguar leftFrontJaguar = new Jaguar(1);
    Jaguar leftRearJaguar = new Jaguar(2);
    Jaguar rightFrontJaguar = new Jaguar(3);
    Jaguar rightRearJaguar = new Jaguar(4);
    RobotDrive drive = new RobotDrive(leftFrontJaguar, leftRearJaguar,
    rightFrontJaguar, rightRearJaguar);
     */
    AutoDrive autodrive; // simple autonomous routines

    /**
     * This method is called once when the robot boots up.
     */
    public void robotInit() {
AND I just found your problem. You're declaring your robot drive wrong. You have
Code:
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
when you should have
Code:
RobotDrive driveRobot = new RobotDrive(jagFrontLeft,jagBackLeft,jagFrontRight,jagBackRight);
What was happening is it would hit the Jaguar declaration and assign the PWM port to the jag. Then you're RobotDrive declaration would try to assign the PWM ports directly instead of going through the jaguars.
Reply With Quote
  #12   Spotlight this post!  
Unread 31-01-2011, 23:27
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: How do I upload code to the Robot with Java?

Code:
 public Joystick leftStick = new Joystick(1);
public Joystick rightStick = new Joystick(2);
/* Here, the cRIO allocates slot 1-4 of the PWM. 
Which means if you try to allocate them again in 
another part of the code, you'll get errors. */
public Jaguar jagFrontLeft = new Jaguar(1);
public Jaguar jagFrontRight = new Jaguar(2);
public Jaguar jagBackLeft = new Jaguar(3);
public Jaguar jagBackRight = new Jaguar(4);
/* See? Here, you're allocating the EXACT SAME 
PWM slots AGAIN. Which creates problems and are
 most likely the cause of your problem. */
public RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
Comments in navy blue. Here's the solution:
Code:
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
/* Code removed because it creates problems */
// Jaguar jagFrontLeft = new Jaguar(1);
// Jaguar jagFrontRight = new Jaguar(2);
// Jaguar jagBackLeft = new Jaguar(3);
// Jaguar jagBackRight = new Jaguar(4);
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4);
Gyro roboGyro = new Gyro(7);
double leftX =0;
double leftY =0;
double rotationRate =0;
double gyroAngle =0;
int i = 0;
Edit: Darn. Someone beat me to it.
Reply With Quote
  #13   Spotlight this post!  
Unread 31-01-2011, 23:50
Omgsar's Avatar
Omgsar Omgsar is offline
Registered User
AKA: Evan Gray
FRC #2745 (S.A.R.)
Team Role: Programmer
 
Join Date: Apr 2009
Rookie Year: 2008
Location: San Antonio
Posts: 7
Omgsar is an unknown quantity at this point
Re: How do I upload code to the Robot with Java?

Ahh, noob mistake. Haven't touched java in forevers. Thanks All.
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 11: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