Go to Post Remember, there are many differents path to obtaining knowledge. There's no need to pigeonhole the process. - Karthik [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 23-01-2015, 15:10
AnnaliseD AnnaliseD is offline
Registered User
None #4284
 
Join Date: Jan 2015
Location: Cinncinnati, Ohio
Posts: 4
AnnaliseD is an unknown quantity at this point
Driver Station Log Errors

Every time that we run the code we enable the robot and then it disables and displays the error :
ERROR Unhandled exception: edu.wpi.first.wpilibj.util.AllocationException: PWM channel 4 is already allocated at [edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:126), edu.wpi.first.wpilibj.PWM.<init>(PWM.java:145), edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java: 33), edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:48 ), org.usfirst.frc.team4284.robot.Robot.teleopPeriodi c(Robot.java:68), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]

We had a jaguar plugged into port 4 and then we un plugged it and it sill displays that error.
Reply With Quote
  #2   Spotlight this post!  
Unread 23-01-2015, 15:14
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Driver Station Log Errors

The error is related to your software, not the hardware configuration. Line 68 of your robot.java is creating a new Jaguar object on PWM 4. However, somewhere earlier in your code, you already created an object that is using PWM 4.

If you post your code, we could give more specific answers.
Reply With Quote
  #3   Spotlight this post!  
Unread 23-01-2015, 15:25
AnnaliseD AnnaliseD is offline
Registered User
None #4284
 
Join Date: Jan 2015
Location: Cinncinnati, Ohio
Posts: 4
AnnaliseD is an unknown quantity at this point
Re: Driver Station Log Errors

I tried changing the input and i still got this error

ERROR Unhandled exception: edu.wpi.first.wpilibj.util.AllocationException: PWM channel 4 is already allocated at [edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:126), edu.wpi.first.wpilibj.PWM.<init>(PWM.java:145), edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java: 33), edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:48 ), org.usfirst.frc.team4284.robot.Robot.teleopPeriodi c(Robot.java:68), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]
Reply With Quote
  #4   Spotlight this post!  
Unread 23-01-2015, 15:27
AnnaliseD AnnaliseD is offline
Registered User
None #4284
 
Join Date: Jan 2015
Location: Cinncinnati, Ohio
Posts: 4
AnnaliseD is an unknown quantity at this point
Re: Driver Station Log Errors

If it helps heres my code

package org.usfirst.frc.team4284.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
Jaguar FL = new Jaguar (0);
Jaguar BL = new Jaguar (1);
Jaguar FR = new Jaguar (2);
Jaguar BR = new Jaguar (3);
Drive = new RobotDrive(FL,BL,FR,BR);
drivestick = new Joystick(0);
}

/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
Drive.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
Drive.drive(0.0, 0.0); // stop robot
}
}

/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){

}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
Drive.arcadeDrive(drivestick);

{
Jaguar leftArm = new Jaguar(5);
Jaguar rightArm = new Jaguar(6);
/* Jaguar retract = new Jaguar(7); */

if (drivestick.getRawButton(4))
leftArm.set (-1);
rightArm.set (1);

try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
leftArm.set(0.0);
rightArm.set(0.0);

if (drivestick.getRawButton(5))
leftArm.set(1);
rightArm.set(-1);

try {
Thread.sleep(500);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
leftArm.set(0.0);
rightArm.set(0.0);


/* if(drivestick.getRawButton(8))
retract.set(1);
try {
Thread.sleep(1000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
retract(0.0);

if(drivestick.getRawButton(9))
retract.set(-1);

try {
Thread.sleep(1000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
retract(0.0);
*/
}



}

/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}

}
Reply With Quote
  #5   Spotlight this post!  
Unread 23-01-2015, 16:35
AnnaliseD AnnaliseD is offline
Registered User
None #4284
 
Join Date: Jan 2015
Location: Cinncinnati, Ohio
Posts: 4
AnnaliseD is an unknown quantity at this point
Re: Driver Station Log Errors

After changing the input locations i still get this error

ERROR Unhandled exception: edu.wpi.first.wpilibj.util.AllocationException: PWM channel 5 is already allocated at [edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:126), edu.wpi.first.wpilibj.PWM.<init>(PWM.java:145), edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java: 33), edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:48 ), org.usfirst.frc.team4284.robot.Robot.teleopPeriodi c(Robot.java:68), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:150), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:234)]



heres the section of code it refers to


Jaguar leftArm = new Jaguar(1);
Jaguar rightArm = new Jaguar(2);
Jaguar retract = new Jaguar(3);

if (drivestick.getRawButton(4))
leftArm.set (-1);
rightArm.set (1);

try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
leftArm.set(0);
rightArm.set(0);

if (drivestick.getRawButton(5))
leftArm.set(1);
rightArm.set(-1);

try {
Thread.sleep(500);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
leftArm.set(0);
rightArm.set(0);


if(drivestick.getRawButton(8))
retract.set(1);
try {
Thread.sleep(1000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
retract.set(0);

if(drivestick.getRawButton(9))
retract.set(-1);

try {
Thread.sleep(1000); //1000 milliseconds is one second.
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
retract.set(0);
Reply With Quote
  #6   Spotlight this post!  
Unread 23-01-2015, 16:38
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,713
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Driver Station Log Errors

You don't want to be instantiating your motor controllers inside of the teleopPeriodic method. That needs done in robotInit().

Also, please use code tags to make your code easier yo read in a forum setting.
Reply With Quote
  #7   Spotlight this post!  
Unread 24-01-2015, 11:52
MamaSpoldi's Avatar
MamaSpoldi MamaSpoldi is offline
Programming Mentor
AKA: Laura Spoldi
FRC #0230 (Gaelhawks)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Shelton, CT
Posts: 305
MamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant future
Yes. Instantiating your motor controllers in the periodic function makes it try to create another object each time it is called. So the second time it is called it is creating another object attached to the same PWM. You should do the object creation in the constructor.
__________________
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 08:37.

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