FrictionBase.h
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2023 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mvsim/ClassFactory.h>
13 #include <mvsim/CsvLogger.h>
14 #include <mvsim/Wheel.h>
15 #include <mvsim/basic_types.h> // fwrd decls.
16 
17 namespace mvsim
18 {
21 {
22  public:
23  using Ptr = std::shared_ptr<FrictionBase>;
24 
25  FrictionBase(VehicleBase& my_vehicle);
26  virtual ~FrictionBase();
27 
31  VehicleBase& parent, const rapidxml::xml_node<char>* xml_node);
32 
34  {
37 
41  double weight = 0;
42 
45  double motorTorque = 0;
46 
49  mrpt::math::TVector2D wheelCogLocalVel{0, 0};
50 
51  TFrictionInput(const TSimulContext& _context, Wheel& _wheel)
52  : context(_context), wheel(_wheel)
53  {
54  }
55  };
56 
59  virtual mrpt::math::TVector2D evaluate_friction(
60  const FrictionBase::TFrictionInput& input) const = 0;
61 
62  void setLogger(const std::weak_ptr<CSVLogger>& logger);
63 
64  protected:
67 
68  std::weak_ptr<CSVLogger> logger_;
69 };
70 
71 using FrictionBasePtr = std::shared_ptr<FrictionBase>;
72 
73 // Class factory:
74 typedef ClassFactory<
78 
79 #define DECLARES_REGISTER_FRICTION(CLASS_NAME) \
80  DECLARES_REGISTER_CLASS2( \
81  CLASS_NAME, FrictionBase, VehicleBase&, \
82  const rapidxml::xml_node<char>*)
83 
84 #define REGISTER_FRICTION(TEXTUAL_NAME, CLASS_NAME) \
85  REGISTER_CLASS2( \
86  TClassFactory_friction, classFactory_friction, TEXTUAL_NAME, \
87  CLASS_NAME)
88 } // namespace mvsim
std::weak_ptr< CSVLogger > logger_
Definition: FrictionBase.h:68
std::shared_ptr< FrictionBase > Ptr
Definition: FrictionBase.h:23
TFrictionInput(const TSimulContext &_context, Wheel &_wheel)
Definition: FrictionBase.h:51
const TSimulContext & context
Definition: FrictionBase.h:35
VehicleBase & myVehicle_
Definition: FrictionBase.h:66
FrictionBase(VehicleBase &my_vehicle)
std::shared_ptr< FrictionBase > FrictionBasePtr
Definition: FrictionBase.h:71
TClassFactory_friction classFactory_friction
ClassFactory< FrictionBase, VehicleBase &, const rapidxml::xml_node< char > * > TClassFactory_friction
Definition: FrictionBase.h:76
void setLogger(const std::weak_ptr< CSVLogger > &logger)
virtual mrpt::math::TVector2D evaluate_friction(const FrictionBase::TFrictionInput &input) const =0
static FrictionBase::Ptr factory(VehicleBase &parent, const rapidxml::xml_node< char > *xml_node)
mrpt::math::TVector2D wheelCogLocalVel
Definition: FrictionBase.h:49


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:20