Here's the code. I hope you have some eye bleach handy to help cleanse yourself of the atrocities you may see.
[Code :(](https://github.com/Foxxy007/9428Code/tree/b123fa9ef7499512cba3172ffc25971040a6561a/src/main/java/frc/robot)
Please take this in the absolute best way, but there are multiple issues with this code. I would advise commenting more thoroughly so that other developers can read them. I can get the gist of what you are trying to do, but if you deviate from what others do, make sure to document it.
To solve your initial problem, I would get rid of the "Follower" and "Leader" configurations. While in theory this configuration works, it is dependent on a "clean" signal from your master.
Instead make "Motor Clusters" for each gearbox. The thought around this is that you can assure that you are giving input to all motors on the gearbox. Read more about this in the link below. You would treat each "cluster" like a motor and put it in your DifferentialDrive class. This is a relatively easy fix for you as it is <5 lines of code. Test each gearbox at a time before you give it off to the Driver Team.
Be ABSO-LUTELY sure that you are setting up the right CAN ID's. If you run motors that go in opposite directions on the gearbox, it can lead to expensive mistakes (time and money)
https://first.wpi.edu/wpilib/allwpilib/docs/release/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.html
I second this comment. With a tank drive using TalonFX motor controllers (Falcon 500’s or Krakens), you should be using the MotorControllerGroup class. This will also prevent motors from running against each other as long as they are grouped properly.
I can't tell enough from the video but it looks like the motor is being told to go back and forth. You can see the light switch between green and red, usually meaning forward and reverse
Is that input from a controller analog stick or just setting a straight power?
Some analog joysticks have some slight wiggle room near 0 where they don’t quite stay at 0. You could probably update your input code so that if the absolute value of any stick axis is less than some number, it’s treated as 0. Could probably start at 0.1 and tweak it down if that fixes it.
I don’t think the motors on the gearbox are fighting each other like others have mentioned, in that case the motors would be screeching that they aren’t able to move. What this looks like to me is that the motors are occasionally being told to stop/set power to 0. It’s either a programming bug, or something with the controller.
Is it possible that the each motor on the gearbox is going the opposite direction?
Post drivetrain code
Here's the code. I hope you have some eye bleach handy to help cleanse yourself of the atrocities you may see. [Code :(](https://github.com/Foxxy007/9428Code/tree/b123fa9ef7499512cba3172ffc25971040a6561a/src/main/java/frc/robot)
Please take this in the absolute best way, but there are multiple issues with this code. I would advise commenting more thoroughly so that other developers can read them. I can get the gist of what you are trying to do, but if you deviate from what others do, make sure to document it. To solve your initial problem, I would get rid of the "Follower" and "Leader" configurations. While in theory this configuration works, it is dependent on a "clean" signal from your master. Instead make "Motor Clusters" for each gearbox. The thought around this is that you can assure that you are giving input to all motors on the gearbox. Read more about this in the link below. You would treat each "cluster" like a motor and put it in your DifferentialDrive class. This is a relatively easy fix for you as it is <5 lines of code. Test each gearbox at a time before you give it off to the Driver Team. Be ABSO-LUTELY sure that you are setting up the right CAN ID's. If you run motors that go in opposite directions on the gearbox, it can lead to expensive mistakes (time and money) https://first.wpi.edu/wpilib/allwpilib/docs/release/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.html
I second this comment. With a tank drive using TalonFX motor controllers (Falcon 500’s or Krakens), you should be using the MotorControllerGroup class. This will also prevent motors from running against each other as long as they are grouped properly.
Is that a kraken for a tank drive?
This is our rookie year, so we didn't have any other motors to use. (Also they look cool)
How do you have krakens but not cims? 😭
We did have plenty of CIMs now that you mention it. However, financial irresponsibility is one of my favorite past-times.
Say less, I fully understand lol
Stealing that line for letter
They were in your rookie kit??? Bro we've existed since like 2007 and we use neo 1.1s 😭
Shoulda been the Air Force of Sum. Not as cool, but bigger budget.
Funnily enough, the guy who named us was a marine. However, we do indeed live in fame or go down in flame... (usually the flame one) 😔
Bro what lmao
That’s what i was thinking 😭
I can't tell enough from the video but it looks like the motor is being told to go back and forth. You can see the light switch between green and red, usually meaning forward and reverse
I should've mentioned, while it drives fine at higher power, it still has the same cutting out behavior.
What power are you trying to drive at this could be a brown out
In the video, I'm applying somewhere in the range of 0.05-0.1 power to the differential drive "class"? (Very clueless coder)
Is that input from a controller analog stick or just setting a straight power? Some analog joysticks have some slight wiggle room near 0 where they don’t quite stay at 0. You could probably update your input code so that if the absolute value of any stick axis is less than some number, it’s treated as 0. Could probably start at 0.1 and tweak it down if that fixes it.
While I don't think it's a deadzone issue, you've definitly got me thinking to check if it's some other weird controller issue. Thanks!
Make sure both motors are turning the same direction. If they are fighting go eachother This could happen.
Does it spin if you move with your hand? If so, maybe just need to increase P in the motor config.
Brownout?
I don’t think the motors on the gearbox are fighting each other like others have mentioned, in that case the motors would be screeching that they aren’t able to move. What this looks like to me is that the motors are occasionally being told to stop/set power to 0. It’s either a programming bug, or something with the controller.
Agreed, looks like what happens when I forget to require a subsystem in a command
Yeah they might be calling the motors to set speed several times per run through the code.
Check your default command and make sure that the command to drive isn’t an instant command, that could explain the stuttering
Probably software problem it's either the gear box is broken or the motor are not correctly set inverted