|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: How do I upload code to the Robot with Java?
Quote:
|
|
#2
|
||||
|
||||
|
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) |
|
#3
|
||||
|
||||
|
Re: How do I upload code to the Robot with Java?
code plz?
|
|
#4
|
|||
|
|||
|
Re: How do I upload code to the Robot with Java?
Quote:
Code:
new PWM(3); |
|
#5
|
||||
|
||||
|
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;
|
|
#6
|
|||
|
|||
|
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); 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; ![]() |
|
#7
|
||||
|
||||
|
Re: How do I upload code to the Robot with Java?
Ahh, noob mistake. Haven't touched java in forevers. Thanks All.
|
|
#8
|
|||
|
|||
|
Re: How do I upload code to the Robot with Java?
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.
|
|
#9
|
|||
|
|||
|
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; 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() {
Code:
RobotDrive driveRobot = new RobotDrive(1, 3, 2, 4); Code:
RobotDrive driveRobot = new RobotDrive(jagFrontLeft,jagBackLeft,jagFrontRight,jagBackRight); |
|
#10
|
|||
|
|||
|
Re: How do I upload code to the Robot with Java?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|