Go to Post The robot competition is the most obvious, visible, and distilled-media-friendly part of the picture... We shouldn't be surprised that it's all that gets into the news coverage, when that coverage is managed by someone who isn't already well versed in what FIRST is trying to do. - Alan Anderson [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 07-31-2016, 07:35 AM
dajp999 dajp999 is offline
Registered User
no team
 
Join Date: Jul 2016
Rookie Year: 2015
Location: USA
Posts: 3
dajp999 is an unknown quantity at this point
FTC NullPointerException

I am a new FTC coach and I am trying to learn Java to support out team. I created 2 classes one which will act as coordinating class which extends OpMode and for now a class representing the RobotDrive. I have done a fair amount of testing and debugging including verifying names of devices in the config file but I still receive a NullPointerException. What am I doing wrong?!?!?!

Here are the 2 classes:

***********************************

package com.qualcomm.ftcrobotcontroller.opmodes;


import com.qualcomm.robotcore.eventloop.opmode.OpMode;

public class Brain extends OpMode {

private int statusDriveInteger = 76;

private RobotDrive rd = new RobotDrive();



public void init (){

statusDriveInteger = rd.statusRobotDrive(1);

telemetry.addData("here ",statusDriveInteger);
}

public void loop (){
rd.setPowerLeftRearDrive(1.0);

}

}





**************************************

package com.qualcomm.ftcrobotcontroller.opmodes;


import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.HardwareMap;




public class RobotDrive {

int erroroccurred;
DcMotor h_leftRearDrive;
private HardwareMap rd_hardwareMap = null;




public int statusRobotDrive (double p_leftRearDrive){
try {
h_leftRearDrive = rd_hardwareMap.dcMotor.get("1");
} catch (Exception p_exception) {
h_leftRearDrive = null;
erroroccurred = 102;

}


return erroroccurred;



}


public void setPowerLeftRearDrive (double p_leftRearDrivePower) {
h_leftRearDrive.setPower(p_leftRearDrivePower);
}

}
Reply With Quote
 


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 08:23 AM.

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