|
Jafar
|
Generic implementation of hardware sensor based on ring buffer. More...
Generic implementation of hardware sensor based on ring buffer.
You need to inherit this class and start in the constructor a thread that will read the sensor, fill the ring buffer, and notify the condition variable when a new reading arrives.
TODO should be improved to be able to not fail if it overflows and that it should not be fatal but just throw away oldest data. 3 policies on overflow: fail, ignore/loop, block (for offline)
Definition at line 101 of file hardwareSensorAbstract.hpp.
#include <hardwareSensorAbstract.hpp>
Public Types | |
| typedef ublas::vector< T > | VecT |
|
typedef ublas::vector_indirect < VecT > | VecIndT |
Public Member Functions | |
| HardwareSensorAbstract (kernel::VariableCondition< int > *condition, Mode mode, unsigned bufferSize) | |
| Constructor. | |
| virtual void | start ()=0 |
| start the acquisition thread, once the object is configured | |
| virtual void | stop ()=0 |
| stop the acquisition thread | |
| virtual bool | join (int timed_ms=-1)=0 |
| wait that the acquisition thread has finished | |
| bool | stopped () |
| bool | initialized () |
| void | setSyncConfig (double timestamps_correction=0.0) |
| virtual void | getTimingInfos (double &data_period, double &arrival_delay, bool locked=false) |
| Provides approximate informations about the timings of data. | |
| virtual void | setTimingInfos (double data_period, double arrival_delay) |
| virtual double | getLastTimestamp ()=0 |
| virtual void | showInfos () |
| virtual VecIndT | getRaws (double t1, double t2, bool release=true) |
| will also release the raws before the first one if release is true | |
| virtual int | getUnreadRawInfos (RawInfos &infos) |
| get timing informations about unread raws | |
| virtual int | getNextRawInfo (RawInfo &info) |
| get info about next unread raw | |
| virtual void | getRaw (unsigned id, T &raw) |
| will also release the raws before this one | |
| virtual void | observeRaw (unsigned id, T &raw) |
| get raw but doesn't release raws before | |
| virtual double | getRawTimestamp (unsigned id) |
| virtual int | getLastUnreadRaw (T &raw) |
| will also release the raws before this one | |
| virtual void | getLastProcessedRaw (T &raw) |
| for information only (display...) | |
| virtual void | release () |
| virtual void | enable (bool enabled=true) |
| void | stopDumping () |
Protected Member Functions | |
| int | getWritePos (bool locked=false) |
| the ring buffer | |
| void | incWritePos (bool locked=false) |
| int | getFirstUnreadPos () |
| int | getLastUnreadPos (bool locked=false) |
| void | releaseUntil (unsigned id, bool locked=false) |
| release until id, excluding id | |
| void | release (unsigned id, bool locked=false) |
| release until id, including id | |
| bool | isFull (bool locked=false) |
| bool | isEmpty (bool locked=false) |
| void | update_arrival_delay (double delay) |
Protected Attributes | |
| kernel::VariableCondition< int > * | condition |
| current read_pos is being used | |
| kernel::VariableCondition< int > | index |
| to notify when new data is available | |
| boost::mutex | mutex_data |
| index of used data | |
| boost::condition_variable | cond_offline_full |
| mutex for using this object | |
| boost::condition_variable | cond_offline_freed |
| int | data_count |
| int | last_sent_pos |
| image count since last image read | |
| bool | no_more_data |
| position of the last raw sent | |
| double | timestamps_correction |
| double | data_period |
| double | arrival_delays [narrival_delays] |
| int | iarrival_delay |
| double | arrival_delay |
| bool | started |
| bool | stopping |
| has the start() command been already run ? | |
| bool | enabled |
| bool | initialized_ |
| whether the sensor is enabled or not | |
| Mode | mode |
| whether the sensor is correctly initialized and working correctly | |
| int | bufferSize |
| VecT | buffer |
| size of the ring buffer | |
Private Attributes | |
| int | write_pos |
| int | read_pos |
| next position where to write, oldest available reading | |
| bool | buffer_full |
| oldest position not released (being read or not read at all) | |
| bool | read_pos_used |
| when read_pos = write_pos, tells whether the buffer is full or empty | |
Friends | |
| class | rtslam::SensorProprioAbstract |
| class | rtslam::SensorExteroAbstract |
| jafar::rtslam::hardware::HardwareSensorAbstract< T >::HardwareSensorAbstract | ( | kernel::VariableCondition< int > * | condition, |
| Mode | mode, | ||
| unsigned | bufferSize | ||
| ) | [inline] |
Constructor.
| condition | to notify when new data is available |
Definition at line 209 of file hardwareSensorAbstract.hpp.
| int jafar::rtslam::hardware::HardwareSensorAbstract< T >::getFirstUnreadPos | ( | ) | [inline, protected] |
Definition at line 154 of file hardwareSensorAbstract.hpp.
Referenced by jafar::rtslam::hardware::HardwareSensorAbstract< RawVec >::releaseUntil().
| int jafar::rtslam::hardware::HardwareSensorAbstract< T >::getLastUnreadPos | ( | bool | locked = false | ) | [inline, protected] |
Definition at line 160 of file hardwareSensorAbstract.hpp.
| virtual void jafar::rtslam::hardware::HardwareSensorAbstract< T >::getTimingInfos | ( | double & | data_period, |
| double & | arrival_delay, | ||
| bool | locked = false |
||
| ) | [inline, virtual] |
Provides approximate informations about the timings of data.
| data_period | the period at which the data are arriving |
| arrival_delay | the delay between the moment we get a data and its real date. This is a starting point that must be overestimated, it may be estimated more precisely afterwards. |
Definition at line 230 of file hardwareSensorAbstract.hpp.
bool jafar::rtslam::hardware::HardwareSensorAbstract< T >::stopping [protected] |
has the start() command been already run ?
the stop() command has been run, we should stop reading data No need to protect it with a mutex for two reasons: 1. assigning and reading a boolean is an indivisible operation 2. boolean have only two possible values, so even if read/write clash was possible it wouldn't hurt
Definition at line 134 of file hardwareSensorAbstract.hpp.
| Generated on Wed Oct 15 2014 00:37:46 for Jafar by doxygen 1.7.6.1 |
|