10 #ifndef CGenericSensor_H
11 #define CGenericSensor_H
43 std::shared_ptr<CGenericSensor>
m_ptr;
51 virtual const CGenericSensor* operator ->(
void)
const {
return m_ptr.get(); }
55 bool operator !()
const {
return !m_ptr.operator bool(); }
56 operator bool()
const {
return m_ptr.operator bool(); }
57 bool present()
const {
return m_ptr.get()!=NULL; }
89 typedef std::multimap< mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr >
TListObservations;
90 typedef std::pair< mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr >
TListObsPair;
124 typedef std::shared_ptr<const CGenericSensor>
ConstPtr;
165 void appendObservations(
const std::vector<mrpt::utils::CSerializablePtr> &
obj);
170 appendObservations(std::vector<mrpt::utils::CSerializablePtr>(1,
obj));
248 m_external_images_format = ext;
253 m_external_images_jpeg_quality =
quality;
256 return m_external_images_jpeg_quality;
265 #define SENSOR_CLASS_ID(class_name) \
266 static_cast<const mrpt::hwdrivers::TSensorClassId*>(& mrpt::hwdrivers::class_name::class##class_name)
268 #define SENSOR_IS_CLASS( ptrObj, class_name ) (ptrObj->GetRuntimeClass()==SENSOR_CLASS_ID(class_name))
273 #define DEFINE_GENERIC_SENSOR(class_name) \
275 static mrpt::hwdrivers::CGenericSensor::CLASSINIT_GENERIC_SENSOR _init_##class_name;\
277 static mrpt::hwdrivers::TSensorClassId class##class_name; \
278 virtual const mrpt::hwdrivers::TSensorClassId* GetRuntimeClass() const; \
279 static mrpt::hwdrivers::CGenericSensor* CreateObject(); \
280 static void doRegister() \
281 { CGenericSensor::registerClass( SENSOR_CLASS_ID( class_name ) ); }
285 #define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace) \
286 mrpt::hwdrivers::CGenericSensor* NameSpace::class_name::CreateObject() \
287 { return static_cast<hwdrivers::CGenericSensor*>( new NameSpace::class_name ); } \
288 mrpt::hwdrivers::TSensorClassId NameSpace::class_name::class##class_name = { \
289 #class_name, NameSpace::class_name::CreateObject }; \
290 const mrpt::hwdrivers::TSensorClassId* NameSpace::class_name::GetRuntimeClass() const \
291 { return SENSOR_CLASS_ID(class_name); }
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
void appendObservation(const mrpt::utils::CSerializablePtr &obj)
Like appendObservations() but for just one observation.
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.
std::map< std::string, const TSensorClassId * > registered_sensor_classes_t
Used in registerClass.
bool isVerboseEnabled() const
TSensorState
The current state of the sensor.
TListObservations m_objList
The queue of objects to be returned by getObservations.
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.
std::shared_ptr< const CGenericSensor > ConstPtr
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.
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::pair< mrpt::system::TTimeStamp, mrpt::utils::CSerializablePtr > TListObsPair
std::string m_external_images_format
The extension ("jpg","gif","png",...) that determines the format of images saved externally.
synch::CCriticalSection m_csObjList
The critical section for m_objList.
double getProcessRate() const
std::string getSensorLabel() const
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::CSerializablePtr > TListObservations
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
void setExternalImageFormat(const std::string &ext)
Set the extension ("jpg","gif","png",...) that determines the format of images saved externally The d...
static CGenericSensorPtr createSensorPtr(const std::string &className)
Just like createSensor, but returning a smart pointer to the newly created sensor object.
This class provides simple critical sections functionality.
This class allows loading and storing values and vectors of different types from a configuration text...
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
GLsizei GLsizei GLuint * obj
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLsizei const GLchar ** string
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)
Eigen::MatrixBase< Derived >::PlainObject operator!(const Eigen::MatrixBase< Derived > &m)
Unary inversion operator.
void BASE_IMPEXP registerClass(const mrpt::utils::TRuntimeClassId *pNewClass)
Register a class into the MRPT internal list of "CSerializable" descendents.
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
class HWDRIVERS_IMPEXP CGenericSensor
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)
virtual CGenericSensor * get()
std::shared_ptr< CGenericSensor > m_ptr
void reset(CGenericSensor *p)
virtual const CGenericSensor * get() const
void set(CGenericSensor *p)
CGenericSensorPtr(CGenericSensor *data)
virtual CGenericSensor * pointer()
virtual const CGenericSensor * pointer() const
A structure for runtime ID class type information in the context of hwdrivers::CGenericSensor.
const char * className
Class name.