Log in

View Full Version : Missing CANTalon class


PM_ME_UR_ROBOT
22-09-2016, 09:59
Obligatory "I'm not very experienced with Java nor programming robots in FRC," so feel free to be as critical as you want, everything is a learning process after all.

We've recently decided to use CAN on our robot to connect our Talon SRX controllers, only problem is that the original code we had done used the Talon class to initialize the speed controllers to build our RobotDrive. No big deal though, we just have to change Talon to CANTalon and remove the port numbers from the constructor since CAN doesn't use PWM and -- oh dear why is there so much red on my screen now?

So the errors came from our program not having CANTalon imported into it, but when I try to import it using the following path, it says it does not exist:

import edu.wpi.first.wpilibj.CANTalon;

We're really not sure how to resolve this issue, all our other classes have imported just fine, but this one just doesn't seem to exist. There isn't much documentation saying I'd have to install some other plugins or update to a certain version for it to be available, so what am I doing wrong?

Thanks in advance to anyone reading.

tl;dr
edu.wpi.first.wpilibj.CANTalon isn't being imported because it's missing, how can I make that not happen?

Bkeeneykid
22-09-2016, 10:32
As always, it really helps if we can see your full code. There could be confounding variables everywhere, and we can't see all the ways things can change. Can you perhaps upload it to GitHub?

Also, make sure you are using CANTalon, not CANTalonSRX, as that class was removed in 2016.

Tyler Scheuble
22-09-2016, 11:11
Side note: Are your CANTalon constructors empty? If you removed the ports and didn't replace it with their integer CAN IDs then that would cause a compile-time error on its own.

PM_ME_UR_ROBOT
22-09-2016, 11:52
As always, it really helps if we can see your full code. There could be confounding variables everywhere, and we can't see all the ways things can change. Can you perhaps upload it to GitHub?

Also, make sure you are using CANTalon, not CANTalonSRX, as that class was removed in 2016.

I wasn't able to push our project to GitHub for some reason, it kept giving errors so I just resorted to compressing it and putting the zipped file up for download. Sorry about that inconvenience.

https://github.com/carson-fitzgibbon/Robotics-Test

As for the CANTalon vs CANTalonSRX thing, we are trying to use CANTalon.

Side note: Are your CANTalon constructors empty? If you removed the ports and didn't replace it with their integer CAN IDs then that would cause a compile-time error on its own.

I made sure to give each constructor their own unique integer from 0 to 3 since we have four motor controllers. Problem isn't so much with the construction as it is the import not being found :/

mikets
22-09-2016, 11:57
I made sure to give each constructor their own unique integer from 0 to 3 since we have four motor controllers. Problem isn't so much with the construction as it is the import not being found :/
The CAN ID is not a random number. It needs to match the ID you assigned to the actual motor controller. I don't think 0 is a valid CAN ID. You need to connect to the web interface of the RoboRIO and check the CAN ID of each CANTalon motor controller.

astronautlevel
22-09-2016, 12:13
Unfortunately I'm not in a position to test it right now, but try removing
import edu.wpi.first.wpilibj.*;

Importing everything in the wpilibj package is bad practice, and it may be the issue here (as by the time you import CANTalon, it's already "imported" due to the wild card)

PM_ME_UR_ROBOT
22-09-2016, 12:21
Unfortunately I'm not in a position to test it right now, but try removing
import edu.wpi.first.wpilibj.*;

Importing everything in the wpilibj package is bad practice, and it may be the issue here (as by the time you import CANTalon, it's already "imported" due to the wild card)

Thanks for the suggestion, I went ahead and manually imported all necessary items for this file, but it still did not resolve the issue. NetBeans still does not recognize CANTalon as a valid class to import, even after updating and restarting the IDE.

AllenGregoryIV
22-09-2016, 12:39
Thanks for the suggestion, I went ahead and manually imported all necessary items for this file, but it still did not resolve the issue. NetBeans still does not recognize CANTalon as a valid class to import, even after updating and restarting the IDE.

Are you using the most updated WPILIB? The recommended IDE is eclipse so you would have had to follow special instructions to get it working with netbeans. If you are using an old WPILIB from the cRIO days that wouldn't have a CANTalon class. From your build.xml file I believe you are, all the old sunspot references are still in there.

GoldenGollem
22-09-2016, 13:32
The CAN ID is not a random number. It needs to match the ID you assigned to the actual motor controller. I don't think 0 is a valid CAN ID. You need to connect to the web interface of the RoboRIO and check the CAN ID of each CANTalon motor controller.

0 is a valid CAN ID and is the defult of most Talon SRX's unless changed in the RoboRIO interface.

Also try it with eclipse. From my understanding NetBeans works only with older versions of WPILIB and the CRIO. The version of WPILIB that netbeans uses I don't believe to have been updated.

PM_ME_UR_ROBOT
22-09-2016, 16:40
Are you using the most updated WPILIB? The recommended IDE is eclipse so you would have had to follow special instructions to get it working with netbeans. If you are using an old WPILIB from the cRIO days that wouldn't have a CANTalon class. From your build.xml file I believe you are, all the old sunspot references are still in there.

I installed Eclipse and I think the problem is fixed, but I can't tell because it has no real time error marking like NetBeans, so it won't show me missing imports or other errors. Know how to fix this? If it starts working that will completely answer my question.

AllenGregoryIV
22-09-2016, 17:43
I installed Eclipse and I think the problem is fixed, but I can't tell because it has no real time error marking like NetBeans, so it won't show me missing imports or other errors. Know how to fix this? If it starts working that will completely answer my question.

Did you install the WPILIB plugins? It should do it. Follow the instructions at screenstepslive. You will need to make a new WPILIB project.

PM_ME_UR_ROBOT
22-09-2016, 19:34
Did you install the WPILIB plugins? It should do it. Follow the instructions at screenstepslive. You will need to make a new WPILIB project.

After a very long series of frustrating events, I figured out the issue. I went directly from NetBeans to Eclipse, which created problems that Eclipse didn't like (no build library or whatever it's called).

I recreated our project in Eclipse and copied the code over and now the error marking works, but more importantly: CANTalon works!

Thank you all for the help.