include/vamos/body/Tire.h

Go to the documentation of this file.
00001 //  Tire.h - the tire for a wheel.
00002 //
00003 //  Copyright (C) 2001 Sam Varner
00004 //
00005 //  This file is part of Vamos Automotive Simulator.
00006 //
00007 //  This program is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU General Public License as published by
00009 //  the Free Software Foundation; either version 2 of the License, or
00010 //  (at your option) any later version.
00011 //
00012 //  This program is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU General Public License
00018 //  along with this program; if not, write to the Free Software
00019 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 #ifndef _TIRE_H_
00022 #define _TIRE_H_
00023 
00024 #include <iostream>
00025 using namespace std;
00026 
00027 #include <vamos/geometry/Material.h>
00028 #include <vamos/geometry/Three_Vector.h>
00029 #include <vamos/body/Particle.h>
00030 
00031 #include <vector>
00032 
00033 #define HAT_ITERATIONS 20
00034 #define HAT_LOAD 0.5
00035 
00036 namespace Vamos_Body
00037 {
00038   //* The frictional properties of the tire.
00039   class Tire_Friction
00040   {
00041         // The parameters of the longitudinal magic equation.
00042         std::vector <double> m_longitudital_parameters;
00043 
00044         // The parameters of the transverse magic equation.
00045         std::vector <double> m_transverse_parameters;
00046 
00047         // The parameters of the magic equation for aligning torque.
00048         std::vector <double> m_aligning_parameters;
00049 
00050         // A parameter that is used to set the volume of the tire squeal
00051         // sound. 
00052         double m_slide;
00053 
00054   public:
00055         //** Constructor
00056         Tire_Friction (const std::vector <double>& long_parameters,
00057                                    const std::vector <double>& trans_parameters,
00058                                    const std::vector <double>& align_parameters);
00059 
00060         // Return the friction vector calculated from the magic formula.
00061         // HUB_VELOCITY is the velocity vector of the wheel's reference
00062         // frame.  PATCH_SPEED is the rearward speed of the contact pacth
00063         // with respect to the wheel's frame.
00064         Vamos_Geometry::Three_Vector 
00065         friction_forces (double normal_force, double friction_factor, 
00066                                          const Vamos_Geometry::Three_Vector& hub_velocity, 
00067                                          double patch_speed, double current_camber,
00068                                         double sigma_hat, double alpha_hat);
00069 
00070         double Pacejka_Fx(double sigma, double Fz, double friction_factor);
00071         double Pacejka_Fy(double alpha, double Fz, double gamma, double friction_factor);
00072         double Pacejka_Mz(double sigma, double alpha, double Fz, double gamma, double friction_factor);
00073   
00074         // Return the value of the slide parameter.
00075         double slide () const { return m_slide; }
00076   };
00077 
00078   //* The tire for a wheel.
00079   class Tire : public Particle
00080   {
00081         // maximum grip sigma
00082         double sigma_hat[HAT_ITERATIONS];
00083         
00084         // maximum grip alpha
00085         double alpha_hat[HAT_ITERATIONS];
00086           
00087         // calculate maximum grip sigma and alpha
00088         void FindSigmaHatAlphaHat(double load, double & sh, double & ah);
00089           
00090         // The radius of the tire.
00091         double m_radius;
00092 
00093         // Linear rolling resistance on a hard surface.
00094         double m_rolling_resistance_1;
00095 
00096         // Quadratic rolling resistance on a hard surface.
00097         double m_rolling_resistance_2;
00098 
00099         Tire_Friction m_tire_friction;
00100 
00101         // The rotational inertia of the tire.
00102         double m_inertia;
00103 
00104         // The rotational speed of the tire in radians per second.
00105         double m_rotational_speed;
00106 
00107         double m_last_rotational_speed;
00108 
00109         // How fast the tire is sliding.
00110         double m_slide;
00111 
00113 
00114         // The velocity of the wheel relative to the road.
00115         Vamos_Geometry::Three_Vector m_velocity;
00116 
00117         // The angular velocity about the normal to the surface.
00118         double m_normal_ang_velocity;
00119 
00120         // The force perpendicular to the surface.
00121         double m_normal_force;
00122 
00123         // The current camber, supplied by the wheel.
00124         double m_camber;
00125 
00126         // The torque on the wheel due to acceleration or braking.
00127         double m_applied_torque;
00128 
00129         // True if the brake for this wheel is locked.
00130         bool m_is_locked;
00131 
00132         // The surface that the tire is currently on.
00133         Vamos_Geometry::Material_Handle m_material;
00134 
00135         // Orient the tire's z-axis with the normal force.
00136         void orient_frame_with_unit_vector (const Vamos_Geometry::
00137                                                                                 Three_Vector& normal_unit_vector);
00138                                                                                 
00139         double m_feedback;
00140         
00141         //1.0 equals a pure off-road tire, 0.0 is a pure road-tire
00142         double m_tread;
00143         
00144         //parameters of the surface we're driving on
00145         double m_friction1;
00146         double m_friction2;
00147         double m_rolling_resistance_factor;
00148         double m_rolling_drag;
00149 
00150   public:
00151         //** Constructor
00152         Tire (double radius, double rolling_resistance_1,
00153                   double rolling_resistance_2, const Tire_Friction& friction, 
00154                   double inertia, double tread);
00155 
00156         //** Destructor
00157         //virtual ~Tire ();
00158 
00159         // Called by the wheel to update the tire.
00160         void input (const Vamos_Geometry::Three_Vector& velocity, 
00161                                 double normal_ang_velocity,
00162                                 const Vamos_Geometry::Three_Vector& normal_force,
00163                                 double camber,
00164                                 double torque,
00165                                 bool is_locked,
00166                                 Vamos_Geometry::Material_Handle material);
00167 
00168         void find_forces ();
00169 
00170         // Advance the tire in time by TIME.
00171         void propagate (double time);
00172 
00173         void rewind ();
00174 
00175         // Return the radius of the tire
00176         double radius () const { return m_radius; }
00177 
00178         // Return the rotational speed of the tire.
00179         double rotational_speed () const { return m_rotational_speed; }
00180         
00181         void set_rotational_speed(double newrs) {m_rotational_speed = newrs; m_last_rotational_speed = newrs;}
00182 
00183         // Return the linear speed of the tread.
00184         double speed () const { return m_rotational_speed * m_radius; }
00185 
00186         // Return the linear sliding speed. 
00187         double slide () const { return m_slide; }
00188 
00189         // Return the position of the contact patch in the wheel's
00190         // coordinate system.
00191         Vamos_Geometry::Three_Vector contact_position () const;
00192 
00193         // Set the tire to its initial conditions.
00194         void reset ();
00195         
00196         double GetFeedback() {return m_feedback;}
00197         
00198         void SetSurfaceParams(double f1, double f2, double rr, double rd) {m_friction1 = f1; m_friction2 = f2; m_rolling_resistance_factor = rr; m_rolling_drag = rd;}
00199   };
00200 }
00201 
00202 #endif // !_TIRE_H_

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6