Homer, our robot, gets a little intelligence!

Finally got a little time this week - weekend to work on our robot project. This is a video of steering stabilization for our tracked robot. We're using compass angle as the source for set-point and input for moving correction. After lots of experimentation with localization possibilities, I felt the ability to maintain a stable heading with a track robot was an absolute necessity for localization based on dead reckoning. So here's our solution. This is our working draft code. We tried to make it as simple and fast as possible.

I'll try to pretty the code up a bit later. The code and video are on our site, Appiphania.com.

Thanks,

Jim 

 

 


This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/homer-our-robot-gets-a-little-intelligence

Inspiring!

This project is very cool and inspiring! Can you give a little more info about the compass module you used and the microcontroller? 

**D’oh!! **
mmm…donuts!

That is a pretty awesome setup

I am very impressed with its correction capabilities and you don’t seem to have had to really separate the compass module all that much, not that I ever did see it on the platform.

sure

There are two micro-controllers. The Rover has an Arduino Duemilanove buit in to the platform and i’ve added an Arduino Nano.

The Duemilanove takes care of the state machine for remote control (I use Chris the Carpenter’s Rocket Bot on the android), the Compass - HMC 6352 http://www.sparkfun.com/products/7915  (mounted in the middle of the plexiglas platform between the Nano and the LCD), and motors drives.

The Nano takes care of processing all other sensors and communicates to the Duemilanove via interupts. If you look closely at the video, when the robot goes to the sides of the video, you’ll see blue leds come on … it’s detecting the edge of the table and reversing direction. The interupts are processed via an optical isolator board (I built). 

I’ll take a few pov photos post on my site.

Thanks,

Jim

 

 

 

Good work in path correction

Good work in path correction indeed! I like it~

Thanks

We’ll post another video in the next week with all states fully integrated with stabilization. :wink:

Thanks so much, I really appreciate it!

It’s nice to hear! :wink:

Thanks, I was expecting it to be a problem but really wasn’t :wink:

I’ll take a couple of close up photos this weekend :wink:

**‘To Start Press Any Key’. Where’s the ANY key? **

Donuts. Is there anything they can’t do?

Hi ChuckCrunch,

Zero and 360 deg crossing in movement make it difficult to use a compass for course /heading stabilization. This is why you’ll not see many (if any) references on google. However, it’s not impossible as the video illistrates.

Keep in mind, this is still a work in progress, that’s why I’ve not posted complete code. I would also recommend setting this up on a test Arduino will a compass (double sided taped) so you can debug with the Serial Monitor. If you use this in a project, please acknowledge this as my code and if you modify it, please share it with me.

 

My approach was to sample heading whenever I change state to take a heading (setpoint), then as the robot moves repeatedly read it’s updated heading and take the absolute difference to setpoint. This error is multipled by some factor to create a correction signal. I then figure out if the difference in heading is above or below the setpoint and apply this to the motor left and right speed respectively.

So …basically… this should work…

the first routine is just to sample heading. 

long getheading()

{

        // sample heading angle

        hmc6352.wake();

        sensVal = hmc6352.getHeading();

        hmc6352.sleep();

  return sensVal;

}  

Next while running (polling);

 

void setheading()

/-----------------------------------------------------

SetHeading Routine

by Jim Winburn 

Appiphania.com

 9/2/2011

/------------------------------------------------------

{

  Input = getheading(); // I sample heading again

  c = 180 - abs(180- abs(Setpoint -Input)); //take the absolute difference

  d = c*10; // apply multiplier to achive desired correction response (you can replace this with a proper PID algorithm if needed)

  e = (maxspeed-d); // apply correction

  if (e<= 0) //if correction < 0 (negative), make it zero

  {

    e=0;

  }  

 

  if (Setpoint - Input > 180) //test if the difference is above or below the setopint, compensating for zero and 360 crossing

    {

    Input +=360;

    }

    else if (Setpoint - Input < -180)

    {

      Input -=360;

    }

   b = Setpoint - Input; 

 

  if (b < 0) // = negative … moving to the right … correct respective motor speed  based on state 

  {

    if (anfwd == 1)   //forward         

    {

    leftspeed = e;

    rightspeed = maxspeed;

    }

    else if (anrev == 1) //reverse

    {

    leftspeed = maxspeed;

    rightspeed = e;

    }  

 

  }  

  else if (b > 0) //= positive … moving to the left … correct respective motor speed  based on state 

  {

     if (anfwd == 1)            

     {

     leftspeed = maxspeed;

     rightspeed = e;

     }

     else if (anrev == 1)

     {

     leftspeed = e;

     rightspeed = maxspeed;

     }

   } 

 }

No problem, Chuck … glad to help.

I’m working on a set of algorithms for precision turns by degree as well as routines for dead-reckoning based on compass angle and odometry. I’m thinking I may eventually create a “CompassPilot” library based on this work for Arduino. 

Good luck with your project,

Jim