![]() |
Defining/Setting a motor in Java
I am trying to run a VERY SIMPLE piece of Java.
Its only goal is to set a motor's speed to 0.5. Yet I have difficulties with even this simple task: Code:
package org.usfirst.frc.team4855.robot;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.team4855.robot.Robot.robotInit(Rob ot.java:31), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:241)] WARNING: Robots don't quit! Give it enough time and the robot will just reach an emergency stopped state without any apparent reason. What in the world am I doing wrong |
Re: Defining/Setting a motor in Java
First, the 50% code should be in teleopPeriodic, not init (so it keeps getting called over and over again).
Second, you're creating the talon at least twice. Your code isn't complete so I can't see where else it's being constructed. |
Re: Defining/Setting a motor in Java
Thanks, put the code in teleopPeriodic.
I'm confused with your second point. The code I posted is all the code there is. |
Re: Defining/Setting a motor in Java
I have always written it in one line directly under the class statement not in robotinit.
Talon motor = new Talon(0); Your problem may be from splitting it up. |
Re: Defining/Setting a motor in Java
Quote:
|
Re: Defining/Setting a motor in Java
The error stack shows Robot.java:31, meaning line 31. You don't have 31 lines posted in your thread.
And you're missing a curly brace to close the class. The above by itself wouldn't compile. |
Re: Defining/Setting a motor in Java
That's because I had a bunch of blank space and comments that I got rid of when I copied and pasted the code here
I'm no longer getting errors in the console after moving to teleopPeriodic. But the motors still won't move. I checked the motors earlier by hooking them up to our battery. They work fine... |
Re: Defining/Setting a motor in Java
I am having the same issue. I am trying to execute EXTREMELY basic code (operating a Victor). Yet, whenever I try to execute the code, nothing happens and my console gives no hints. Even the sample code does nothing to the robot right now. It successfully deploys yet does nothing.
|
Re: Defining/Setting a motor in Java
Nevermind. It was a stupid electrical error. I thought I had checked the system thoroughly but apparently I hadn't.
Thanks for letting me know it wasn't the code's fault. |
Re: Defining/Setting a motor in Java
Quote:
|
| All times are GMT -5. The time now is 10:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi