FrictionBase.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2020 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 
13 #include <mvsim/VehicleBase.h>
14 
15 #include <rapidxml.hpp>
16 
17 using namespace mvsim;
18 
20 
21 MRPT_TODO("When each wheel will have its own friction - remove m_logger.")
22 
23 // Explicit registration calls seem to be one (the unique?) way to assure
24 // registration takes place:
26 {
27  static bool done = false;
28  if (done)
29  return;
30  else
31  done = true;
32 
35 }
36 
38  : m_world(my_vehicle.getWorldObject()), m_my_vehicle(my_vehicle)
39 {
40 }
41 
44  VehicleBase& parent, const rapidxml::xml_node<char>* xml_node)
45 {
47 
48  using namespace std;
49  using namespace rapidxml;
50 
51  if (!xml_node || 0 != strcmp(xml_node->name(), "friction"))
52  throw runtime_error(
53  "[FrictionBase::factory] Expected XML node <friction>");
54 
55  // Parse:
56  const xml_attribute<>* frict_class = xml_node->first_attribute("class");
57  if (!frict_class || !frict_class->value())
58  throw runtime_error(
59  "[FrictionBase::factory] Missing mandatory attribute 'class' in "
60  "node <friction>");
61 
62  return classFactory_friction.create(frict_class->value(), parent, xml_node);
63 }
64 
65 void FrictionBase::setLogger(const std::weak_ptr<CSVLogger>& logger)
66 {
67  m_logger = logger;
68 }
This file contains rapidxml parser and DOM implementation.
std::shared_ptr< FrictionBase > Ptr
Definition: FrictionBase.h:23
Ch * value() const
Definition: rapidxml.hpp:692
std::weak_ptr< CSVLogger > m_logger
Definition: FrictionBase.h:68
MRPT_TODO("Modify ping to run on Windows + Test this")
FrictionBase(VehicleBase &my_vehicle)
TClassFactory_friction classFactory_friction
Ch * name() const
Definition: rapidxml.hpp:673
#define REGISTER_FRICTION(TEXTUAL_NAME, CLASS_NAME)
Definition: FrictionBase.h:84
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
Ptr create(const std::string &class_name, ARG1 a1) const
Definition: ClassFactory.h:39
void setLogger(const std::weak_ptr< CSVLogger > &logger)
static FrictionBase::Ptr factory(VehicleBase &parent, const rapidxml::xml_node< char > *xml_node)
void register_all_friction()


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51