Go to Post As a Mississippi boy, I'm especially proud that I could read - Natchez [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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.
  #2   Spotlight this post!  
Unread 06-02-2016, 15:39
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,275
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Any help appreciated

I don't know Java, but my guess is skip using robotdrive.motortype. That class presumes 4 control signals, whereas you only have 2.

Use robotdrive(left channel, right channel) to set your motor channels.

Also, I presume you are using one motor controller per motor, and splitting the Pwm signal. You can't drive 2 cim motors with one controller.
  #3   Spotlight this post!  
Unread 06-02-2016, 16:00
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,600
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: Any help appreciated

Quote:
Originally Posted by rich2202 View Post
I don't know Java, but my guess is skip using robotdrive.motortype. That class presumes 4 control signals, whereas you only have 2.
Close. It should work with 2, but you have to use the correct 2. It should be kRearLeft and kRearRight.
  #4   Spotlight this post!  
Unread 07-02-2016, 09:52
jayjay jayjay is offline
Registered User
no team
 
Join Date: Feb 2016
Posts: 2
jayjay is an unknown quantity at this point
Re: Any help appreciated

Rich/Joe, thanks for the helpful advice.

I will do what Joe has suggested. Thanks again.
Closed Thread


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 01:29.

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