Ideas for automatically balancing the robot on the charge station?

Hi, I’m on the programming subteam for my FRC team and I wanted to know what ideas everybody has for getting the robot on the charge station while keeping it level. We’re looking into using gyro inputs in some manner to calibrate the robot when it is on the platform automatically. Any help is greatly appreaciated


Start by getting yourself one of these:

This will enable you to sense the direction and magnitude of the force being put on your robot that is causing it to roll off the CS and compensate with a sufficient amount of motor power to move back to where you want to be (wish I could help out more but I’m not a programmer, I’m sure more will chime in below!).


Not OP but I was wondering if the NavX MXP is capable of this aswell.
NavX mxp

Its a little bit more difficult to get a NavX working reliably in my experience.

1 Like

We already have this product and we were planning to use it


At the simplest level, you can get the angle of the robot from your pigeon or navx, and use a proportional controller to increase power to the drive motors until you get within some deadband of level. This may work on its own, or you may need to add an integral component to help once the error gets close to zero. Look into PID controllers on the WPILib docs as a starting point, and come back to ask questions once you have reviewed that.


There are two elements as far as I can tell:

  • Location/Localization - Can you get to the station? Are you on the station?
  • Level - are you perpendicular to gravitational down?
    If you are not level and you drive to fix that you may drive off the ramp so the range is constrained. That is the classical inverted pendulum on a cart. But there is a dead-band in the middle of the charge station rocking mechanism (see here).

Can you expand on this? Are you speaking in general, or are you speaking to getting angle or magnitude?

Yes, the navx also has a 3 axis gyro and 3 axis accelerometer to measure this.

Additionally, the roborio has a built in 3-axis accelerometer:

I’m also curious about this- in my experience, navX has been just about as plug-and-play as it gets.


You might want to consider - is this better than a driver with 2 minutes of practice?

Overall you’re controlling the velocity of a weight moving along a seesaw that may have other weights and nonconservative forces you don’t know consistently. Not only are you controlling theta but also angular velocity and that’s very hard when you don’t know the dynamics of the charging station system.
→ yes you can approximate the dynamics but alliance partners can change that super easily

For the autonomous balance, which is a massive contributor to the RP, definitely.


I mean I feel like a driver can do it much better due to biological intelligence being a bit better than a rough PID (in this case for the reasons I mentioned)

I’m not saying don’t balance

We were able to get it working just using our gyro and translating that to forwards and back movement.


My team is eager to try autonomous balancing. Detecting the gravity vector with an accelerometer ought not to be difficult, but it’s worth pointing out that there’s also a visual indicator on either end of the charging station (LEDs light up when the platform is in the “balanced” zone). I think the accelerometer is no harder to read than a light sensor and gives better data than the LEDs, but it’s worth mentioning.


Its a little bit more difficult to get a Pigeon working reliably in my experience.

Can you please elaborate on that? What difficulties did you run into?

Would an adis16448 achieve the same results as a pigeon?

I don’t know if this code is the best example, but it’s an example to start from.

Doesn’t the double hinge mechanism in the charging station result in a 5.3" “dead-zone” in which if your centre of gravity lies there you will not tip, and in fact the platform will self-right?


Is it though? I mean engaged vs balance.
Seems like it would be easy for a team to drive up and turn 90° so as to not roll off. The difference being 4 points not a RP.

Not to derail, so I’ll leave the link.

1 Like