Go to Post So let me get this straight. We'll have 6 hours to re-build an entirely new robot that took us 6 weeks originally to make. - [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 06-02-2016, 14:46
jayjay jayjay is offline
Registered User
no team
 
Join Date: Feb 2016
Posts: 2
jayjay is an unknown quantity at this point
Any help appreciated

I have written a simple java program to test our 2016 bot. I have update the firmware, image and jre on our 2015 roborio, and updated to the latest version of Eclipse. Our drive consists of four motors – one Talon controller with a y-splitter controls the two left motors, and another Talon with a y-splitter controls the two right motors.

The bot works with a simple arcade drive coded in the teleop method. When I add the setInvertedMotors code (which worked last year), I get “no code” on the bot, a red comm light on the roborio, and the following error:

ERROR Unhandled exception: java.lang.NullPointerException at [edu.wpi.first.wpilibj.RobotDrive.setInvertedMotor( RobotDrive.java:703), org.usfirst.frc.team4951.robot.Robot.robotInit(Rob ot.java:38), edu.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:241)]

Here is my code:

Code:
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.RobotDrive.MotorType;

public class Robot extends IterativeRobot {
    final String defaultAuto = "Default";
    final String customAuto = "My Auto";
    String autoSelected;
    SendableChooser chooser;
    
    RobotDrive myDrive;
    Joystick stick0, stick1;
	
    public void robotInit() {
        chooser = new SendableChooser();
        chooser.addDefault("Default Auto", defaultAuto);
        chooser.addObject("My Auto", customAuto);
        SmartDashboard.putData("Auto choices", chooser);
        
        myDrive = new RobotDrive(0,1); // 0 = left, 1 = right

        stick0 = new Joystick(0);
        stick1 = new Joystick(1);
        
        myDrive.setInvertedMotor(MotorType.kFrontLeft, true);
        myDrive.setInvertedMotor(MotorType.kRearLeft, true);
        
    }
    
    public void autonomousInit() {
    	//autoSelected = (String) chooser.getSelected();
//		autoSelected = Smart;Dashboard.getString("Auto Selector", defaultAuto);
		//System.out.println("Auto selected: " + autoSelected);
    }

    public void autonomousPeriodic() {
    	switch(autoSelected) {
    	case customAuto:
        //Put custom auto code here   
            break;
    	case defaultAuto:
    	default:
    	//Put default auto code here
            break;
    	}
    }

    public void teleopPeriodic() {
        myDrive.arcadeDrive(stick0);
    }

    public void testPeriodic() {
    
    } 
}
Any help with the error would be appreciated. Thanks.
 


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 20:02.

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