Problems -_-

so our robot has been fitted for talons and we had it working for jaguars and we switched them back to jaguars with jaguar code and isn’t working like it should. anything visible,

package edu.wpi.first.wpilibj.templates;

//Imports wpilib for certain sections of code that are related
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;
import edu.wpi.first.wpilibj.templates.commands.ExampleCommand;
import edu.wpi.first.wpilibj.templates.commands.ShooterDoNothing;
import edu.wpi.first.wpilibj.templates.commands.ShooterOneThird;
import edu.wpi.first.wpilibj.templates.commands.ShooterTwoThirds;
import edu.wpi.first.wpilibj.templates.commands.ShooterWhole;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;


/**
 * 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 RobotTemplate extends IterativeRobot {
       //names all the wpi objects 
       
       
       
       Joystick leftStick = new Joystick(1);
       Joystick rightStick = new Joystick(2);
       Joystick thirdStick = new Joystick(3);
       Jaguar leftdrive = new Jaguar(1);
       Jaguar rightdrive = new Jaguar(2);
       Button shooter1 = new JoystickButton(thirdStick,3);
       Button shooter2 = new JoystickButton(thirdStick,4);
       Button shooter3 = new JoystickButton(thirdStick,5);
       Button shooterStop = new JoystickButton(thirdStick,2);
       Jaguar shooter = new Jaguar(3);
       RobotDrive drive = new RobotDrive(1, 2);
      
       
       
       Command autonomousCommand;
       

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        // instantiate the command used for the autonomous period
       
       
       

        // Initialize all subsystems
        CommandBase.init();
    }
    
    public void autonomousInit() {
        // schedule the autonomous command (example)
        autonomousCommand.start();
        
            drive.setSafetyEnabled(true);
            Timer.delay(2.0);
            drive.drive(-.5,0);
            Timer.delay(2.0);
            drive.drive(+.5,0);
            Timer.delay(2.0);
            drive.drive(0,0);
            Timer.delay(.5);
            
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }   
    
    public void teleopInit() {
	// This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to 
        // continue until interrupted by another command, remove
        // this line or comment it out.
        autonomousCommand.cancel();  
         drive = new RobotDrive(leftdrive,rightdrive);
                
                
                         //Button commands for when the button is pressed
                        shooter1.whenPressed(new ShooterOneThird());
                         shooter2.whenPressed(new ShooterTwoThirds());
                         shooter3.whenPressed(new ShooterWhole());
                         shooterStop.whenPressed(new ShooterDoNothing());
                         
                         
                        
                                   while(isOperatorControl() && isEnabled()){ 
                                    drive.tankDrive(leftStick, rightStick); // drive with the joysticks
                                    Timer.delay(0.01);
                                    }
                          
        }
    /**
     * This function is called periodically during operator control
     */
}

also for some reason at this point into building the code on the robot it stops here and wont continue but still says its in progress.

ant -f C:\\Users\\Sebastian\\Documents\\NetBeansProjects\\Project2012 deploy run
clean:
Deleting directory C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build
Created dir: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build
Created dir: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\classes
[crio-compile] ./src, C:/Users/Sebastian/sunspotfrcsdk\lib\wpilibj.jar;C:/Users/Sebastian/sunspotfrcsdk\lib
etworktables-crio.jar, C:/Users/Sebastian/sunspotfrcsdk\lib\squawk.jar -> ./build/classes
Compiling 12 source files to C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\classes
compile:
preverify:
Created dir: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\preverify
Created dir: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\preverify.raw.util
[crio-preverify] ./build/classes, , C:/Users/Sebastian/sunspotfrcsdk\lib\wpilibj.jar;C:/Users/Sebastian/sunspotfrcsdk\lib
etworktables-crio.jar, C:/Users/Sebastian/sunspotfrcsdk\lib\squawk.jar -> ./build/preverify
Expanding: C:\Users\Sebastian\sunspotfrcsdk\lib\wpilibj.jar into C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\preverify
Expanding: C:\Users\Sebastian\sunspotfrcsdk\lib
etworktables-crio.jar into C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\preverify
jar:
[crio-jar] ./build/preverify, ./resources -> ./build/app.jar
Building jar: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\app.jar
suite:
Created dir: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\suite
[crio-suite] ./build/app.jar -> ./build/suite/image
CompilerOracle: exclude com/sun/squawk/Method.getParameterTypes
CompilerOracle: exclude com/sun/squawk/SymbolParser.getSignatureTypeAt
CompilerOracle: exclude com/sun/squawk/SymbolParser.stripMethods
[translating suite image [closed: false, parent: squawk] ...]
### Excluding compile: com.sun.squawk.Method::getParameterTypes
### Excluding compile: com.sun.squawk.SymbolParser::getSignatureTypeAt
[Including resource: META-INF/MANIFEST.MF]
Romizer processed 388 classes and generated 4 files.
Expanding: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\app.jar into C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\suite
Moving 1 file to C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\suite
Moving 1 file to C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\suite
Moving 1 file to C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\build\suite
Deleting: C:\Users\Sebastian\Documents\NetBeansProjects\Project2012\image.suite.api
deploy:
[crio-configure] Configuration files not included in this version of the sdk
[crio-configure] Checking that crio is configured for Java
Host OS: Windows NT (unknown) 6.2, 6.2
Host JVM: Java HotSpot(TM) 64-Bit Server VM 20.10-b01
Target IP: 10.40.85.2
Network interfaces on host:
    Ralink RT5390 802.11b/g/n WiFi Adapter:  address: 10.40.85.8 netmask: 255.255.255.255 or hidden by IPv6 address (due to Java on Windows Bug:6707289)
