View Single Post
  #5   Spotlight this post!  
Unread 07-31-2016, 08:12 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: FTC NullPointerException

No. Your main class (Brain) is extending OpMode class which means it inherited everything the OpMode class has http://ftckey.com/apis/ftc/com/qualc...de/OpMode.html. One of the fields that OpMode class has is a variable:
Code:
HardwareMap hardwareMap
So the hardwareMap is already created for you. If you want the RobotDrive class has access to it, you need to pass the hardwareMap to it through its constructor, like this:
Code:
public class Brain
{
    ...
    private RobotDrive rd = new RobotDrive(hardwareMap);
}

public class RobotDrive
{
    private HardwareMap rd_hardwareMap;

    public RobotDrive(HardwareMap hardwareMap)
    {
        rd_hardwareMap = hardwareMap;
    }
}
__________________

Last edited by mikets : 07-31-2016 at 08:21 PM.
Reply With Quote