Leaky Integrator Class
I have been working to update my framework lately and I ran across and interesting concept that can be used by robots to track recurring events and store them in a short-term memory that eventually fades. This is useful, for instance, when a robot gets stuck in a corner, bumping left and them bumping right and repeating. This behavior is called canyoning and seems to happen often. The robot is essentially stuck in the corner, thrashing back and forth until something changes.
Using a Leaky Integrator allow the successive bumps to be summed in the short-term memory while at the same time leaking some bumps out of the bottom at a slower rate. As the robot thrashes more the integrator is filled up. This value could be used to adjust the spin angle for the robot so that the more times the robot bumps, the more it turns to get out of the corner. As the robot escapes, the memory of the corner fades to prevent drastic actions on bumps later in its journey when it may not be stuck in a corner.
An analogy for the leaky integrator is a bucket with a drain in the side that can be opened to let some water out. Water poured into the top fills the bucket if more water comes in than is let out the bottom. If the water stops pouring in, eventually the level will decrease to the level of the side drain. If too much water is poured in, the bucket will eventually have the maximum amount in it and the rest is lost over the top edges.
The RobotC code contains the class. A sample program is commented out at the bottom. It demonstrates instantiating the class and filling a bucket (as it tries to leak out) until the bucket is full. Once full, the input is stopped, and the bucket drains. Very simple, but might be useful to someone out there in Mindstorms land.