1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All right reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12 // Authors: Radu Serban
13 // =============================================================================
14 //
15 // Wrapper classes for modeling an entire LMTV vehicle assembly
16 // (including the vehicle itself, the powertrain, and the tires).
17 //
18 // =============================================================================
19 
20 #ifndef LMTV_H
21 #define LMTV_H
22 
23 #include <array>
24 #include <string>
25 
26 #include "chrono_vehicle/wheeled_vehicle/tire/ChPacejkaTire.h"
27 
28 #include "chrono_models/ChApiModels.h"
29 #include "chrono_models/vehicle/mtv/LMTV_Vehicle.h"
30 #include "chrono_models/vehicle/mtv/FMTV_SimpleCVTPowertrain.h"
31 #include "chrono_models/vehicle/mtv/FMTV_SimpleMapPowertrain.h"
32 #include "chrono_models/vehicle/mtv/FMTV_SimplePowertrain.h"
33 #include "chrono_models/vehicle/mtv/FMTV_Powertrain.h"
34 #include "chrono_models/vehicle/mtv/FMTV_RigidTire.h"
35 #include "chrono_models/vehicle/mtv/FMTV_TMeasyTire.h"
36 
37 namespace chrono {
38 namespace vehicle {
39 namespace fmtv {
40 
41 /// @addtogroup vehicle_models_fmtv
42 /// @{
43 
44 /// Definition of the LMTV assembly.
45 /// This class encapsulates a concrete wheeled vehicle model with parameters corresponding to
46 /// an LMTV vehicle, the powertrain model, and the 4 tires.
47 class CH_MODELS_API LMTV {
48   public:
49     LMTV();
50     LMTV(ChSystem* system);
51 
52     ~LMTV();
53 
SetContactMethod(ChContactMethod val)54     void SetContactMethod(ChContactMethod val) { m_contactMethod = val; }
55 
SetChassisFixed(bool val)56     void SetChassisFixed(bool val) { m_fixed = val; }
SetChassisCollisionType(CollisionType val)57     void SetChassisCollisionType(CollisionType val) { m_chassisCollisionType = val; }
58 
SetBrakeType(BrakeType brake_type)59      void SetBrakeType(BrakeType brake_type) { m_brake_type = brake_type; }
SetTireType(TireModelType val)60     void SetTireType(TireModelType val) { m_tireType = val; }
SetPowertrainType(PowertrainModelType val)61     void SetPowertrainType(PowertrainModelType val) { m_powertrainType = val; }
62 
63     // void setSteeringType(SteeringTypeWV val) { m_steeringType = val; }
64 
SetInitPosition(const ChCoordsys<> & pos)65     void SetInitPosition(const ChCoordsys<>& pos) { m_initPos = pos; }
SetInitFwdVel(double fwdVel)66     void SetInitFwdVel(double fwdVel) { m_initFwdVel = fwdVel; }
SetInitWheelAngVel(const std::vector<double> & omega)67     void SetInitWheelAngVel(const std::vector<double>& omega) { m_initOmega = omega; }
68 
SetTireStepSize(double step_size)69     void SetTireStepSize(double step_size) { m_tire_step_size = step_size; }
70 
EnableBrakeLocking(bool lock)71     void EnableBrakeLocking(bool lock) { m_brake_locking = lock; }
72 
GetSystem()73     ChSystem* GetSystem() const { return m_vehicle->GetSystem(); }
GetVehicle()74     ChWheeledVehicle& GetVehicle() const { return *m_vehicle; }
GetChassis()75     std::shared_ptr<ChChassis> GetChassis() const { return m_vehicle->GetChassis(); }
GetChassisBody()76     std::shared_ptr<ChBodyAuxRef> GetChassisBody() const { return m_vehicle->GetChassisBody(); }
GetPowertrain()77     std::shared_ptr<ChPowertrain> GetPowertrain() const { return m_vehicle->GetPowertrain(); }
78     double GetTotalMass() const;
79 
80     void Initialize();
81 
LockAxleDifferential(int axle,bool lock)82     void LockAxleDifferential(int axle, bool lock) { m_vehicle->LockAxleDifferential(axle, lock); }
LockCentralDifferential(int which,bool lock)83     void LockCentralDifferential(int which, bool lock) { m_vehicle->LockCentralDifferential(which, lock); }
84 
85     void SetAerodynamicDrag(double Cd, double area, double air_density);
86 
SetChassisVisualizationType(VisualizationType vis)87     void SetChassisVisualizationType(VisualizationType vis) { m_vehicle->SetChassisVisualizationType(vis); }
SetChassisRearVisualizationType(VisualizationType vis)88     void SetChassisRearVisualizationType(VisualizationType vis) { m_vehicle->SetChassisRearVisualizationType(vis); }
SetSuspensionVisualizationType(VisualizationType vis)89     void SetSuspensionVisualizationType(VisualizationType vis) { m_vehicle->SetSuspensionVisualizationType(vis); }
SetSteeringVisualizationType(VisualizationType vis)90     void SetSteeringVisualizationType(VisualizationType vis) { m_vehicle->SetSteeringVisualizationType(vis); }
SetWheelVisualizationType(VisualizationType vis)91     void SetWheelVisualizationType(VisualizationType vis) { m_vehicle->SetWheelVisualizationType(vis); }
92     void SetTireVisualizationType(VisualizationType vis);
93 
94     void Synchronize(double time, const ChDriver::Inputs& driver_inputs, const ChTerrain& terrain);
95     void Advance(double step);
96 
LogHardpointLocations()97     void LogHardpointLocations() { m_vehicle->LogHardpointLocations(); }
DebugLog(int what)98     void DebugLog(int what) { m_vehicle->DebugLog(what); }
99 
100   protected:
101     ChContactMethod m_contactMethod;
102     CollisionType m_chassisCollisionType;
103     bool m_fixed;
104     bool m_brake_locking;
105 
106     BrakeType m_brake_type;
107     TireModelType m_tireType;
108     PowertrainModelType m_powertrainType;
109 
110     double m_tire_step_size;
111 
112     SteeringTypeWV m_steeringType;
113 
114     ChCoordsys<> m_initPos;
115     double m_initFwdVel;
116     std::vector<double> m_initOmega;
117 
118     bool m_apply_drag;
119     double m_Cd;
120     double m_area;
121     double m_air_density;
122 
123     ChSystem* m_system;
124     LMTV_Vehicle* m_vehicle;
125 
126     double m_tire_mass;
127 };
128 
129 /// @} vehicle_models_fmtv
130 
131 }  // namespace fmtv
132 }  // end namespace vehicle
133 }  // end namespace chrono
134 
135 #endif
136