10 #include <mrpt/core/format.h> 23 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF) 24 #include "GenericObservation.pb.h" 27 using namespace mvsim;
35 static bool done =
false;
48 m_sensor_last_timestamp(0)
62 if (!root)
throw runtime_error(
"[SensorBase::factory] XML node is nullptr");
63 if (0 != strcmp(root->
name(),
"sensor"))
65 "[SensorBase::factory] XML root element is '%s' ('sensor' " 71 if (!sensor_class || !sensor_class->
value())
73 "[VehicleBase::factory] Missing mandatory attribute 'class' in " 83 "[SensorBase::factory] Unknown sensor type '%s'", root->
name()));
90 const std::map<std::string, std::string>& varValues)
94 if (node ==
nullptr)
return false;
107 const std::shared_ptr<mrpt::obs::CObservation>& obs,
114 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF) 117 mvsim_msgs::GenericObservation msg;
118 msg.set_unixtimestamp(mrpt::Clock::toDouble(obs->timestamp));
121 std::vector<uint8_t> serializedData;
124 msg.set_mrptserializedobservation(
125 serializedData.data(), serializedData.size());
137 #if defined(MVSIM_HAS_ZMQ) && defined(MVSIM_HAS_PROTOBUF)
This file contains rapidxml parser and DOM implementation.
static SensorBase::Ptr factory(VehicleBase &parent, const rapidxml::xml_node< char > *xml_node)
std::string publishTopic_
virtual void onNewObservation([[maybe_unused]] const VehicleBase &veh, [[maybe_unused]] const mrpt::obs::CObservation *obs)
std::map< std::string, TParamEntry > TParameterDefinitions
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions ¶ms, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="")
void publishTopic(const std::string &topicName, const google::protobuf::Message &msg)
bool parseSensorPublish(const rapidxml::xml_node< char > *node, const std::map< std::string, std::string > &varValues)
void BASE_IMPEXP ObjectToOctetVector(const CSerializable *o, vector_byte &out_vector)
void registerOnServer(mvsim::Client &c) override
(in seconds) (Default = 0.1)
const std::string & getName() const
SensorBase(VehicleBase &vehicle)
VehicleBase & m_vehicle
The vehicle this sensor is attached to.
void reportNewObservation(const std::shared_ptr< mrpt::obs::CObservation > &obs, const TSimulContext &context)
std::shared_ptr< SensorBase > Ptr
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
void register_all_sensors()
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Ptr create(const std::string &class_name, ARG1 a1) const
virtual void registerOnServer(mvsim::Client &c)
virtual ~SensorBase()
which the sensor is attached.
GLsizei const GLcharARB ** string
TClassFactory_sensors classFactory_sensors
void advertiseTopic(const std::string &topicName)
#define REGISTER_SENSOR(TEXTUAL_NAME, CLASS_NAME)
This file contains rapidxml printer implementation.
mvsim::Client & commsClient()