CAN VictorSPX "method of following" - What am I missing? (Newbie to programming)

Following various YouTube videos to set up differential drive. To be honest I don’t know if the image is enough for people who know what they are doing to see my issue, but the code builds after simply naming/creating the four motors. I start to get errors when doing the .follow command. Originally tried the “MotorControllerGroup” and it states “deprecated” use “PWM…, if CAN ‘their method’”. Everywhere I read, including the CTRE documentation, says .follow works for VictorSPX. What am I doing wrong? I don’t know anything about Java, just been blindly googling/youtubing/navigating the WPIlib to try and create what we need.

.follow() is a valid VictorSPX call, the error you’re getting is because you are starting a new declaration with the word private in front of it.

// Declare and instantiate the motor controllers
private VictorSPX rightBackMotor = new VictorSPX(0)
private VictorSPX rightFront = new VictorSPX(1)

// Tell the right front motor, to follow the right back motor
rightFront.follow(rightBackMotor)

I tried w/ and without “private” prior to posting, both gave me issues. Is there an import that should be coming in when I use .follow? Although I have both the v6 and v5 phoenix libraries imported, for whatever reason even when I was setting up the motor controllers I had to type in the import to get them to be recognized.

Can you share your current code? Preferably as a link to github or similar.

The call to .follow() can’t be at the class scope. You need to put that in a function (likely your constructor)

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