src/vamos/body/Brake.cc

Go to the documentation of this file.
00001 //  Brake.cc - a brake for a wheel.
00002 //
00003 //  Copyright (C) 2001--2002  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 #include <vamos/body/Brake.h>
00022 #include <cmath>
00023 #include <iostream>
00024 #include <stdio.h>
00025 
00026 //* Class Brake
00027 
00028 //** Constructor
00029 Vamos_Body::Brake::
00030 Brake (double sliding, double radius, double area, double max_pressure, 
00031            double bias, double handbrake) :
00032   m_friction (sliding),
00033   m_radius (radius),
00034   m_area (area),
00035   m_max_pressure (max_pressure * bias),
00036   m_bias (bias),
00037   m_threshold (4.0e-4),
00038   m_is_locked (false),
00039   m_handbrake (handbrake)
00040 {
00041 }
00042 
00043 // Return the torque exerted on the wheel by the brake.
00044 double Vamos_Body::Brake::
00045 torque (double factor, double rotational_speed)
00046 {
00047   // `factor' is the fraction of maximum pressure applied. 
00048   double pressure = factor * m_bias * m_max_pressure;
00049   double normal = pressure * m_area;
00050   double torque = m_friction * normal * m_radius;
00051   double velocity = m_radius * rotational_speed;
00052   if (velocity < 0.0)
00053         torque *= -1;
00054 
00055   // See if the brake is locked.
00056   if (std::abs (velocity) < (m_threshold * normal))
00057         {
00058                 m_is_locked = true;
00059                 torque = 0.0;
00060         }
00061   else
00062         {
00063           m_is_locked = false;
00064         }
00065 //std::cout << torque << std::endl;
00066   return torque;  
00067 }

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