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, Michael Taylor
13 // =============================================================================
14 //
15 // Base class for continuous band track shoes using rigid treads.
16 // Derived classes specify actual template definitions, using different models
17 // for the track web.
18 //
19 // =============================================================================
20 
21 #ifndef CH_TRACK_SHOE_BAND_H
22 #define CH_TRACK_SHOE_BAND_H
23 
24 #include "chrono/assets/ChTriangleMeshShape.h"
25 
26 #include "chrono_vehicle/ChApiVehicle.h"
27 #include "chrono_vehicle/ChSubsysDefs.h"
28 
29 #include "chrono_vehicle/tracked_vehicle/ChTrackShoe.h"
30 
31 namespace chrono {
32 namespace vehicle {
33 
34 /// @addtogroup vehicle_tracked_shoe
35 /// @{
36 
37 /// Base class for continuous band track shoes using rigid treads.
38 /// Derived classes specify actual template definitions, using different models
39 /// for the track web.
40 class CH_VEHICLE_API ChTrackShoeBand : public ChTrackShoe {
41   public:
42     ChTrackShoeBand(const std::string& name  ///< [in] name of the subsystem
43     );
44 
~ChTrackShoeBand()45     virtual ~ChTrackShoeBand() {}
46 
47     /// Get the mass of the track shoe.
48     virtual double GetMass() const override;
49 
50     /// Return the pitch length of the track shoe.
51     /// This quantity must agree with the pitch of the sprocket gear.
52     virtual double GetPitch() const override;
53 
54     /// Initialize this track shoe subsystem.
55     /// The track shoe is created within the specified system and initialized
56     /// at the specified location and orientation (expressed in the global frame).
57     /// This version initializes the bodies of a CB rigid-link track shoe such that
58     /// the center of the track shoe subsystem is at the specified location and all
59     /// bodies have the specified orientation.
60     virtual void Initialize(std::shared_ptr<ChBodyAuxRef> chassis,  ///< [in] handle to the chassis body
61                             const ChVector<>& location,             ///< [in] location relative to the chassis frame
62                             const ChQuaternion<>& rotation          ///< [in] orientation relative to the chassis frame
63                             ) override;
64 
65     /// Write the procedurally-generated tread body visualization mesh to a Wavefront OBJ file.
66     void WriteTreadVisualizationMesh(const std::string& out_dir);
67 
68     /// Export the procedurally-generated tread body visualization mesh as a macro in a PovRay include file.
69     void ExportTreadVisualizationMeshPovray(const std::string& out_dir);
70 
71   protected:
72     /// Return the mass of the tread body.
73     virtual double GetTreadMass() const = 0;
74 
75     /// Return the mass of the web.
76     /// This will be equally distributed over the specified number of web segments.
77     virtual double GetWebMass() const = 0;
78 
79     /// Return the moments of inertia of the tread body.
80     virtual const ChVector<>& GetTreadInertia() const = 0;
81 
82     /// Return the moments of inertia of the web.
83     /// These will be distributed over the specified number of web segments.
84     virtual const ChVector<>& GetWebInertia() const = 0;
85 
86     /// Return the dimensions of the contact box for the guiding pin.
87     /// Note that this is for contact with wheels, idler, and ground only.
88     /// This contact geometry does not affect contact with the sprocket.
89     virtual const ChVector<>& GetGuideBoxDimensions() const = 0;
90 
91     /// Return the offset (in X direction) of the guiding pin.
92     virtual double GetGuideBoxOffsetX() const = 0;
93 
94     /// Return the location of the guiding pin center, expressed in the shoe reference frame.
95     virtual ChVector<> GetLateralContactPoint() const override;
96 
97     /// Return the width of the CB track belt (in the Y direction)
98     virtual double GetBeltWidth() const = 0;
99 
100     /// Return the length of the flat tip of the tread tooth tip (in the X direction)
101     virtual double GetToothTipLength() const = 0;
102     /// Return the length of the base of the tread tooth (in the X direction) where the tooth circular profile ends
103     virtual double GetToothBaseLength() const = 0;
104     /// Return the width of the one of the tooth profile sections of the tread tooth (in the Y direction)
105     virtual double GetToothWidth() const = 0;
106     /// Return the height from the base to the tip of the tread tooth profile (in the Z direction)
107     virtual double GetToothHeight() const = 0;
108     /// Return the radius of the tooth profile arc that connects the tooth tip and base lines
109     virtual double GetToothArcRadius() const = 0;
110 
111     /// Return the combined length of all of the web sections (in the X direction)
112     virtual double GetWebLength() const = 0;
113     /// Return the thickness of the web section (in the Z direction)
114     virtual double GetWebThickness() const = 0;
115 
116     /// Return the length of the tread below the web area (in the X direction, tread pad for ground contact)
117     virtual double GetTreadLength() const = 0;
118     /// Return the thickness of the tread below the web area (tread pad for ground contact)
119     virtual double GetTreadThickness() const = 0;
120 
121     /// Specify the name assigned to the procedurally-generated tread body visualization mesh.
122     virtual const std::string& GetTreadVisualizationMeshName() const = 0;
123 
124     /// Create the contact materials. A derived class must set 4 materials, consistent with the specified contact
125     /// method, for interactionss with the sprocket, wheels, and ground. Note that these can be shared.
126     virtual void CreateContactMaterials(ChContactMethod contact_method) = 0;
127 
128     /// Add contact geometry for the tread body.
129     /// Note that this is for contact with wheels, idler, and ground only.
130     /// This contact geometry does not affect contact with the sprocket.
131     void AddShoeContact();
132 
133     /// Add visualization of the tread body, based on primitives corresponding to the contact shapes.
134     /// Note that the "primitive" shape for the tread body is a procedurally-generated mesh.
135     void AddShoeVisualization();
136 
137     /// Get index-specific color (for visualization)
138     static ChColor GetColor(size_t index);
139 
140     // Contact materials
141     std::shared_ptr<ChMaterialSurface> m_tooth_material;  ///< contact material for teeth (sprocket interaction)
142     std::shared_ptr<ChMaterialSurface> m_body_material;   ///< contact material for main body (wheel interaction)
143     std::shared_ptr<ChMaterialSurface> m_pad_material;    ///< contact material for pad (ground interaction)
144     std::shared_ptr<ChMaterialSurface> m_guide_material;  ///< contact material for guide pin (wheel interaction)
145 
146   private:
147     /// Utilities for creating the tooth visualization mesh.
148     int ProfilePoints(std::vector<ChVector2<>>& points, std::vector<ChVector2<>>& normals);
149     std::shared_ptr<ChTriangleMeshShape> ToothMesh(double y);
150 
151     ChVector2<> m_center_p;       ///< center of (+x) arc, in tread body x-z plane
152     ChVector2<> m_center_m;       ///< center of (-x) arc, in tread body x-z plane
153     double m_center_p_arc_start;  ///< starting angle of the (+x) arc, in tread body x-z plane
154     double m_center_p_arc_end;    ///< ending angle of the (+x) arc, in tread body x-z plane
155     double m_center_m_arc_start;  ///< starting angle of the (-x) arc, in tread body x-z plane
156     double m_center_m_arc_end;    ///< ending angle of the (-x) arc, in tread body x-z plane
157 
158     friend class ChSprocketBand;
159     friend class SprocketBandContactCB;
160 };
161 
162 /// Vector of handles to continuous band track shoe subsystems.
163 typedef std::vector<std::shared_ptr<ChTrackShoeBand>> ChTrackShoeBandList;
164 
165 /// @} vehicle_tracked_shoe
166 
167 }  // end namespace vehicle
168 }  // end namespace chrono
169 
170 #endif
171