|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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); } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|