I am a new programmer for my HS robotics team. This year, our team switched from NI Lab view to FRC Java. I have the can ID’s from the Lab view code and I am trying to write the ID’s into Java. I have had a difficult time finding any information on how to do this, and I am asking if anyone else has any information on what to do.

If you have the CAN IDs, you can just input them when declaring your motor controllers:


private CANSparkMax leftDrive = new CANSparkMax({CANID}, MotorType.kBrushless);


private TalonFX leftDrive = new TalonFX({CANID}, {CAN bus});

A good way to keep your CAN ID’s organized is by using a Constants file. Any numbers that have significant meaning and that don’t change should be placed in this file. Here is an example of our Constants file on 5406 from this year:

1 Like

Thank you, this should help me get back on track.

1 Like

I ended up having another issue. I went to the two motor controller websites and tried to get the imports needed for declaring CAN motor controllers, but when I copied the imports into my code it would say that it cannot resolve the imports. An example import for the Talon import is

import com.ctre.phoenix.motorcontrol.can.TalonSRX;

Have you ever had any issues with this?

Do you have the vendor dependencies installed?


That is probably the issue, I was unaware those existed. I will check that shortly.

1 Like

3rd Party Libraries — FIRST Robotics Competition documentation for reference in installing the dependencies.

1 Like

I’d recommend reading and following the CTRE documentation here: Welcome to Phoenix’s documentation! — Phoenix documentation

1 Like

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