StartCompetition() should have handled this error

That’s what our DS and debugger say when I press the left trigger, and the robot code instantly crashes. It’s coming from the first turret.setPower() line in the following code. Any ideas?

Could you share your code? Do you ever construct the turret object? And there should be more details about the error in the message log.

Lmao forgot sorry

We don’t really have enough information. Please share the full stack trace.

Share the full log, and if you can, upload code to GitHub so you can share the full code

It will also tell you what line caused the error in the stack trace.

Initial impressions makes it seem like it could be a math issue that throws an error, but the stack trace would really tell us what’s going on

I’ll be able to get an error log later tonight, I remember it saying something about a tracer lambda $print if that helps. Sorry for the vagueness, just really confused where the error could even come from.

If I had to guess it has something to do with lambda.getAsDouble(). I am not 100% sure what you are doing there (again would be great to get thee rest of the code), but that is the only piece of that code that I think would cause a null reference (which is likely what is causing the robot to crash).

One note, if you split that one line into multiple lines it would be easier to troubleshoot. For example:

double lambdaResult = clip(lambda.getAsDouble());
turret.setPower(-.005*(220-lambdaResult)/6.2);

If that is the issue that change will change the error line and make it easier to troubleshoot.

1 Like

Alright, so I have this newer(ish) code and when the debugger goes to line 77, it skips to a “throwable cause” catch or something and the robot code crashes. It definitely has to do with getting the lambda as a double.BetterDrive.java (5.3 KB)

What is Robot.xEntry at that time?

It’s a double number that updates every once in a while and has a default value

No, I’m asking whether Robot.xEntry is null or actually initialized?

Yes it’s initialized, it’s a network tables entry

Does lambda get changed by any other code? Why even use a lambda here?

Not sure how else to get a NT entry live while the robot is running, all the other ways I’ve tried have failed. Code either has error and shuts off or nothing happens

Why can’t you just call Robot.xEntry.getDouble(0) directly from line 77?

I tried that and the robot would either crash or do nothing dont remember which

I didn’t have this exact code when I did that though so that’s still on the table

I’m very confused. The lambda is really doing nothing here if you don’t ever change its function implementation. If you’re getting a crash calling Robot.xEntry.getDouble(), putting it in a lambda doesn’t change that at all. Try pulling it out of the lambda and seeing if you get a more useful stack trace.

I can try more things tomorrow, but I’m lost as well. I can see in the smart dashboard that xentry gets updated but the error still occurs.

Posting your entire code would be helpful, or at the very least, Robot.java as well. There’s a lot of action-at-a-distance going on here.