Hi I’m trying to figure a an error with our robot when we deploy the code the status light for the Robot Code is flashing on and off the error it is giving us is.
Agreed. Sometimes this takes the form of constructing the same device in two different classes, rather than declaring it in one and using it in both through arguments.
This error means that a device is being created multiple times on the same ID or port. This could happen for creating multiple motors on the same port or for instantiating a class multiple times that instantiates devices.
It would be appreciated if you could link to the code and/or a full stacktrace if you need more help.
By not explicitly setting a value, it is being initialized to 0. Then in ColorWheelSubsystem at this line:
motor = new StarTalonSRX(RobotMap.COLOR_MOTOR_PORT);
It tries to create this motor controller object using port 0. However, the DriveTrain subsystem has already put a motor at port 0 via this in RobotMap:
public static int DRIVETRAIN_MOTOR_LEFT_1 = 0;
And this in the DriveTrain subsystem:
leftMotor1 = new StarTalonSRX(RobotMap.DRIVETRAIN_MOTOR_LEFT_1);
Also, you will want to post the specific text of the error you are reviving. This is a highly useful and often necessary clue to determine root cause. In particular, if you see how the original poster provided info, there was a specific file and line number which reported the issue (StarTalonSRX.java:34) - this in turn makes the debug process much much more straightforward.
Finally - best practice for requesting help online is to detail specifically where you are stuck, what steps you have tried already, what their outcome was, and why you believe each of these outcomes was not the desired one. This is largely because none of use are aware of what work you have or have not done. It provides clues as to what things could be at fault, and helps folks be better at mentoring you toward self-solving these issues in the future.
Thank you for getting back so early, this link should be corrected https://github.com/ok-dominic/Felipe-7708-2021.git
and as for the errors, this is what we get after we deploy and try to run the driver station
So, I think this is the key - your error is happening during the instantiation of the second swerve module object.
Internally, your swerve module class is hardcoded to always use the same ports for your encoders. However, you have four independent modules - each should have its own unique set of values for which ports are used for the encoders.
One way to fix it is to mirror the pattern you used for your motor ports - you pass them in to the constructor of the swerve module. In this case, you’d add four new integer arguments to the constructor to account for the A/B channels on the two encoders. Then, in Drivetrain.java, pass in the proper unique port indices.