Announcement

Collapse
No announcement yet.

What causes a null error?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What causes a null error?

    We are having issues with our phones. They keep reading "An exception occured NULL". Any ideas on what is happening?
    Thanks

  • #2
    Originally posted by FTC5828 View Post
    We are having issues with our phones. They keep reading "An exception occured NULL". Any ideas on what is happening?
    Thanks
    Robot Controller Phone or Drive Station? If Robot Controller, open do a View Logs from the menu and see if you can find more details about the null error. Also please provide code

    Comment


    • #3
      Bug report: null exceptions not actually null

      The ubiquitous 'null' we see in these error messages is caused by the fact that there's a bug in the exception reporting infrastructure: it only reports the getMessage() part of the exception, not the name of the exception class itself as well (this is in EventLoopManager.EventLoopRunnable.run()). A significant number of types of exceptions don't have any getMessage() content; this is where the null comes from.

      In addition to any getMessage() content (which should be checked for null), the name of the Exception class should also be reported.

      Comment


      • #4
        Originally posted by FTC0417 View Post
        The ubiquitous 'null' we see in these error messages is caused by the fact that there's a bug in the exception reporting infrastructure: it only reports the getMessage() part of the exception, not the name of the exception class itself as well (this is in EventLoopManager.EventLoopRunnable.run()). A significant number of types of exceptions don't have any getMessage() content; this is where the null comes from.

        In addition to any getMessage() content (which should be checked for null), the name of the Exception class should also be reported.
        That's a good find. You should create an issue here: https://github.com/ftctechnh/ftc_app/issues

        Comment


        • #5
          Here is our code for our robot
          package com.qualcomm.ftcrobotcontroller.opmodes;
          import com.qualcomm.robotcore.eventloop.opmode.OpMode;
          import com.qualcomm.robotcore.hardware.DcMotor;
          //import com.qualcomm.robotcore.hardware.Servo;
          public class Teleop1 extends OpMode {
          //If the phone cannot find the DC Motor Controllers, go into cnfiguration and search for the motors one at a time, this should reset the
          // search and then work correctly
          DcMotor rightwheels;
          DcMotor leftwheels;
          DcMotor backwheel1;
          DcMotor backwheel2;
          DcMotor armpivot;
          DcMotor armslide;
          // Servo Test;

          public Teleop1() {}

          @Override
          public void start() {

          rightwheels = hardwareMap.dcMotor.get("rightwheels");
          leftwheels = hardwareMap.dcMotor.get("leftwheels");
          backwheel1 = hardwareMap.dcMotor.get("backwheel1");
          backwheel2 = hardwareMap.dcMotor.get("backwheel2");
          // Test = hardwareMap.servo.get("Test");
          // leftwheels.setDirection(DcMotor.Direction.REVERSE) ;
          backwheel2.setDirection(DcMotor.Direction.REVERSE) ;

          }

          @Override
          public void loop() {

          double threshold = .10;
          if (Math.abs(gamepad1.right_stick_y) > threshold) {
          rightwheels.setPower(gamepad1.right_stick_y);
          backwheel1.setPower(gamepad1.right_stick_y);
          } else {
          rightwheels.setPower(0);
          backwheel1.setPower(0);
          }
          if (Math.abs(gamepad1.left_stick_y) > threshold) {
          leftwheels.setPower(gamepad1.left_stick_y);
          backwheel2.setPower(gamepad1.left_stick_y);
          // cog2.setPower(gamepad1.left_stick_y);
          }
          else
          {
          leftwheels.setPower(0);
          backwheel2.setPower(0);
          // cog2.setPower(0);
          }

          if (gamepad1.left_bumper)
          {
          backwheel1.setPower(1);
          backwheel2.setPower(1);
          rightwheels.setPower(-1);
          leftwheels.setPower(-1);
          }
          if (gamepad2.a)
          {
          armpivot.setPower(1);
          }
          else
          {
          armpivot.setPower(0);
          }
          if(gamepad2.y)
          {
          armpivot.setPower(-1);
          }
          if(gamepad2.right_bumper)
          {
          armslide.setPower(1);
          }
          else
          {
          armslide.setPower(0);
          }
          if(Math.abs(gamepad2.right_trigger) > 0)
          {
          armslide.setPower(-1);
          }




          }
          @Override
          public void stop() {

          }
          }

          Comment


          • #6
            Okay, so now that we know what causes it, are there any suggestions on how to fix this error? We cannot run the robot currently and we need to get it working soon.

            Comment


            • #7
              Are you assigning armpivot and armslide anywhere?

              Comment


              • #8
                You are using armpivot and armslide without first assigning them, which is sure to cause a NullPointerException.

                Comment


                • #9
                  Originally posted by GearTicks View Post
                  You are using armpivot and armslide without first assigning them, which is sure to cause a NullPointerException.
                  Try putting "private" before the variable assignment
                  Code:
                   private DcMotor armpivot;
                  armpivot will then be greyed out showing that is unassigned.


                  Someone else on the forum pointed this out.

                  Also you really don't want to give other classes access to these variables so it is good practice to use "private".

                  Comment

                  Working...
                  X