SensorBase.h
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 
10 #pragma once
11 
12 #include <mrpt/obs/obs_frwds.h>
13 #include <mvsim/ClassFactory.h>
14 #include <mvsim/Simulable.h>
15 #include <mvsim/VisualObject.h>
16 
17 namespace mvsim
18 {
19 class VehicleBase;
20 
21 class SensorBase : public VisualObject, public Simulable
22 {
23  public:
24  using Ptr = std::shared_ptr<SensorBase>;
25 
26  SensorBase(VehicleBase& vehicle);
27  virtual ~SensorBase();
29 
32  static SensorBase::Ptr factory(
33  VehicleBase& parent, const rapidxml::xml_node<char>* xml_node);
34 
35  virtual void loadConfigFrom(const rapidxml::xml_node<char>* root) = 0;
36 
37  double m_sensor_period;
38 
40  void registerOnServer(mvsim::Client& c) override;
41 
42  protected:
44 
47 
48  std::string publishTopic_;
49 
50  bool parseSensorPublish(
51  const rapidxml::xml_node<char>* node,
52  const std::map<std::string, std::string>& varValues);
53 
55  const std::shared_ptr<mrpt::obs::CObservation>& obs,
56  const TSimulContext& context);
57 };
58 
59 // Class factory:
63 
64 #define DECLARES_REGISTER_SENSOR(CLASS_NAME) \
65  DECLARES_REGISTER_CLASS2( \
66  CLASS_NAME, SensorBase, VehicleBase&, const rapidxml::xml_node<char>*)
67 
68 #define REGISTER_SENSOR(TEXTUAL_NAME, CLASS_NAME) \
69  REGISTER_CLASS2( \
70  TClassFactory_sensors, classFactory_sensors, TEXTUAL_NAME, CLASS_NAME)
71 } // namespace mvsim
static SensorBase::Ptr factory(VehicleBase &parent, const rapidxml::xml_node< char > *xml_node)
Definition: SensorBase.cpp:54
std::string publishTopic_
Definition: SensorBase.h:48
const GLfloat * c
bool parseSensorPublish(const rapidxml::xml_node< char > *node, const std::map< std::string, std::string > &varValues)
Definition: SensorBase.cpp:88
void registerOnServer(mvsim::Client &c) override
(in seconds) (Default = 0.1)
Definition: SensorBase.cpp:132
SensorBase(VehicleBase &vehicle)
Definition: SensorBase.cpp:44
VehicleBase & m_vehicle
The vehicle this sensor is attached to.
Definition: SensorBase.h:43
void reportNewObservation(const std::shared_ptr< mrpt::obs::CObservation > &obs, const TSimulContext &context)
Definition: SensorBase.cpp:106
std::shared_ptr< SensorBase > Ptr
Definition: SensorBase.h:24
virtual ~SensorBase()
which the sensor is attached.
virtual void loadConfigFrom(const rapidxml::xml_node< char > *root)=0
TClassFactory_sensors classFactory_sensors
Definition: SensorBase.cpp:29
double m_sensor_period
Definition: SensorBase.h:37
ClassFactory< SensorBase, VehicleBase &, const rapidxml::xml_node< char > * > TClassFactory_sensors
Definition: SensorBase.h:61
double m_sensor_last_timestamp
Definition: SensorBase.h:46


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