AGX Dynamics  2.35.0.1
TrackWheel.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxVehicle/Wheel.h>
20 #include <agxVehicle/TrackNode.h>
21 
22 #include <agx/MergedBody.h>
23 
24 namespace agxVehicle
25 {
27 
32  {
33  public:
34  enum Model
35  {
38  ROLLER
39  };
40 
42  {
43  MERGE_NODES = 1 << 0,
45  SPLIT_SEGMENTS = 1 << 2,
48  MOVE_NODES_TO_ROTATION_PLANE = 1 << 3,
52  MOVE_NODES_TO_WHEEL = 1 << 4
55  };
56 
57  public:
58 #ifndef SWIG
60 #else
62 #endif
63  using Properties = agx::BitState<Property, agx::UInt32>;
64 
65  public:
80  TrackWheel( Model model,
81  agx::Real radius,
82  agx::RigidBody* rb,
83  agx::FrameRef rbRelFrame = nullptr );
84 
99  TrackWheel( Model model,
100  agx::Real radius,
101  agx::RigidBody* rb,
102  agx::AffineMatrix4x4 rbRelTransform );
103 
110  ControlPointContainer getControlPoints( agx::Real circleSegmentLength ) const;
111 
119  agx::Bool getControlPoints( agx::Real circleSegmentLength, ControlPointContainer& container ) const;
120 
124  agx::Bool hasControlPoint( const agx::Vec3& point, const agx::Real epsilon = agx::REAL_SQRT_EPSILON ) const;
125 
129  Model getModel() const;
130 
134  template<typename... ModelTypes>
135  agx::Bool isModel( ModelTypes... modelTypes ) const;
136 
140  const Properties getProperties() const;
141 
147  void setEnableProperty( Property property, agx::Bool enable );
148 
153  agx::Bool getEnableProperty( Property property ) const;
154 
158  agx::MergedBody* getMergedBody() const;
159 
164 
170 
179 
183  agxVehicle::Track* getTrack() const;
184 
185  public:
187 
189 
190  virtual void onAdd( Track* track );
191  virtual void onRemove( Track* track );
192 
194 
195  protected:
197  virtual ~TrackWheel();
198 
199  private:
200  Model m_model;
201  Properties m_properties;
202  agx::MergedBodyRef m_mergedBody;
203  Track* m_track;
204  };
205 
206  inline agx::MergedBody* TrackWheel::getMergedBody() const
207  {
208  return m_mergedBody;
209  }
210 
211  template<typename... ModelTypes>
212  inline agx::Bool TrackWheel::isModel( ModelTypes... modelTypes ) const
213  {
214  std::array<Model, sizeof... (ModelTypes)> args = { {modelTypes...} };
215  for ( const auto arg : args )
216  if ( arg == m_model )
217  return true;
218  return false;
219  }
220 
222  {
223  return m_properties;
224  }
225 
227  {
228  return m_properties.Is( property );
229  }
230 
231  inline Track* TrackWheel::getTrack() const
232  {
233  return m_track;
234  }
235 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXVEHICLE_EXPORT
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Wheel used in tracked vehicles.
Definition: TrackWheel.h:32
agx::Bool hasControlPoint(const agx::Vec3 &point, const agx::Real epsilon=agx::REAL_SQRT_EPSILON) const
agx::Bool getEnableProperty(Property property) const
Definition: TrackWheel.h:226
agxVehicle::Track * getTrack() const
Definition: TrackWheel.h:231
void setEnableProperty(Property property, agx::Bool enable)
Enable/disable a property for this wheel.
agx::UIntVector findMergedNodesIndices() const
List of node indices merged to this wheel.
agx::Bool getControlPoints(agx::Real circleSegmentLength, ControlPointContainer &container) const
Creates a set of points defining the wheel circle, each length circleSegmentLength apart.
agx::MergedBody * getOrCreateMergedBody(agxSDK::Simulation *simulation)
TrackWheel(Model model, agx::Real radius, agx::RigidBody *rb, agx::AffineMatrix4x4 rbRelTransform)
Construct given property (wheel type), radius, rigid body and transform defining wheel center,...
agx::BitState< Property, agx::UInt32 > Properties
Definition: TrackWheel.h:63
const Properties getProperties() const
Definition: TrackWheel.h:221
IndexRangeContainer findMergedNodesIndexRanges() const
Finds merged nodes indices and splits the list into ranges where the indices aren't consecutive.
@ SPROCKET
Sprocket - geared driving wheel with default property MERGE_NODES.
Definition: TrackWheel.h:36
@ IDLER
Idler - geared non-powered wheel with default property MERGE_NODES.
Definition: TrackWheel.h:37
agx::Bool isModel(ModelTypes... modelTypes) const
Definition: TrackWheel.h:212
TrackWheel(Model model, agx::Real radius, agx::RigidBody *rb, agx::FrameRef rbRelFrame=nullptr)
Construct given property (wheel type), radius, rigid body and frame defining wheel center,...
Model getModel() const
ControlPointContainer getControlPoints(agx::Real circleSegmentLength) const
Creates a set of points defining the wheel circle, each length circleSegmentLength apart.
Assembly object representing a continuous track with a given number of shoes (nodes).
Abstraction of a wheel of arbitrary geometry.
Definition: Wheel.h:38
Structure holding several "normal" rigid bodies.
Definition: MergedBody.h:56
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
This namespace contains classes related to vehicles dynamics.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
AGXCORE_EXPORT const Real REAL_SQRT_EPSILON
VectorPOD< Vec3 > Vec3Vector
agx::ref_ptr< MergedBody > MergedBodyRef
Definition: MergedBody.h:46
double Real
Definition: Real.h:42