10 #ifndef CGenericSensor_H
11 #define CGenericSensor_H
73 using Ptr = std::shared_ptr<CGenericSensor>;
79 typedef std::pair<mrpt::system::TTimeStamp, mrpt::utils::CSerializable::Ptr>
124 typedef std::map<std::string, const TSensorClassId*>
177 const std::vector<mrpt::utils::CSerializable::Ptr>&
obj);
183 std::vector<mrpt::utils::CSerializable::Ptr>(1,
obj));
305 #define SENSOR_CLASS_ID(class_name) \
306 static_cast<const mrpt::hwdrivers::TSensorClassId*>( \
307 &mrpt::hwdrivers::class_name::class##class_name)
309 #define SENSOR_IS_CLASS(ptrObj, class_name) \
310 (ptrObj->GetRuntimeClass() == SENSOR_CLASS_ID(class_name))
315 #define DEFINE_GENERIC_SENSOR(class_name) \
317 static mrpt::hwdrivers::CGenericSensor::CLASSINIT_GENERIC_SENSOR \
318 _init_##class_name; \
321 static mrpt::hwdrivers::TSensorClassId class##class_name; \
322 virtual const mrpt::hwdrivers::TSensorClassId* GetRuntimeClass() const; \
323 static mrpt::hwdrivers::CGenericSensor* CreateObject(); \
324 static void doRegister() \
326 CGenericSensor::registerClass(SENSOR_CLASS_ID(class_name)); \
331 #define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace) \
332 mrpt::hwdrivers::CGenericSensor* NameSpace::class_name::CreateObject() \
334 return static_cast<hwdrivers::CGenericSensor*>( \
335 new NameSpace::class_name); \
337 mrpt::hwdrivers::TSensorClassId NameSpace::class_name::class##class_name = \
338 {#class_name, NameSpace::class_name::CreateObject}; \
339 const mrpt::hwdrivers::TSensorClassId* \
340 NameSpace::class_name::GetRuntimeClass() const \
342 return SENSOR_CLASS_ID(class_name); \
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
void appendObservations(const std::vector< mrpt::utils::CSerializable::Ptr > &obj)
This method must be called by derived classes to enqueue a new observation in the list to be returned...
void setSensorLabel(const std::string &sensorLabel)
std::string m_path_for_external_images
The path where to save off-rawlog images: empty means save images embedded in the rawlog.
static registered_sensor_classes_t & get_registered_sensor_classes()
Access to singleton.
CGenericSensor & operator=(const CGenericSensor &)=delete
void getObservations(TListObservations &lstObjects)
Returns a list of enqueued objects, emptying it (thread-safe).
CGenericSensor()
Constructor.
std::mutex m_csObjList
The critical section for m_objList.
bool isVerboseEnabled() const
TSensorState
The current state of the sensor.
TListObservations m_objList
The queue of objects to be returned by getObservations.
void loadConfig(const mrpt::utils::CConfigFileBase &configSource, const std::string §ion)
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensor...
virtual void doProcess()=0
This method will be invoked at a minimum rate of "process_rate" (Hz)
size_t m_grab_decimation_counter
Used when "m_grab_decimation" is enabled.
CGenericSensor(const CGenericSensor &)=delete
size_t m_grab_decimation
If set to N>=2, only 1 out of N observations will be saved to m_objList.
static void registerClass(const TSensorClassId *pNewClass)
Register a class into the internal list of "CGenericSensor" descendents.
std::shared_ptr< CGenericSensor > Ptr
std::pair< mrpt::system::TTimeStamp, mrpt::utils::CSerializable::Ptr > TListObsPair
size_t m_max_queue_len
See CGenericSensor.
TSensorState getState() const
The current state of the sensor
double m_process_rate
See CGenericSensor.
virtual void initialize()
This method can or cannot be implemented in the derived class, depending on the need for it.
std::string m_external_images_format
The extension ("jpg","gif","png",...) that determines the format of images saved externally.
std::map< std::string, const TSensorClassId * > registered_sensor_classes_t
Used in registerClass.
static CGenericSensor::Ptr createSensorPtr(const std::string &className)
Just like createSensor, but returning a smart pointer to the newly created sensor object.
double getProcessRate() const
std::string getSensorLabel() const
static CGenericSensor * createSensor(const std::string &className)
Creates a sensor by a name of the class.
virtual void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string §ion)=0
Loads specific configuration for the device from a given source of configuration parameters,...
void setExternalImageJPEGQuality(const unsigned int quality)
The quality of JPEG compression, when external images is enabled and the format is "jpg".
std::string m_sensorLabel
See CGenericSensor.
void enableVerbose(bool enabled=true)
Enable or disable extra debug info dumped to std::cout during sensor operation.
unsigned int getExternalImageJPEGQuality() const
unsigned int m_external_images_jpeg_quality
For JPEG images, the quality (default=95%).
std::multimap< mrpt::system::TTimeStamp, mrpt::utils::CSerializable::Ptr > TListObservations
void appendObservation(const mrpt::utils::CSerializable::Ptr &obj)
Like appendObservations() but for just one observation.
virtual void setPathForExternalImages(const std::string &directory)
Set the path where to save off-rawlog image files (will be ignored in those sensors where this is not...
virtual const mrpt::hwdrivers::TSensorClassId * GetRuntimeClass() const =0
virtual ~CGenericSensor()
Destructor.
void setExternalImageFormat(const std::string &ext)
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The d...
This class allows loading and storing values and vectors of different types from a configuration text...
std::shared_ptr< CSerializable > Ptr
GLsizei GLsizei GLuint * obj
GLsizei const GLfloat * value
GLsizei const GLchar ** string
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Auxiliary structure used for CSerializable runtime class ID support.
CLASSINIT_GENERIC_SENSOR(const TSensorClassId *pNewClass)
A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.
const char * className
Class name.