View Single Post
  #2   Spotlight this post!  
Unread 05-03-2014, 18:20
irvingc irvingc is offline
Registered User
FRC #0948 (Newport Robotics Group)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Bellevue, WA
Posts: 31
irvingc is on a distinguished road
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);
to
Code:
drive = new RobotDrive(RobotMap.frontLeftMotor, RobotMap.rearLeftMotor, RobotMap.frontRightMotor, RobotMap.rearRightMotor);
[ edit ]
And the same change should be applied to the enc variable.

Last edited by irvingc : 05-03-2014 at 18:23.
Reply With Quote