Sunday, May 15, 2016

Buddybot gets Obstacle Avoidance

BuddyBot, the first robot programmed in the Swift programming language with SwiftyBones, just got some more upgrades.  The first being a second MaxSonar_EZ2 range finder so it can decide which way to turn when it detects an object in front of it.  The rest of the upgrades were cosmetic like a new top tray that holds the breadboard in place, two new indicator LEDs so it now has three and a new start button.   You can see the earlier posts on BuddyBot here:

The first robot programed in Swift with SwiftyBones
BuddyBot - The Swift robot gets its first upgrades

If you are interested in making your own BuddyBot or if you just want to see what parts were used you can see this post:  BuddyBot update and Parts List

Here are some new pictures of BuddyBot

When I added the second MaxSonar_EZ2 range finder I put one on the left side and one on the right side.  This allows BuddyBot to determine if the left or right side is closer to the object in front of it and then determine which way to turn based on which side is closer.  It is a very basic system, which could use some more logic, but it is definitely a start.  You can see several videos of BuddyBot with the new obstacle avoidance system below.

One thing with the MaxSonar_EZ2 range finder, or any small sonar sensor like this one, is when the robot approaches an object at too large of an angle, the sonar sensor will not register the object.  With this in mind, I think I will want to add an infrared obstacle avoidance sensor to assist the MaxSonar range finders.  The IR sensor I am thinking about using is this one.  I currently have one of these so I am thinking about giving it a try next weekend.  What I will do is when the IR sensor detects an object then I will use the sonar range finders to determine which way to move.

I am also thinking about using a sonar sensor to determine if BuddyBot is near a ledge or step.  I am thinking that if I use a sonar sensor, facing down, in BuddyBot’s nose then I can determine if it is at a ledge or a stairway.  I could take the range when the BuddyBot first starts and if the range increases significantly then it has approached a ledge.

I did not make any changes to the SwiftBones library for this upgrade however I did make significant changes to the BuddyBot code.  You can see the changes on BuddyBot’s GitHub page.


  1. You can also use the Sharp IR sensor like the ones mounted on this bot:

  2. Thanks for the tip, unfortunately I already have an IR sensor but I will keep the Sharp one in mind for the next robot that I am beginning to design.