Angle measurement for balancing robot.


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Location
    Muenchen, Germany
    Posts
    5


    Did you find this post helpful? Yes | No

    Wink balancing two-wheel robot using accelerometer or rate gyro

    Hi Henrik,

    I am also working on a balancing robot. My platform is an ATMEGA16 with L293D motor controller ICs and I am using a two-axis accelerometer board built with Freescale MMA2260DR2 for x-axis and MMA1260DR2 for z-axis with a bandwidth of 50Hz, which should be fast enough for a pure accelerometer solution. The robot's mechanical structure is built with Fischertechnik components. I also use a rate gyro CRS03-02 by silicon sensors (bandwidth 10 Hz, which could be a little too slow).
    I also asked myself whether it could be possible to use only the accelerometer alone or the rate gyro alone. To solve the problem of the acceleration of the robot influencing the measurement values of the two-axis accelerometer I would like to suggest the following to you:

    First of all I would recommend to use both readings of the two-axis accelerometer. The accelerometer should be placed in the height of the motors. If you use the x-axis in direction of the robots acceleration and the z-axis in the direction to the sky or ground (starting initially without tilt), both the tilt and the acceleration can be calculated from the data using trigonometric relations and solving a squared equation. I used the drawing in the paper of Joe Le Pendulum for reference, see attached file Tilt_Angle.doc or their paper on the web, Figure 5.

    Then the forward (or backward) acceleration a of the robot can be calculated to:

    a= +- SqareRoot( Square(x) + Square(z) - 1)
    + for the case a>0
    - for the case a<0

    and

    tilt=arcsin((x-z*SquareRoot(Square(x)+Square(z)-1))/(Square(x)+Square(z)))
    # for the case a>0

    tilt=arcsin((x+z*SquareRoot(Square(x)+Square(z)-1))/(Square(x)+Square(z)))
    # for the case a<0

    tilt=arcsin(x)
    # for the case a=0

    All values are normalized to the earth's acceleration g (g=1).

    The remaining unknown figure is the sign or direction of the acceleration a to get the correct result for the tilt. This could be derived from the motor control comparing the motor power during the last two control steps before this measurement.

    For the motor control it is then essential to use in addition to the tilt also the tilt change rate (for a PD regulation) by comparing the last two tilt values (differentiating), because if you only use the tilt itself, the reaction of the motors will be too slow.

    If you only want to use the rate gyro alone (as was done for Joe Le Pendulum), then you need a way to compensate for the gyro's drift. A simple way of doing this could be to work with a running average for the offset. Make a reference measurement of the offset as a starting point and keep the robot in an upright position for a short time after releasing the reset button. Then update the offset with a weighted value of the rate measurement, such as:

    offset_new= offset*(999/1000)+ rate/1000

    for every new measurement of the rate. The weighting should be adapted to the timing period of your measurement updates. By this the drift of the gyro could be compensated. I am working on this tuning at the moment. Assuming a measurement timing period of 10ms (100Hz), the above equation would correspond to a low pass filter with 100Hz/1000=0,1 Hz filtering the dc component of the measurement signal to be used for the offset.

    All this I am writing here is still in an experimental state and are thoughts I developed during my research over the last weeks. I hope you can make use of these ideas. If so, please let me know. My own robot is not yet perfectly balancing, I am tuning the PD regulation constants and the offset filtering at the moment based on the pure gyro rate approach. Next step I will do then is use the pure accelerometer approach.

    Kind regards, uffi.
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Thumbs up

    Uffi,
    That is some nice info, THANK YOU! I will definetly investigate and/or try both methods and will post any results in this thread. Please let me know how you are progressing as well!

    Thanks again!

    /Henrik Olsson.

  3. #3
    Join Date
    Jan 2007
    Location
    Muenchen, Germany
    Posts
    5


    Did you find this post helpful? Yes | No

    Wink parameter.h

    Henrik,

    one question regarding your posted attachment "kalman.zip". In the source "tilt.c" a header file "parameter.h" is linked, which is not included in your file "kalman.zip". Also I could not find these files in the latest releases of the autopilot UAV command and control project (version 2.5, 2.4 or 2.3). Which project at sourceforge has developed these files?
    Can you post also the file parameter.h?

    Thanks in advance, uffi.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default

    Hi Uffi,
    I think that the original files came from the UAV project on sourceforge. Anyway the zipped archive of the complete file-set as found on the Nuts & Volts FTP-site is 345k and the max attachement size allowed here is 200k. So I'll attach the Parameter.h only (change file extension from .txt) and if you want the rest I can e-mail it to you directly or you can get them from the N&V FTP-site. Here: http://www.nutsvolts.com/~downloads/B-Bot.zip

    Are you saying that you are working on converting the routines to PBP? If you do and want to share it I will owe you big time!

    I just got my two SHARP GP2D120 in today so I will have a go at using them first. Then I'll revisit the gyro/accellerometer approach.

    Hope to here from you!

    /Henrik Olsson.
    Attached Files Attached Files

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Lots of energy spent

    Thinking about balancing robots, a lot of energy is spent to do this, both electrical energy and your energy. I would suggest using large wheels and ballasting the robot below the axle to lower the C/G. Perhaps the batteries could go there. then install one of the gyros sold for R/C helicopters to help stabalize the bot. I think then your code for the motors would be less critical, and robot would would make you smile sooner (even if the ballast is inadequate to allow it to stand without controller operating, it should help).
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jan 2007
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    joe - this was my first reaction also. but then i read this N&V article... they put the batteries in the 'head'... and consider the segway... sure the batteries are in the base, but the center of gravity probably is closer to our mid section when it is being ridden...

    i get the impression that a high center of gravity is important.. i also notice that most bots put the accelerometer low, near the wheel axle height...

    if anyone has more info.. i am reading along.. interested in the concepts, if not actually making my own balancing robot!

    i know it may sound like sacrilege, but try the parallax forums.. very helpful people there...

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's 2007, resource are everywhere and mostely free... so what's the problem to look elsewhere, i don't see any. This is why divorces exist after all

    In this case it's more about problem approach and/or problem analysis than anything else. Time to dig in you old school books or take a few cup of coffee to see what's happen
    Last edited by mister_e; - 30th January 2007 at 04:44.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by vacpress View Post
    joe - this was my first reaction also. but then i read this N&V article... they put the batteries in the 'head'
    I will take the time to read that article again.
    JS
    Edit:
    The article says they moved the batteries up to "increase the inertia", I see that as an attempt to cause the accelerometers to respond faster. Their robot chassis is made of whiteboard, probably the reason they needed to increase the inertia, as that cardboard is not very stiff, I believe they could have achieved similar results by moving the accelerometers up to the "Head"
    where nature put ours. Anyway those are my thoughts on the matter, It's up to you to sort out whats good and what's useless.
    Have fun,
    JS
    Last edited by Archangel; - 30th January 2007 at 04:57. Reason: add
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Replies: 0
    Last Post: - 2nd February 2009, 23:23
  2. PIC16F877A for application in mobile robot...
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th January 2009, 14:47
  3. Need Help - Line Tracer Robot
    By pidot in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th August 2007, 14:58
  4. IR for robot on 16F877A
    By Samuel in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 9th April 2005, 20:57
  5. Line tracer robot
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 30th January 2005, 15:36

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts