1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights 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: Daniel Melanz, Radu Serban
13 // =============================================================================
14 //
15 // Multi-link suspension constructed with data from file.
16 //
17 // =============================================================================
18 
19 #ifndef MULTILINK_H
20 #define MULTILINK_H
21 
22 #include "chrono_vehicle/ChApiVehicle.h"
23 #include "chrono_vehicle/wheeled_vehicle/suspension/ChMultiLink.h"
24 
25 #include "chrono_thirdparty/rapidjson/document.h"
26 
27 namespace chrono {
28 namespace vehicle {
29 
30 /// @addtogroup vehicle_wheeled_suspension
31 /// @{
32 
33 /// Multi-link suspension constructed with data from file.
34 class CH_VEHICLE_API MultiLink : public ChMultiLink {
35   public:
36     MultiLink(const std::string& filename);
37     MultiLink(const rapidjson::Document& d);
38     ~MultiLink();
39 
UseTierodBodies()40     virtual bool UseTierodBodies() const override { return m_use_tierod_bodies; }
41 
getSpindleMass()42     virtual double getSpindleMass() const override { return m_spindleMass; }
getUpperArmMass()43     virtual double getUpperArmMass() const override { return m_upperArmMass; }
getLateralMass()44     virtual double getLateralMass() const override { return m_lateralMass; }
getTrailingLinkMass()45     virtual double getTrailingLinkMass() const override { return m_trailingLinkMass; }
getUprightMass()46     virtual double getUprightMass() const override { return m_uprightMass; }
getTierodMass()47     virtual double getTierodMass() const override { return m_tierodMass; }
48 
getSpindleRadius()49     virtual double getSpindleRadius() const override { return m_spindleRadius; }
getSpindleWidth()50     virtual double getSpindleWidth() const override { return m_spindleWidth; }
getUpperArmRadius()51     virtual double getUpperArmRadius() const override { return m_upperArmRadius; }
getLateralRadius()52     virtual double getLateralRadius() const override { return m_lateralRadius; }
getTrailingLinkRadius()53     virtual double getTrailingLinkRadius() const override { return m_trailingLinkRadius; }
getUprightRadius()54     virtual double getUprightRadius() const override { return m_uprightRadius; }
getTierodRadius()55     virtual double getTierodRadius() const override { return m_tierodRadius; }
56 
getSpindleInertia()57     virtual const ChVector<>& getSpindleInertia() const override { return m_spindleInertia; }
getUpperArmInertia()58     virtual const ChVector<>& getUpperArmInertia() const override { return m_upperArmInertia; }
getLateralInertia()59     virtual const ChVector<>& getLateralInertia() const override { return m_lateralInertia; }
getTrailingLinkInertia()60     virtual const ChVector<>& getTrailingLinkInertia() const override { return m_trailingLinkInertia; }
getUprightInertia()61     virtual const ChVector<>& getUprightInertia() const override { return m_uprightInertia; }
getTierodInertia()62     virtual const ChVector<> getTierodInertia() const override { return m_tierodInertia; }
63 
getAxleInertia()64     virtual double getAxleInertia() const override { return m_axleInertia; }
65 
getSpringRestLength()66     virtual double getSpringRestLength() const override { return m_springRestLength; }
getSpringForceFunctor()67     virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getSpringForceFunctor() const override { return m_springForceCB; }
getShockForceFunctor()68     virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getShockForceFunctor() const override { return m_shockForceCB; }
69 
getTierodBushingData()70     virtual std::shared_ptr<ChVehicleBushingData> getTierodBushingData() const override { return m_tierodBushingData; }
71 
72   private:
getLocation(PointId which)73     virtual const ChVector<> getLocation(PointId which) override { return m_points[which]; }
getDirection(DirectionId which)74     virtual const ChVector<> getDirection(DirectionId which) override { return m_directions[which]; }
75 
76     virtual void Create(const rapidjson::Document& d) override;
77 
78     std::shared_ptr<ChLinkTSDA::ForceFunctor> m_springForceCB;
79     std::shared_ptr<ChLinkTSDA::ForceFunctor> m_shockForceCB;
80 
81     ChVector<> m_points[NUM_POINTS];
82     ChVector<> m_directions[NUM_DIRS];
83 
84     bool m_use_tierod_bodies;
85 
86     double m_spindleMass;
87     double m_upperArmMass;
88     double m_lateralMass;
89     double m_trailingLinkMass;
90     double m_uprightMass;
91     double m_tierodMass;
92 
93     double m_spindleRadius;
94     double m_spindleWidth;
95     double m_upperArmRadius;
96     double m_lateralRadius;
97     double m_trailingLinkRadius;
98     double m_uprightRadius;
99     double m_tierodRadius;
100 
101     ChVector<> m_spindleInertia;
102     ChVector<> m_upperArmInertia;
103     ChVector<> m_lateralInertia;
104     ChVector<> m_trailingLinkInertia;
105     ChVector<> m_uprightInertia;
106     ChVector<> m_tierodInertia;
107 
108     double m_axleInertia;
109 
110     std::shared_ptr<ChVehicleBushingData> m_tierodBushingData;
111 
112     double m_springRestLength;
113 };
114 
115 /// @} vehicle_wheeled_suspension
116 
117 }  // end namespace vehicle
118 }  // end namespace chrono
119 
120 #endif
121