00001 // Differential.cc - the differential gear system. 00002 // 00003 // Copyright (C) 2001--2004 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/Differential.h> 00022 #include <vamos/geometry/Conversions.h> 00023 00024 // class Differential - the differential gear system of the 00025 // drivetrain. 00026 00027 Vamos_Body:: 00028 Differential::Differential (double final_drive, double anti_slip) 00029 : m_final_drive (final_drive), 00030 m_anti_slip (anti_slip), 00031 m_left_wheel_speed (0.0), 00032 m_right_wheel_speed (0.0), 00033 m_left_wheel_torque (0.0), 00034 m_right_wheel_torque (0.0) 00035 { 00036 } 00037 00038 double Vamos_Body::Differential:: 00039 get_driveshaft_speed (double left_wheel_speed, double right_wheel_speed) 00040 { 00041 m_left_wheel_speed = left_wheel_speed; 00042 m_right_wheel_speed = right_wheel_speed; 00043 return m_final_drive * (left_wheel_speed + right_wheel_speed) / 2.0; 00044 } 00045 00046 double Vamos_Body:: 00047 Differential::get_anti_slip_torque () const 00048 { 00049 double drag = m_anti_slip * (m_left_wheel_speed - m_right_wheel_speed); 00050 return Vamos_Geometry::clip (drag, -m_anti_slip, m_anti_slip); 00051 } 00052 00053 void Vamos_Body:: 00054 Differential::find_wheel_torques (double driveshaft_torque) 00055 { 00056 double torque = driveshaft_torque * m_final_drive / 2.0; 00057 double drag = get_anti_slip_torque (); 00058 m_left_wheel_torque = torque - drag; 00059 m_right_wheel_torque = torque + drag; 00060 }
1.4.6