REV Swerve, PigeonIMU Java Help

I have been trying to get my first try at code for the REV Maxswerve Drive Train we have going, but we are using a PigeonIMU for out gyro and I don’t think I exactly know what kind of commands to use as compared to the example code out there for the REV MAXSwerve. Any more experienced programmers able to help?

1 Like

It appears that you’re attempting to use the navX methods on the PigeonIMU. The Pigeon uses different naming for the same functions, so you’ll have to change them. I don’t remember the exact naming and the Pigeon’s documentation isn’t great, so I would recommend using VSCode’s features to help you out. If you type out m_gyro. then press control + space, a list of suggestions should appear. (For modifying your current code, you can delete the red underlined words and control + space there). The method names should be fairly self explanatory, but if they aren’t there should also be descriptions of what each method does.

1 Like

I did that for most of them, I just can’t find the equivalent of getRate() for the PigeonIMU

Try using WPI_PigeonIMU it implements getRate. It also implemnts the other missing methods reset and getAngle

This worked! I was now able to deploy my code. It seems like it’s trying but I have the robot up on blocks and now it is “twitching” and seemingly trying to keep moving without input from the controller


This could be a couple of things, one it could be input from your crontroller if you don’t have a deadband on the controller. IT could also be jitter in your gyro. Jitter in your gyro could be the result of electrical noise or just the gyro itself. The pigeon does have some drift problems and slow response compared to the newer gyros. Or more likely than gyro jitter it could be some oscellation in your steer PID. You could look at the tollerances on the steer pid to see if it is too small.


Also keep in mind that on blocks your steer pid will behave differently than on the ground because it takes less force to turn the wheels on blocks.

I changed some values, but it seems like it is fine when im steering, but if i stop, it takes off in an opposite direction almost. Im not sure what this could really be. Also, one of my wheels will not turn(rotate), or even attempt to. I have changed the spark max, the encoder wires, and the neo 55.

You would need to share more code to get help with those problems.

1 Like

I don’t see anything obvious for the reversal. Does it go backwards fast and keep going or slowly and not very long, if it is the latter it could just be controller backlash.

As for the steer motor that doesn’t ever turn it may be your pdp/h port it is plugged into. It could be the CAN wiring, can you see that motor id in the REV hardware client if you plug your computer into another motor controller? Also which motor won’t steer at all?

Not sure if you still mean robot is on blocks but there was another recent similar CD thread with comments.

I know on my team’s swerve the PID controllers are always trying to reach the set point and you can see the motor controller lights indicating power to the motors are on. The carpet keeps the robot from moving all the way to the set point as @Bmongar alluded to.

Also, when the joystick is released to stop driving, the stick doesn’t necessarily follow the perfectly straight motion back to center (which needs a dead-band) without any change in angle. Different driver controllers behave better or worse - try to find a better one if that’s causing trouble or calibrate the stick to see if that helps.

Also, on blocks the gyro isn’t moving so field relative orientation mode can’t be checked.

Hi everyone, I took some time away from robotics for a second, but I am back and have fixed my previous issue of a single wheel not rotating, it was a bad absolute encoder. However, I still have an issue where the robot seems to randomly shoot off in a direction and keep trying to go in that direction once it has started this “cycle”. This is the errors I get on my driver station console. Anyone know what this could be, im unsure if it’s code related or can related

I think it may be a CAN issue but would just love some insight from someone with more experience in this area

Have you checked your DS logs? If you want to share them here, remember to include both files (.dslog and .dsevents).

Is this what you are looking for?

It looks to me like you have a problem with your CAN bus wiring. I would trace the wiring from the roboRIO, comparing each device to the ones reporting problems (SparkMAX 4,5,6,7,10,11 and Pigeon). Hopefully you will get to a point where you have passed the ones not having problems, and the remainder are the ones with problems. That section should be where there is a connection issue. (I’m assuming you’re using the recommended simple CAN bus topology here.)

I’m not sure this explains everything you’re reporting, but I think it’s what you should fix first.

How long is your CAN bus? What type of connector are you using? Feel free to post pictures of your CAN bus wiring.

1 Like

Another trick is to disconnect both ends of the CAN bus, connect a ohmmeter or continuity meter across one colour end-to-end, and then wiggle all of your wiring, noting the effect it has on the resistance/continuity. Repeat for the other colour.

Did you ever track down your problem?