Jan 14 10

Sweeping the SONAR – Tests #29 and #30

by Puck

It seems the Rover has a very tight field of view and to counter this tunnel vision effect we are going to try sweeping the SONAR turret from side to side as he travels forward.

Test # 29 – SONAR Sweeping Bench Test

Test #30 – SONAR Sweeping Floor Test

Here we are getting closer to good collision avoidance.  Bob the Dreaded Conduit Pipe looks like he may be close to defeat.

Jan 14 10

Test Videos #27 and #28 – More Collision Avoidance

by Puck

Here are two more videos of the Rover trying to get the SONAR tuned up for good collision avoidance.

Test #27 – Oops!

Here the Rover is crashing because we aren’t sending any braking to his motors.  That means he is coasting forward even when he detects an obstacle.

Test #28 – Restoring the Hard Braking

Here the braking has been restored.  We brake by sending 1-2 inverted pulses to the motors which pops the wheels in the opposite direction very briefly.  It’s a jolting stop, but it certainly beats crashing.

Jan 13 10

Rover with Web Server and AJAX

by Puck

In my previous post I showed how fast it was to bring the Rabbit Web Server into the project.  Of course, I could just be a terrible liar so here is video showing the Wi-Fi web server in action.

It’s a Plain-Jane web page but we can always add a style sheet later to beautify it.

Jan 13 10

Rover, Scholar, Explorer, Poet, and Web Server

by Puck

A Renaissance Robot with many skills

One of the reasons why the Rabbit is so compelling as an embedded computer is that with all the different work we are doing with motors and sensor tuning adding an interactive web server is quick and painless.

Here are the preliminary goals:

  • Wi-Fi connectivity
  • Web Server
  • Use Asynchronous JavaScript and XML (AJAX) to display Rover data in real-time

Here is what we need to make this happen:

  • A web page
  • An XML file
  • A C program to run on the rover

The Gratuitous Self-Plug

If you are concerned about the nitty-gritty of how this all works and want to try it yourself, take a look at my Rabbit-Geek’s AJAX Workbook.  It has step-by-step instructions, examples, and code you can use on your own.

Rabbit-Geek Workbook for the Web, RabbitWeb, JavaScript, and AJAX

The rest of the article will be a big picture explanation of how this works.

Easy Wi-Fi

You can configure all the Wi-Fi network settings in the compiler or the code.  In this case, I have configured everything in the compiler like this:

Wi-Fi_Settings

This configuration looks harder than it actually is.   In the TCP_CONFIG.LIB file that comes with the compiler you will find a series of Wi-FI templates for each type of encryption.  I just copied the configuration from the file into this compiler window and then tweaked it for my specific network.

(For the hackers out there, I have foiled your attempts by obscuring my Wi-Fi network password with the Red Rectangle of Redaction. ;) )

Time to Configure Wi-Fi = 5 minutes or less

The Web Server

Assuming for a moment that we have the web page and XML file ready, let’s look at how the Rabbit devices implement a web server.  Fortunately, by adding less than 40 lines of code to our program I can add an interactive web server with AJAX.

Here is the C code:

Web_Server_Basic

As you can see it isn’t too scary looking.  After the web server is initialized you just spin in the loop on the http_handler function which is non-blocking and typically returns in about 1 millisecond or less.

Time Creating a C File = Approximately 20 minutes

The Amazing Mutating XML File

The XML file is the easiest piece and while my XML might offend a real web developer, I’m an embedded engineer and it works.

Here is the XML file before it is served:

ROVER_XML

The only weird looking part of the XML file is the strange “<z? echo ($Rover_Data) ?>“.  When the web server receives a request for the XML file it will strip this RabbitWeb code out and replace it with the value of the Rover_Data string variable from my embedded controller.

For example, if the Rover_Data variable held the string “Scooby Doo” the final served XML file would be updated.

Here is the served XML file when Rover_Data = “Scooby Doo”:

ROVER_XML_W_DATA

If the web server gets a new request from the file and the Rover_Data string variable has changed, the XML file will also be updated before it is served to the browser.  That’s easy dynamic data for your web page.

Time Creating an XML File = Less than 5 minutes

The HTML page with special AJAX kung-fu

The web page may be a bit intimidating but all it really does is:

1. Use the JavaScript to figure out which browser you are using

2. If your browser supports it, get a copy of the XML file from the server and use it to get the data

3. Put that data on the web page every 500 milliseconds.

Here is the HTML file:

rover_hmtl

Click to read the code

I just copied this from some of my Workbook samples.

Time Editing the HTML File = About 5 minutes

How Long Did That Take?

Total Time to Add the Web Server = Less than an hour

(It took me longer to write this blog post.  ;)

Jan 8 10

Rover’s Nemesis… the Dread Pipe Bob

by Puck

If you have been watching RoverLord’s videos you may notice we commonly drop him on the floor outside Larry’s cube to run down the hall of the cube farm.  Down this hall of danger and crisis lives RoverLORD’s greatest nemesis, Bob C.P.

Bob is the conduit pipe running along the wall and he and the wall space he claims for himself tend to give RoverLORD fits when it comes to collision avoidance.

Bob the Conduit Pole, Nemesis of RoverLORD

Bob the Conduit Pole, Nemesis of RoverLORD

I chose the name ‘Bob’ because what RoverLORD calls him is not printable in a blog.

RoverLORD's interpretation of Bob the Pole

RoverLORD's interpretation of Bob C.P.

We have been working on new Collision Avoidance algorithms in the never ending battle between Bob and RoverLORD.  Before the robot can conquer the earth, he must first defeat Bob C.P. and his Wall of Death.

Rover versus Bob for World Domination

Rover versus Bob for World Domination

New Algorithm

We have updated the algorithm to take advantage of the new mobile SONAR turret:

  • Loop Forever
    • Test for Obstacle
    • If Obstacle Detected
      1. Stop
      2. Retreat
      3. Sweep the SONAR 180 degrees looking for obstacles
        1. Read SONAR Left
        2. Read SONAR Center
        3. Read SONAR Right
        4. Compare who has the closest obstacle
      4. Turn away from obstacle
    • Travel Forward

Videos 25 and 26

At least in these Algorithms, Bob C.P. and the Wall of the Death still have the upper hand.

Rover locked in a desperate battle to escape Bob’s Wall of Death.