A class for calculating steering angle calculations based on current and desired heading and specified intercept distance along the new path.

Dependents:   AVC_20110423

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Steering.h Source File

Steering.h

00001 
00002 #define PI 3.141592653589
00003 
00004 /** A class for managing steering angle calculations based on current and desired heading
00005  *  and specified intercept distance along the new path.  
00006  *
00007  *  See Notebook entry: http://mbed.org/users/shimniok/notebook/smooth-steering-for-rc-car/
00008  */
00009 class Steering
00010 {
00011   public:
00012     /** create a new steering calculator
00013      *
00014      * @param wheelbase vehicle wheelbase
00015      * @param track vehicle track width
00016      * @param intercept new course intercept distance
00017      */
00018     Steering(float wheelbase, float track);
00019 
00020     /** set intercept distance
00021      * @param intercept distance along new course at which turn arc will intercept
00022      */
00023     void setIntercept(float intercept);
00024 
00025     /** convert course change to average steering angle
00026      * assumes Ackerman steering, with track and wheelbase
00027      * and course intercept distance specified.
00028      *
00029      * See notebook: http://mbed.org/users/shimniok/notebook/smooth-steering-for-rc-car/
00030      *
00031      * @param theta relative bearing of the new course
00032      * @returns steering angle in degrees
00033      */ 
00034     float calcSA(float theta);
00035     
00036   private:
00037 
00038     inline static float angle_radians(float deg) {return (PI/180.0)*deg;}
00039 
00040     inline static float angle_degrees(float rad) {return (180/PI)*rad;}
00041 
00042     float _wheelbase;
00043     float _track;
00044     float _intercept;
00045 };