Menu
Baran Kahyaoglu Dev Blog
Baran Kahyaoglu Dev Blog

Bug Algorithms

Posted on 21/10/201210/06/2020 by brnkhy

First Javascript post ever! Wohoooo… I guess…

Or not. I actually hate it, rather passionately too ( especially after trying typescript ).

http://barankahyaoglu.com/robotics/bug/

Anyway,

I’ve done this little simulation after the first day Robot Motion Control and Planning class. It simulates the behaviours of 3 different bug algorithms ; Bug 0, Bug 1 and Bug 2. Creative names indeed.

 

I’ll just copy paste the description here as well;

All robots ;

have tenticle sensor ( no range ).
have no information other than the relative position of the goal.

Bug 0
It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it can freely move towards the goal again.
Rinse repeat.

Bug 1
This one is a little smarter.
Non greedy, rather safe compared to Bug 0 and Bug 2.
It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it reaches the starting point again, ( so it travels all around the obstacle )
Keeps track of all points around the obstacle,
Goes back to the one closest to the goal,
Moves towards the goal.
Rinse repeat.

Bug 2
This one is also a bit smart, in a different way though.
It’s greedy.
Finds the shortest path to goal as if there are no obstacles ( going through obstacles ), let’s call it “direct path” It moves towards the goal.
If it runs into an obstacle;
Turns left or right ( this should be fixed but kinda random in my implementation ),
Follows the obstacle until it reaches a point on direct path
Now that it’s back on the direct path again, it just move towards the goal.
Rinse repeat.

 

It’s unstable though, gets confused or just simply break down on some occasions. By no means a full implementation, just the simple bareboneĀ  algorithm, vulnerable to every corner case situation. Don’t even bother trying to use the javascript code for whatever, it’s horrible. ( again, first javascript project ever )

 

Oh and I used KineticJS for it. Actually using it for almost everything these days, works brilliant with typescript as well. One of the better libraries out there I guess ( not that I know anything about JS community but still )

 

Share on Social Media
twitter facebook linkedin reddit email

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

4 thoughts on “Bug Algorithms”

  1. Tommy says:
    27/11/2015 at 6:19 pm

    Excuse me. I am doing a project on bug algorithms. Would you mind send me the source code of bug0,1 and 2 algorithms in matlab or C++.

    Thank you very much.

    Reply
    1. brnkhy says:
      09/12/2015 at 1:25 pm

      Hey there,
      Unfortunately I only have javascript code and it’s already there, embedded in the page.
      Shouldn’t be hard to convert it to C++ I guess.
      Cheers,
      Baran

      Reply
  2. malihe says:
    24/06/2017 at 4:16 pm

    hi . I am doing a project on bug algorithms. Would you mind send me the source code of bug1 and 2 algorithms in matlab. please

    Thank you very much

    Reply
    1. brnkhy says:
      24/06/2017 at 5:42 pm

      Hello!
      I’m afraid I don’t have anything related to those projects at the moment. But they were all done in javascript (are demos even still alive?) so you can get them from the page. Other than that, I don’t even remember those algorithms anymore, I’m sorry šŸ™

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Subscribe to Blog via Email

Follow me on Twitter!

My Tweets

Categories

  • Desktop Development (26)
  • Game Development (39)
  • Mapbox Unity SDK (4)
  • Uncategorized (8)
  • Unity3D (21)
  • Web Development (6)
  • WinRT Development (1)

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Baran Kahyaoglu Dev Blog | Powered by WordPress & Superb Themes