Java - Class extensions and exception errors (for commands)

Hey everyone,

Team 253 would much appropriate help for this issue.

The whole team is waiting for programming (well… me) to get this fixed ASAP.

First off, here is the code for reference

So my team wanted to take the data of multiple sensors and use it in multiple different classes (commands).

These other classes allow us to do various tasks with our robot by using the data from the SensorData class.

In order to get the sensors - Example -

public class SensorData extends Command {
public class GearAutoCorrect extends SensorData {

However, we are running into a snag.

We get “WARNING! Robots don’t quit”

And an illegal exception error linking to and

However, when we tried debugging the error and putting the SensorData and one of our classes (GearsAutoCorrect that takes that data into our last year’s code, it throws an error at the GearsAutoCorrect class (right at the super():wink:

Particularly, I believe its an inheritance problem with the superclass or…

… me completely misunderstanding this concept of FRC java.

Any advice helps!

We need this issue fixed ASAP to test out our robot this weekend!

Can you post the exception and the java traceback from the error?

I’m sorry, I not familiar with the Command based code up until what I’ve just read.
What I would recommend (after posting your traceback error) is to create a simple ‘Code2017test’ project and only create the main,, and Drivetrain.

Get simple code to work first with just one simple piece, and then gradually add the next piece and test it. Once you get some simple code working, go back to your main project and apply the lessons learned.

I suggest reading the command based programming guide here and exploring the GearsBot example in eclipse.

Your problem is that you’re declaring your sensors in SensorData, and then creating instances in each of your commands that extend it. This causes multiple allocations, the same root cause as your last issue.

In the Simple Subsystems page, notice how a subsystem contains the hardware, while the command invokes the methods provided by the subsystem. That way hardware is only instantiated once.