Connecting FTP @10.40.85.2
[crio-deploy] ./build/suite/image.suite -> 10.40.85.2
Sending local file image.suite
run:
   Waiting for cRIO to reboot (1s)
   Waiting for cRIO to reboot (2s)
   Waiting for cRIO to reboot (3s)
   Waiting for cRIO to reboot (4s)
   Waiting for cRIO to reboot (5s)
   Waiting for cRIO to reboot (6s)
   Waiting for cRIO to reboot (7s)
[cRIO] 
[cRIO] -> * Loading debug.o: debug
[cRIO] Debugging is up, target server mounted at /tsfs
[cRIO] 
[cRIO] 
[cRIO]                 VxWorks
[cRIO] 
[cRIO] Copyright 1984-2006  Wind River Systems, Inc.
[cRIO] 
[cRIO]              CPU: cRIO-FRC II
[cRIO]     Runtime Name: VxWorks
[cRIO]  Runtime Version: 6.3
[cRIO]      BSP version: 1.0/0
[cRIO]          Created: Jun 14 2012, 08:43:39
[cRIO] ED&R Policy Mode: Deployed
[cRIO]    WDB Comm Type: WDB_COMM_END
[cRIO]              WDB: Ready.
[cRIO] 
[cRIO] * Loading nisysrpc.out: nisysrpc
[cRIO] * Loading NiRioRpc.out: NiRioRpc
[cRIO] * Loading nivissvc.out: nivissvc
[cRIO] * Loading nivision.out: nivision
[cRIO] NI-RIO Server 12.0.0b10 started successfully.
[cRIO] task 0xe1d640 (NiRioRpc) deleted: errno=0 (0) status=0 (0)
[cRIO] * Loading visa32.out: visa32
[cRIO] * Loading niserial.out: niserial
[cRIO] * Loading NiFpgaLv.out: NiFpgaLv
[cRIO] * Loading FRC_FPGA.out: FRC_FPGA
[cRIO] * Loading FRC_NetworkCommunication.out: FRC_NetworkCommunication
[cRIO] FRC_NetworkCommunication version: p4-1.4.0a10
[cRIO] FPGA Hardware GUID: 0x1394F6DC1FEB42EC6910E5767ED1D22C
[cRIO] FPGA Software GUID: 0x1394F6DC1FEB42EC6910E5767ED1D22C
[cRIO] FPGA Hardware Version: 2012
[cRIO] FPGA Software Version: 2012
[cRIO] FPGA Hardware Revision: 1.6.4
[cRIO] FPGA Software Revision: 1.6.4
[cRIO] * Loading FRC_JavaVM.out: FRC_JavaVM
[cRIO] 
[cRIO] Welcome to LabVIEW Real-Time 12.0rc7
[cRIO] task 0xd22648 (sysapi-rpc) deleted: errno=0 (0) status=0 (0)
[cRIO] 
[cRIO] [Squawk VM] Version: 2011 FRC, Nov  5 2011, 14:34:13
[cRIO] FPGA Hardware GUID: 0x1394f6dc1feb42ec6910e5767ed1d22c
[cRIO] FPGA Software GUID: 0xa14c11bde4bb64aef6a86fc52a294cd9
[cRIO] Uncaught exception in Thread.run():
[cRIO]     on thread edu.wpi.first.wpilibj.templates.RobotTemplate - main
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: PWM channel 1 on module 1 is already allocated
[cRIO]     at edu.wpi.first.wpilibj.PWM.initPWM(PWM.java:116)
[cRIO]     at edu.wpi.first.wpilibj.PWM.<init>(PWM.java:146)
[cRIO]     at edu.wpi.first.wpilibj.SafePWM.<init>(SafePWM.java:33)
[cRIO]     at edu.wpi.first.wpilibj.Jaguar.<init>(Jaguar.java:44)
[cRIO]     at edu.wpi.first.wpilibj.RobotDrive.<init>(RobotDrive.java:91)
[cRIO]     at edu.wpi.first.wpilibj.templates.RobotTemplate.<init>(RobotTemplate.java:58)
[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)
[cRIO] edu.wpi.first.wpilibj.networktables2.server.ServerConnectionAdapter@8 entered connection state: GOT_CONNECTION_FROM_CLIENT
[cRIO] edu.wpi.first.wpilibj.networktables2.server.ServerConnectionAdapter@8 entered connection state: CONNECTED_TO_CLIENT
BUILD STOPPED (total time: 2 minutes 36 seconds)

