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: Radu Serban
13 // =============================================================================
14 //
15 // Three-link Independent Rear Suspension constructed with data from file.
16 //
17 // =============================================================================
18 
19 #ifndef THREELINK_IRS_H
20 #define THREELINK_IRS_H
21 
22 #include "chrono_vehicle/ChApiVehicle.h"
23 #include "chrono_vehicle/wheeled_vehicle/suspension/ChThreeLinkIRS.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 /// Three-link Independent Rear Suspension constructed with data from file.
34 class CH_VEHICLE_API ThreeLinkIRS : public ChThreeLinkIRS {
35   public:
36     ThreeLinkIRS(const std::string& filename);
37     ThreeLinkIRS(const rapidjson::Document& d);
38     ~ThreeLinkIRS();
39 
getSpindleMass()40     virtual double getSpindleMass() const override { return m_spindleMass; }
getArmMass()41     virtual double getArmMass() const override { return m_armMass; }
getUpperLinkMass()42     virtual double getUpperLinkMass() const override { return m_upperMass; }
getLowerLinkMass()43     virtual double getLowerLinkMass() const override { return m_lowerMass; }
44 
getSpindleRadius()45     virtual double getSpindleRadius() const override { return m_spindleRadius; }
getSpindleWidth()46     virtual double getSpindleWidth() const override { return m_spindleWidth; }
getArmRadius()47     virtual double getArmRadius() const override { return m_armRadius; }
getUpperLinkRadius()48     virtual double getUpperLinkRadius() const override { return m_upperLinkRadius; }
getLowerLinkRadius()49     virtual double getLowerLinkRadius() const override { return m_lowerLinkRadius; }
50 
getSpindleInertia()51     virtual const ChVector<>& getSpindleInertia() const override { return m_spindleInertia; }
getArmInertia()52     virtual const ChVector<>& getArmInertia() const override { return m_armInertia; }
getUpperLinkInertia()53     virtual const ChVector<>& getUpperLinkInertia() const override { return m_upperInertia; }
getLowerLinkInertia()54     virtual const ChVector<>& getLowerLinkInertia() const override { return m_lowerInertia; }
55 
getAxleInertia()56     virtual double getAxleInertia() const override { return m_axleInertia; }
57 
getSpringRestLength()58     virtual double getSpringRestLength() const override { return m_springRestLength; }
getSpringForceFunctor()59     virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getSpringForceFunctor() const override { return m_springForceCB; }
getShockForceFunctor()60     virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getShockForceFunctor() const override { return m_shockForceCB; }
61 
62   private:
getLocation(PointId which)63     virtual const ChVector<> getLocation(PointId which) override { return m_points[which]; }
getDirection(DirectionId which)64     virtual const ChVector<> getDirection(DirectionId which) override { return m_dirs[which]; }
65 
66     virtual void Create(const rapidjson::Document& d) override;
67 
68     std::shared_ptr<ChLinkTSDA::ForceFunctor> m_springForceCB;
69     std::shared_ptr<ChLinkTSDA::ForceFunctor> m_shockForceCB;
70 
71     ChVector<> m_points[NUM_POINTS];
72     ChVector<> m_dirs[NUM_DIRS];
73 
74     double m_spindleMass;
75     double m_armMass;
76     double m_upperMass;
77     double m_lowerMass;
78 
79     double m_spindleRadius;
80     double m_spindleWidth;
81     double m_armRadius;
82     double m_upperLinkRadius;
83     double m_lowerLinkRadius;
84 
85     ChVector<> m_spindleInertia;
86     ChVector<> m_armInertia;
87     ChVector<> m_upperInertia;
88     ChVector<> m_lowerInertia;
89 
90     double m_axleInertia;
91 
92     double m_springRestLength;
93 };
94 
95 /// @} vehicle_wheeled_suspension
96 
97 }  // end namespace vehicle
98 }  // end namespace chrono
99 
100 #endif
101