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 MTV vehicle assembly
16 // (including the vehicle itself, the powertrain, and the tires).
17 //
18 // =============================================================================
19 
20 #ifndef MTV_H
21 #define MTV_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/MTV_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 MTV assembly.
45 /// This class encapsulates a concrete wheeled vehicle model with parameters corresponding to
46 /// an MTV vehicle, the powertrain model, and the 6 tires.
47 class CH_MODELS_API MTV {
48   public:
49     MTV();
50     MTV(ChSystem* system);
51 
52     ~MTV();
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 
UseWalkingBeamRearSuspension(bool val)63     void UseWalkingBeamRearSuspension(bool val) { m_use_walking_beam = 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); }
SetSubchassisVisualizationType(VisualizationType vis)89     void SetSubchassisVisualizationType(VisualizationType vis) { m_vehicle->SetSubchassisVisualizationType(vis); }
SetSuspensionVisualizationType(VisualizationType vis)90     void SetSuspensionVisualizationType(VisualizationType vis) { m_vehicle->SetSuspensionVisualizationType(vis); }
SetSteeringVisualizationType(VisualizationType vis)91     void SetSteeringVisualizationType(VisualizationType vis) { m_vehicle->SetSteeringVisualizationType(vis); }
SetWheelVisualizationType(VisualizationType vis)92     void SetWheelVisualizationType(VisualizationType vis) { m_vehicle->SetWheelVisualizationType(vis); }
93     void SetTireVisualizationType(VisualizationType vis);
94 
95     void Synchronize(double time, const ChDriver::Inputs& driver_inputs, const ChTerrain& terrain);
96     void Advance(double step);
97 
LogHardpointLocations()98     void LogHardpointLocations() { m_vehicle->LogHardpointLocations(); }
DebugLog(int what)99     void DebugLog(int what) { m_vehicle->DebugLog(what); }
100 
101   protected:
102     ChContactMethod m_contactMethod;
103     CollisionType m_chassisCollisionType;
104     bool m_fixed;
105     bool m_brake_locking;
106 
107     BrakeType m_brake_type;
108     TireModelType m_tireType;
109     PowertrainModelType m_powertrainType;
110 
111     bool m_use_walking_beam;
112 
113     double m_tire_step_size;
114 
115     ChCoordsys<> m_initPos;
116     double m_initFwdVel;
117     std::vector<double> m_initOmega;
118 
119     bool m_apply_drag;
120     double m_Cd;
121     double m_area;
122     double m_air_density;
123 
124     ChSystem* m_system;
125     MTV_Vehicle* m_vehicle;
126 
127     double m_tire_mass;
128 };
129 
130 /// @} vehicle_models_fmtv
131 
132 }  // namespace fmtv
133 }  // end namespace vehicle
134 }  // end namespace chrono
135 
136 #endif
137