In the constructor for RobotDrive, if you pass it numbers, it will construct Jaguars for you.
So, but constructing your own, you created two Jaguar objects for the Jaguar on PWM 1, but you can only have one object for each Jaguar, so it crashed.

Just replace

RobotDrive drive = new RobotDrive(1, 2);

with

RobotDrive drive = new RobotDrive(leftdrive , rightdrive);

Edit: Also, if you never use leftdrive or rightdrive, you can just remove the code that says

Jaguar leftdrive = new Jaguar(1);
       Jaguar rightdrive = new Jaguar(2);

because the RobotDrive constructor will make them for you, though I like having the Jaguar/Victor/Talon objects declared, it just looks nicer.

----Edit------
John beat me too it:)

The post above is correct.

For future reference you may want to look into handling exceptions in Java. This article in the Java documentation explains exceptions pretty well:http://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html

This is your problem:

[cRIO] Uncaught exception in Thread.run():
[cRIO] on thread edu.wpi.first.wpilibj.templates.RobotTemplate - main
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: PWM channel 1 on module 1 is already allocated

Take a look in here:

   Joystick leftStick = new Joystick(1);
   Joystick rightStick = new Joystick(2);
   Joystick thirdStick = new Joystick(3);
   Jaguar leftdrive = new Jaguar(1);
   Jaguar rightdrive = new Jaguar(2);
   Button shooter1 = new JoystickButton(thirdStick,3);
   Button shooter2 = new JoystickButton(thirdStick,4);
   Button shooter3 = new JoystickButton(thirdStick,5);
   Button shooterStop = new JoystickButton(thirdStick,2);
   Jaguar shooter = new Jaguar(3);
   RobotDrive drive = new RobotDrive(1, 2);

and

drive = new RobotDrive(leftdrive,rightdrive);

is this any better

Joystick leftStick = new Joystick(1);
       Joystick rightStick = new Joystick(2);
       Joystick thirdStick = new Joystick(3);
       Button shooter1 = new JoystickButton(thirdStick,3);
       Button shooter2 = new JoystickButton(thirdStick,4);
       Button shooter3 = new JoystickButton(thirdStick,5);
       Button shooterStop = new JoystickButton(thirdStick,2);
       Jaguar leftdrive;
       Jaguar rightdrive;
       RobotDrive drive = new RobotDrive(leftdrive,rightdrive);
       Command autonomousCommand;

OK, a few things…

You should create instances of the objects that you are going to use in the RobotInit method (or some other code that will only be executed once). In your original post at the top of the thread, you are creating the RobotDrive instances in TeleopInit() which means it won’t be available in your Autonomous code since it hasn’t been created yet.

So I would move all the sensor and actuator creation code to the RobotInit method since that will only be called once per run of the robot. That ensures you won’t be trying to recreate something or forgetting to create it on either the autonomous or teleop path.

Also in the last post you did something like this:

Jaguar leftdrive;
Jaguar rightdrive;
RobotDrive drive = new RobotDrive(leftdrive, rightdrive);

In this case you are allocating two references to Jaguar objects, but you have not yet allocated the objects themselves. This is done using the new operator. So what you need is something like this:

Jaguar leftDrive = new Jaguar(1);
Jaguar rightDrive = new Jaguar(2);
RobotDrive drive = new RobotDrive(leftDrive, rightDrive);

Here the leftDrive and rightDrive Jaguar objects are allocated before using them to create the RobotDrive object.

You also might want to look at RobotBuilder to create this part of the program since it will create the structure of the program for you with all this housekeeping already done in the generated program. There are some videos that describe how to use it in:

http://www.youtube.com/user/bradamiller.

and more documentation:

http://wpilib.screenstepslive.com/s/3120/m/7882

Good luck!

Brad

Thank you :frowning: we’ve been having large problems, we are all new to java and haven’t touched code before so i really appreciate the help. I’m a hands on learner so once i learn it i can go off it and learn more. Thank you