Go to Post Consider yourself mentored, you have learned a lesson: "Don't stick your hands in icky things." - Amanda Morrison [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 16-02-2016, 10:13
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
PLZ Fix error

I keep getting error :Error at edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:244): ERROR Unhandled exception: java.lang.RuntimeException: Code: -1029. HAL: Resource already allocated at [edu.wpi.first.wpilibj.hal.PWMJNI.allocatePWMChanne l(Native Method), edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:117), edu.wpi.first.wpilibj.PWM.<init>(PWM.java:134), edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java: 35), edu.wpi.first.wpilibj.Talon.<init>(Talon.java:51), org.usfirst.frc.team5713.robot.Robot.robotInit(Rob ot.java:25), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:242)]

Joystick mXboxController = new Joystick(0); // this will drive the robot
Joystick controlStick = new Joystick(1); // this will be for function of the robot such as toggle the conveyor belt and etc.
Talon frontLeft = new Talon(3);
Talon frontRight = new Talon(2);
Talon rearRight = new Talon(0);
Talon rearLeft = new Talon(1);
public void robotInit() { // this code will be ran each time we power on the robot

mXboxController = new Joystick(0); // depends on the usb connected to computer
controlStick = new Joystick(1);
frontLeft = new Talon(3);
frontRight = new Talon(2);
rearLeft = new Talon(0);
rearRight = new Talon(1);
}


public void autonomousInit() { // triggers when we enter autonomous

frontLeft.enableDeadbandElimination(true);
frontLeft.set(-1.0);// dont forget to change speed to an int value -1.0 is full reverse and +1.0 is full forward also for foward on the y value -1 this may vary REMEBER!!!
rearLeft.enableDeadbandElimination(true);
rearLeft.set(+1.0);
frontRight.enableDeadbandElimination(true);
frontRight.set(-1.0);
rearRight.enableDeadbandElimination(true);
rearRight.set(+1.0);

}


public void autonomousPeriodic() { // this code runs periodically in autonomous
while (isAutonomous() && isEnabled()) {


}
}




public void teleopInit(){ // This triggers every time we enter telop mode.

mXboxController = new Joystick(0); // the number within the parathesis depends on the controllers usb order always check
controlStick = new Joystick(1);
frontLeft = new Talon(3);
frontRight = new Talon(2);
rearLeft = new Talon(0);
rearRight = new Talon(1);

}




public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {




if(mXboxController.getRawButton(8)){
frontRight.set(1.0);


} if(mXboxController.getRawButton(7)){
frontLeft.set(1.0);
}

if(mXboxController.getRawButton(5)){
rearLeft.set(-1.0);
} if(mXboxController.getRawButton(6)){
rearRight.set(-1.0);
}

Timer.delay(0.01); } } // this will constantly update motors and speed controllers periodically
public void testPeriodic() {

LiveWindow.run(); // launches the smartdashboard that allows us to see inputs and out puts to the robot
}

}
Reply With Quote
  #2   Spotlight this post!  
Unread 16-02-2016, 11:31
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: PLZ Fix error

You are attempting to construct your Talon and Joystick objects too many times. Try constructing them just once in robotInit().

Code:
Joystick mXboxController; // this will drive the robot
Joystick controlStick; // this will be for function of the robot such as toggle the conveyor belt and etc.

Talon frontLeft;
Talon frontRight;
Talon rearRight;
Talon rearLeft;

public void robotInit() {	// this code will be ran each time we power on the robot

  // Construct joysticks here
  mXboxController = new Joystick(0); // depends on the usb connected to computer
  controlStick = new Joystick(1);

  // Construct Talons here
  frontLeft = new Talon(3);
  frontRight = new Talon(2);
  rearLeft = new Talon(0);
  rearRight = new Talon(1);
}
Hope that helps.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-02-2016, 11:34
ghead ghead is offline
Registered User
FRC #3103
 
Join Date: Aug 2013
Location: US
Posts: 13
ghead is an unknown quantity at this point
Re: PLZ Fix error

Not a java guy, but I can't imagine creating three instances of your joysticks and talons is a good thing. Try deleting the duplicate initialization in robotInit() and teleopInit() while waiting on someone better equipped to answer you.

<edit>Someone better equipped than I beat me to it. Good luck!</edit>
Reply With Quote
  #4   Spotlight this post!  
Unread 16-02-2016, 12:02
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
Thank you
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 10:28.

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