Go to Post FIRST is our Hunger Games. May the odds be ever in your favor. - GeorgeM [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-03-2014, 17:16
fireXtract fireXtract is offline
MegaHertz_Lux
FRC #2847 (Mega Hertz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: fmt
Posts: 42
fireXtract is an unknown quantity at this point
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)
Anything else needed to solve the problem i can put into a pastebin but i dont know how to get around using the drive in 2 places.
Reply With Quote
  #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
  #3   Spotlight this post!  
Unread 06-03-2014, 09:47
fireXtract fireXtract is offline
MegaHertz_Lux
FRC #2847 (Mega Hertz)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: fmt
Posts: 42
fireXtract is an unknown quantity at this point
Re: Using robotdrive in 2 commands

Thank you very much! I will be testing it shortly.
Reply With Quote
Reply


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 12:41.

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