|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Using robotdrive in 2 commands
I am using one Subsystem that has methods for driving based on encoders and driving based on double input. I have been doing some scrounging and borrowed some code from various places.
the subsystem looks like this DriveTrain the commands used are DriveWithJoystick and DriveToDistance DriveToDistance (this one doesnt do anything i commented out the autodrive part) DriveWithJoysticks Im stumped because when i deploy my code to the robot it gives a null pointer exception at the lines that reference the mechanum part Code:
[cRIO] java.lang.NullPointerException [cRIO] at us.mn.k12.fairmont.robotics.subsystems.DriveTrain.driveMechanum_Cartesian(DriveTrain.java:37) [cRIO] at us.mn.k12.fairmont.robotics.commands.DriveWithJoysticks.execute(DriveWithJoysticks.java:25) |
|
#2
|
|||
|
|||
|
Re: Using robotdrive in 2 commands
Using one subsystem in multiple commands is the correct usage pattern - there's no need to get around it.
The problem is that in your DriveTrain constructor, you declare and instantiate a local RobotDrive object instead of initializing the member variable. The quickest fix is just to remove the data type, i.e. change: Code:
RobotDrive drive = new RobotDrive(RobotMap.frontLeftMotor, RobotMap.rearLeftMotor, RobotMap.frontRightMotor, RobotMap.rearRightMotor); Code:
drive = new RobotDrive(RobotMap.frontLeftMotor, RobotMap.rearLeftMotor, RobotMap.frontRightMotor, RobotMap.rearRightMotor); And the same change should be applied to the enc variable. Last edited by irvingc : 05-03-2014 at 18:23. |
|
#3
|
|||
|
|||
|
Re: Using robotdrive in 2 commands
Thank you very much! I will be testing it shortly.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|