Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
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 /** convert course change to average steering angle 00037 * assumes Ackerman steering, with track and wheelbase 00038 * and course intercept distance specified. Also, |radius| of turn is limited to limit 00039 * 00040 * See notebook: http://mbed.org/users/shimniok/notebook/smooth-steering-for-rc-car/ 00041 * 00042 * @param theta relative bearing of the new course 00043 * @param limit is the limit of the turn circle radius (absolute value) 00044 * @returns steering angle in degrees 00045 */ 00046 float calcSA(float theta, float limit); 00047 00048 /** compute steering angle based on pure pursuit algorithm 00049 */ 00050 float purePursuitSA(float hdg, float Bx, float By, float Ax, float Ay, float Bx, float By); 00051 00052 /** Compute cross track error given last waypoint, next waypoint, and robot coordinates 00053 * @returns cross track error 00054 */ 00055 float crossTrack(float Bx, float By, float Ax, float Ay, float Bx, float By); 00056 00057 private: 00058 00059 inline static float angle_radians(float deg) {return (PI/180.0)*deg;} 00060 00061 inline static float angle_degrees(float rad) {return (180/PI)*rad;} 00062 00063 float _wheelbase; 00064 float _track; 00065 float _intercept; 00066 };
Generated on Tue Jul 12 2022 14:09:28 by 1.7.2