I have a self balancing robot project and I need to add a routine that can dynamically adjust for a change in the center of gravity. I know the angle of the robot and the speed is determined with an optical rotary encoder.
Example of what I need:
Assume the robot is balancing in place (not moving forward or reverse). If I then add a little weight to the front basket of the robot it can no longer balance because the CG is off.
Is there a utility, library, or some formula for automatically adjusting for that CG change? Without a forward or reverse command, the robot should constantly be seeking a balance point that allows it to be stationary again.
I'm no expert on this but I was not aware that a regular balancing program would need to know where the CofG was and, consequently I suspect it should adapt automatically if it changed - provided the change did not exceed the capability of the drive system.
Thinking some more about it I reckon the normal balancing system is designed to hold the robot at a particular angle, which happens to pass through the CofG. If you change the CofG then the "static" angle will need to change. I can imagine how you could "train" the robot by holding it in its new static position and telling it to record that angle. I can't immediately think how it could learn the change by itself.
I marvel at my body's ability to do this without any conscious thought on my part - however a human body has a linear patch on the ground (a foot) that can be used to correct for some of the error whereas the wheeled robot only has a point on the ground.
It would help to know what will cause your robot's CofG to change.
If the machine was just intended to stay balanced in one place then the change of angle could probably be used to cause a correction. However I believe when the machine moves it uses a deliberate change of angle to make itself unstable.