NavBot: Calibration

[This is a breakout post for NavBot: Version 1 where I show how to get the NavBot project to run on your own robot.]

In a previous post I detailed some of the systematic errors typical for differential type robots and how to correct for them.

In this post I’m simply going to show how to do the calibration.

Note that all tests should be performed on flat and even surfaces. Any bumps or unevenness in the travel of the robot will affect the calibration.

First ensure that WHEEL_RL_SCALER, WHEELBASE_SCALER and DISTANCE_SCALER are set to 1.0 near the top of MyBot.h:

// correct for systematic errors
#define WHEEL_RL_SCALER         1.0f  // Ed
#define WHEELBASE_SCALER        1.0f  // Eb

// correct distance 
#define DISTANCE_SCALER         1.0f  // Es

Setting the scalers to a value of 1 means they have no effect on the robot.

In Pilot.h set all the PLT_xxx defines to 0:

#define PLT_DEBUG_STATE             0
#define PLT_DEBUG_TASK              0
#define PLT_DEBUG_ENCODER           0
#define PLT_SHOW_ERRORS             0
#define PLT_MOVE_INFO               0
#define PLT_TURN_INFO               0
#define PLT_SPEED_INFO              0
#define PLT_SHOW_HEADING_ADJUST     0
#define PLT_SHOW_TURN_ADJUST        0
#define PLT_GRAPH_WHEEL_PID         0
#define PLT_GRAPH_SPEED_PID         0
#define PLT_GRAPH_HEADING_PID       0

In NavBot_v1.ino config the bot for CALIBRATE_MOVE with CAL_DISTANCE to 2 meters or whatever distance you can manage.

//----------------------------------------
// Config Logic
//----------------------------------------

#define CFG_TEST_ENCODERS     0     // print encoder ticks as they change
#define CFG_TEST_MOTORS       0     // verify motor wiring
#define CFG_SQUARE_TEST       0
#define CFG_CALIBRATE_MOVE    1     // straight line movement
#define CFG_CALIBRATE_TURNS   0     // turning only test

#define CAL_DISTANCE          2     // meters to move 
#define CAL_TURNS             5     // num turns (+ right, - left)

With these new settings compile and upload the code to the bot.

Mark the start position of the robot and press the start button. When the bot stops, measure the actually distance it has travelled as accurately as you can.

You can repeat this a few times and average the results.

Now set DISTANCE_SCALER to the actual distance traveled divided by the CAL_DISTANCE.

DISTANCE_SCALER = Actual distance / specified distance

So if you told the robot to travel 2000 mm and it only travelled 1992 mm then:

DISTANCE_SCALER = (1992.0f/2000.0f)

So we would update MyBot.h to be:

// correct for systematic errors
#define WHEEL_RL_SCALER         1.0f  // Ed
#define WHEELBASE_SCALER        1.0f  // Eb

// correct distance 
#define DISTANCE_SCALER         (1992.0f/2000.0f)  // Es

Run the test again with the new DISTANCE_SCALER and measure the new result. If you want to get more accuracy then augment the current DISTANCE_SCALER with the new one.

For example, say your bot now travels 1998 mm then you would update DISTANCE_SCALER to be:

// correct distance 
#define DISTANCE_SCALER         (1992.0f/2000.0f)*(1998.0f/2000.0f)  // Es

Once we have a suitable DISTANCE_SCALER we need to do the UMBmark test to calculate WHEEL_RL_SCALER and WHEELBASE_SCALER.

Set CFG_SQUARE_TEST to 1 in NavBot_v1.ino and SQUARE_SIZE to some distance:

//----------------------------------------
// Config Logic
//----------------------------------------

#define CFG_TEST_ENCODERS     0     // print encoder ticks as they change
#define CFG_TEST_MOTORS       0     // verify motor wiring
#define CFG_SQUARE_TEST       0
#define CFG_CALIBRATE_MOVE    1     // straight line movement
#define CFG_CALIBRATE_TURNS   0     // turning only test

#define CAL_DISTANCE          2     // meters to move 
#define CAL_TURNS             5     // num turns (+ right, - left)

#define SQUARE_SIZE           800   // size of square test sides in mm

