Getting Error The constructor CANSparkMax(int) is undefinedJava(134217858)

Anyone have any idea on what this could be? I most definitely defined it but i am still getting this error.

Import missing? Library missing? Does it work elsewhere in your code? The other thing is I think you have to say brushed vs brushless

I have imported the CANSparkMax and that checks out fine but I did not know you have to put brushed vs brushless… Where would I implement this into the code?

I think you have to specify the type in the constructor, e.g. new CANSparkMax(port,MotorType.kBrushless);

that worked for that error but when I tried to simulate the robot on the desktop no values came up for those brushless motors. When I tried to add the WPI_ before the motor controllers this came up with more errors. Any ideas on how to fix this?

There isn’t a WPI_CANSparkMax: com.revrobotics (SPARK-MAX-roboRIO API)

As for simulation, there are others that have more help there: Simulating a NEO/CTRE mixed robot using new WPILib Simulator - #9 by Starlight220

it doesn’t appear that there is a WPI_CANSparkMax at all. I just get an error when I try to change it to this

1 Like

Nope. I can’t help you with simulation because it is something I am revisiting right now. I’m looking at 6738’s code to figure out Spark Max simulation: IR2021/ at 81b653234270b0d30483934c319d73c191c5eb71 · ExcaliburFRC/IR2021 · GitHub

I was just using the simulator to see how the code would respond to the robot. I am using this because I don’t have the whole circuit with me. what would be the steps to take for the actual robot when programming the spark’s?

My attempt to mock/simulate onboard PID features didn’t work and I abandoned it. We shortly later switched to using all control on the RIO, that can be simulated much easier and should be almost identical to the frc-docs drive simulation tutorial except for the encoder part- write velocity values to the "Alt Encoder Velocity"SimDouble (see my comment that was linked to earlier or the frc-docs article) and read values as usual (for SparkMaxes). If you’re using the primary encoder and not the alt one, then the key is "Encoder Velocity".

Just note that you will need to override CANSparkMax.set() and write to the output SimDouble due to a bug.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.