FIRST Robotics Code Error

Those on my programming division of my team for FIRST this year are having significant trouble with our code. Everything is done right, even VSC has coloured it right, but for some reason the code isn’t working, and when I hover my mouse it says that the DifferentialDrive is referring to the class instead of the constructor.


We’ve yet to solve this problem, so any input would be greatly appreciated.

I’m not sure about the red underlining, but try replacing VictorSPX with WPI_VictorSPX (also in import). Otherwise, I’m not sure.

1 Like

try replacing VictorSPX with WPI_VictorSPX also in import

if those don’t work you should try removing the import for DifferentialDrive and reimport it, making sure you choose the right one. Sometimes there are other classes named the same unrelated to FRC/WPILib

Most CTRE motor controller objects have a specific WPI import for use in things like drivetrain constructors. In this case, you would need to import WPI_VictorSPX instead of VictorSPX.

Keep in mind if you’d rather be able to use the standard import, there is always the option of creating a Differential drive yourself using the PercentOutput of the motors. This is done by creating a Left Power and a Right Power double, where one side outputs Speed + turn, and the other outputs Speed - turn. The resulting code will look a little bit like this, but may vary depending on your joystick layout or your motor configuration.

double  speed = -joy1.getRawAxis(1);
double turn = joy1.getRawAxis(2);

double Left = speed + turn;
double Right = speed - turn;

m_leftDrive.set(left);
m_rightDrive.set(Right);

Let me know if you need further explanation or any other kind of help.

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