Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #pragma once
00011
00012 #include <mvsim/basic_types.h>
00013 #include <mvsim/ClassFactory.h>
00014 #include <mvsim/Wheel.h>
00015 #include <mvsim/CsvLogger.h>
00016
00017 namespace mvsim
00018 {
00020 class FrictionBase
00021 {
00022 public:
00023 FrictionBase(VehicleBase& my_vehicle);
00024 virtual ~FrictionBase();
00025
00028 static FrictionBase* factory(
00029 VehicleBase& parent, const rapidxml::xml_node<char>* xml_node);
00030
00031 struct TFrictionInput
00032 {
00033 const TSimulContext& context;
00034 Wheel& wheel;
00035 double weight;
00036
00037 double motor_torque;
00038
00039
00040 mrpt::math::TPoint2D wheel_speed;
00041
00042
00043
00044 TFrictionInput(const TSimulContext& _context, Wheel& _wheel)
00045 : context(_context),
00046 wheel(_wheel),
00047 weight(.0),
00048 motor_torque(.0),
00049 wheel_speed(0, 0)
00050 {
00051 }
00052 };
00053
00056 virtual void evaluate_friction(
00057 const FrictionBase::TFrictionInput& input,
00058 mrpt::math::TPoint2D& out_result_force_local) const = 0;
00059
00060 void setLogger(const std::weak_ptr<CSVLogger>& logger);
00061
00062 protected:
00063 World* m_world;
00064 VehicleBase& m_my_vehicle;
00065
00066 MRPT_TODO("When each wheel will have its own friction - remove this.")
00067 std::weak_ptr<CSVLogger> m_logger;
00068 };
00069
00070 typedef std::shared_ptr<FrictionBase> FrictionBasePtr;
00071
00072
00073 typedef ClassFactory<FrictionBase, VehicleBase&,
00074 const rapidxml::xml_node<char>*>
00075 TClassFactory_friction;
00076 extern TClassFactory_friction classFactory_friction;
00077
00078 #define DECLARES_REGISTER_FRICTION(CLASS_NAME) \
00079 DECLARES_REGISTER_CLASS2( \
00080 CLASS_NAME, FrictionBase, VehicleBase&, \
00081 const rapidxml::xml_node<char>*)
00082
00083 #define REGISTER_FRICTION(TEXTUAL_NAME, CLASS_NAME) \
00084 REGISTER_CLASS2( \
00085 TClassFactory_friction, classFactory_friction, TEXTUAL_NAME, \
00086 CLASS_NAME)
00087 }