Home > RobotC Code > Leaky Integrator Class

Leaky Integrator Class

I have been working to update my framework lately and I ran across and interesting LeakyIntegratorconcept 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.

Download: LeakyIntegrator.c

Categories: RobotC Code Tags: ,
  1. January 10, 2011 at 5:05 pm

    this looks really cool! That’s a problem I’ve been having a lot (the continuous bumping in strange corners). I was only wondering about what the leaky integrator should… leak: the same (allowed) value vs. one of the old values (like the ten back each leak) The second one woud take up more space, so I’m more attracted by leaking a normalized amount. What do you think?


    • Thom
      January 13, 2011 at 8:37 am

      The way the class is set up, you would set a constant amount the bucket would leak with each timeslice. It is like having a bucket with a hole in the bottom. No matter how much water you put in the top, a constant amount leaks out the bottom.

      I thin of it like memory retention. The robot continually learns about bumping into a wall and counts the times in memory. As the situation improves, it slowly forgets about the bumps until, over time, the memory us gone and it has to relearn to escape a corner. Te idea is to build up a memory so repeated actions have a factor to work with either to multiply a turn time or set a threshold for a totally different action.

      Good luck with your robotics.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: