Let's Make Robots!

Occupancy Grid Programming Help.

With much help and inspiration from Gareth and Grog (and others) I have a working Lidar (wiicamera and laser) system. Currently, I am using a very low power laser (while checking the mail everyday for the good laser to show up) and getting about 16" of range. For now during testing this is just fine. Everything is just in a smaller scale, but proportionally, everything is equal.

I am taking one distance measurement every degree in a 180 degree sweep. This array of 180 distances is sent off to processing via BT. Thank you rik for help with the processing code --and oldie but a goodie, dusted off and still working great. I start with a small circle in the center of the screen, this shows the location of the camera. From this point, we have 180 imaginary "rays" going out 1 degree apart. On each of these rays we place a dot. The dot's distance from the center is the same as the corresponding distance as read by the lidar. We draw all the dots. We connect each one with a line, and we get this:

Anywhere the line changes from blue to red (or vice versa) there has been a change in distance (between 2 adjacent points) and that change is above a given threashold. We can consider this an "edge". From one "edge" to another can be considered a "path" in that we would never drive into the corner or "edge" of anything. Zip through all the arrays of distances and angles and paths and "paths that are wide enough to fit through" and you end up with walter picking the path that is furthest away and one that he can physically fit through. We could also use this same data to find the longest "blind corner" which would be the one he would be most "curious" about. Or we could go to the closest to "investigate".etc... etc... Basically, we end up with a bunch of arrays of data, we can go through them in different ways with different criteria and chose a given path among many available ones.

Whew... Man Chris, you gunna ask a question any time soon?

I want to start exploring the idea of occupancy grids. I am gaining much inspiration from this.

Now, I have got the very basic idea here, if you look at the picture above, you see basically a 1/2 circle. This circle jets in and out but it does start at the left and continues to the right and it is a continous line. How do I code the simple idea of everything in the circle is clear, everything out of the circle we don't know about yet? I can draw a grid, I can associate an array with it --no problem. But how do I say, "If there is a peice of a line or a dot or pixel at these coordinates, change the coresponding array location to 1"? Or, "draw an imaginary line between every point and the center and any part of the grid that touches that line, change the array value to 1". Moreso, I would also need to move the center dot as walter moves to a new location on the grid. Actually, now that I think about it, that's a simple thing to do in processing. I got that one. Focus.

I think this would be similar to a video game and how characters would interact with walls and objects. Maybe I should draw a line from the center to each point --draw each ray-- Man, I got nuthin' here... I don't even know how to begin thinking about the problem...

Go easy on me.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Chris the Carpenter's picture

rik, you could not be more correct...

I didnt wanna, I had never done it before and all I had was the kind of heat gun you would use to strip paint. I was scared shitless. To be honest, it was a LOT better than I thought it would have been. Lifting the old chip off was pretty straight forward: Keep the heat moving and keep tapping the chip with some tweezers. It eventually moved a little, I grabbed it and pulled it off. I did a little tidy-tidy on the pads, tried to "prep" them with some fresh solder and went on to flooding/wicking the new chip. --That was really the hard part.

As we all know, solder wick works worst with small amounts of solder. I mean, you gotta have more stuff to capillary so the capillary action keeps capillaring. I found that it helps to "pre-soak" the braid a little bit and be sure the tip of the iron stays wet with solder (for heat transfer). Took some patience but i got it done.

My heart was pounding the whole time. --Literally.

Chris the Carpenter's picture

Why does hardware have to always come around, and stick its big, non-working nose into everything? Yup, I lost a motor driver last night. Funny --everything was super-duper A-OK and then all of a sudden, nothing. A little diagnostics later and i find it was the onboard arduino brain itself that died. Little heat gun work (and a new 328) and it seems that i am back in the ball game. However, it looks like I have a day of re-tweeking my current and volt sensors and getting this guy back to 100%.

Lost one day --pretty minor.

Hopefully driving forward and taking readings tomorrow.

rik's picture

You replaced the uC on your Wild Thumper Controller? Wow, you've got guts!

Gareth's picture

Here is a concept i was using over &"* years ago , Occupancy Navigation "The Great Walls of LMR"

For the cost of 1 byte/cell four object walls and 4 direction tested flags can be indicated.

Walter would have a field day being able to test multiple cells forwards/Left/Right without even turning ...........

I used the basic concept to make mazes and solve mazes.

Chris the Carpenter's picture

Yeah, 45s are the next logical step... That said, I am on step 13 --that is step 87. I hope to drive around via RC tonight and get the side sensors going. Will be a good test of basic data transfer and getting that data into the main array.

GroG's picture

45 next right?

Chris the Carpenter's picture

I am fighting tooth and nail to get through 90 degree angles... You want concentric circles? Yup, my head officially exploded.

Chris the Carpenter's picture

Everything MUST be done at a 90 degree angle. If we/I don't stick to this 90 degree theory, my head will explode.

ignoblegnome's picture

What if instead of a grid system you used a pattern of circles and rays to make a sector map like a disc drive? Then your mapping points would align more gracefully to your measurements. ; j


(wipes bits of grey matter from sleeve)

Chris the Carpenter's picture

So far.

  • hooked up keyboard to propeller
  • propeller hooked up to Bluetooth
  • able to send "arrow keys" to processing

   In Processing

  • made big double-decker array [50][100]  // [Y][X]
  • started image buffer at 1000x500
  • drew a bunch of boxes 10x10
  • seeded currentX and currentY and currentDirection for a start position
  • figured out array code: 
  • 0=open
  • 1=object
  • 2=been there path
  • 10 Walter's current position and pointing north
  • 11 Walter's current position and pointing east
  • 12 Walter's current position and pointing south
  • 13 Walter's current position and pointing west
  • Able to "drive" walters position around on this grid and mark where we have been and know what way we are pointing
  • Path is stored in the array

Enough for tonight. Video tomorrow maybe.

Man, I'm tired... Arrays fill your brain up. Double decker arrays fill your brain twice as fast...