And in the same file set testPath to cwSquare:

int16_t *testPath = cwSquare;

When you now run the bot it will travel clockwise about the square of the size specified by SQUARE_SIZE in millimeters.

Mark the position of the bot before and after it travels the square. Measure the x and y difference between the start and end positions, where the positive y axis is in the direction of where the bot is initially facing forward and the positive x axis is 90° to the right:

UMBMark Type A CW

[Note that the x offset in the above diagram is positive and the y value is negative.]

Do this four more times and get an average for the clockwise x and y offsets.

Change the testPath to be ccwSquare

int16_t *testPath = ccwSquare;

And perform the test 5 more times and again average the counter clockwise x and y offsets.

Using the averaged x and y values for clockwise and counter clockwise runs perform the following calculations to find the values for WHEEL_RL_SCALER and WHEELBASE_SCALER:

L = SQUARE_SIZE
WB = WHEELBASE
CCWx = average counter clockwise x offset
CCWy = average counter clockwise y offset
CWx = average clockwise x offset
CWy = average clockwise y offset

Ax = ( CWx – CCWx ) / 4 * L
Bx = – ( CWx + CCWx ) / 4 * L
Rx = ( L / 2 ) / SIN( Bx / 2 )
Edx = ( Rx + WB/2) / ( Rx – WB/2)
Ebx = 90 / ( 90 – ( Ax * 180 / π ) )

AlphaY = – ( CWy + CCWy ) / 4 * L
BetaY = ( CCWy – CWy ) / 4 * L
Ry = ( L / 2 ) / SIN( Betay / 2 )
Edy = ( Ry + B / 2) / ( Ry – B / 2)
Eby = 90 / ( 90 – ( Ay * 180 / π ) )

WHEELBASE_SCALER = ( Eby + Ebx ) / 2
WHEEL_RL_SCALER = ( Edy + Edx ) / 2

With these new values, run the test again and see if the new x and y offsets are smaller this time. If you want you can use these new values recalculate WHEEL_RL_SCALER and WHEELBASE_SCALER to get even more accuracy. However, remember that effect is accumulative and so the results from the first run must be multiplied by the results from the second run or you will lose the correction from the first run

Google Doc Spreadsheet

If you don’t want to manually do the calculations it is worthwhile to make a spreadsheet.

I created one for myself that also plots the data:

Screen Shot 2014-05-06 at 11.38.31 PM

It’s a Google doc and you can find it here: UMBmark Worksheet V1.

Make a copy for your own use by clicking on File -> Make a Copy.

Screen Shot 2014-05-07 at 2.10.20 PM

[Note that you'll need to have a Google Drive account to make a copy.]

Use Serial Output for Better Results

If you have bluetooth or some way to remotely capture the serial output from NavBot then you can avail of the waypoint information to get more accurate results in your measurements.

In NavBot_v1.ino set TARGET_INFO to 1 in the serial output config section:

//----------------------------------------
// Serial output config
//----------------------------------------

#define SERIAL_BAUD   9600

#define MOTOR_INFO      0       // print motor values
#define BUTTON_INFO     0       // print button state
#define NAV_INFO        0       // print nav data
#define TARGET_INFO     1       // print nav data at way points
#define MEM_REPORT      0       // print memory usage at startup

Now every time the pilot reaches a waypoint the positional information is printed out:

For the UMBmark test we can subtract the reported final x and y positions from our measured x and y values:

Screen Shot 2014-05-23 at 5.53.48 PM

In the above case we’d subtract -8.58 mm from x and -1.99 mm from y.

h is the heading in degrees, v is the velocity in mm/second and t is the turning rate in degrees/second. For TARGET_INFO v and t will always be zero as the bot will be at a complete stop where reporting its position.

Similarly for the distance test:

Screen Shot 2014-05-23 at 10.18.33 PM

We can read the exact distance the robot thinks it has traveled from the y value which is 2002.06 mm.

About these ads

One comment

  1. […] This is actually normal behavior and has to do with the true size of the wheels and wheelbase compared to what we have measured. These anomalies can be corrected for using the UMBmark Test. I have created a separate post that shows how to perform this test: NavBot: Calibration […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.