RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
rtabmap::OdometryThread Class Reference

Runs an Odometry front-end in its own thread, driven by events. More...

#include <OdometryThread.h>

Inheritance diagram for rtabmap::OdometryThread:
Collaboration diagram for rtabmap::OdometryThread:

Public Member Functions

 OdometryThread (Odometry *odometry, unsigned int dataBufferMaxSize=1)
 Constructor.
 
- Public Member Functions inherited from UThread
 UThread (Priority priority=kPNormal)
 
virtual ~UThread ()
 
void start ()
 
void kill ()
 
void join (bool killFirst=false)
 
void setPriority (Priority priority)
 
void setAffinity (int cpu=0)
 
bool isCreating () const
 
bool isRunning () const
 
bool isIdle () const
 
bool isKilled () const
 
Handle getThreadHandle () const
 
unsigned long getThreadId () const
 
- Public Member Functions inherited from UThreadC< void >
int Create (Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (unsigned long &ThreadId, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
int Create (unsigned long &ThreadId, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false) const
 
- Public Member Functions inherited from UEventsHandler
void registerToEventsManager ()
 
void unregisterFromEventsManager ()
 

Protected Member Functions

virtual bool handleEvent (UEvent *event)
 Receives the events listed in the class description.
 
- Protected Member Functions inherited from UEventsHandler
 UEventsHandler ()
 
virtual ~UEventsHandler ()
 
- Protected Member Functions inherited from UEventsSender
void post (UEvent *event, bool async=true) const
 

Additional Inherited Members

- Public Types inherited from UThread
enum  Priority {
  kPLow , kPBelowNormal , kPNormal , kPAboveNormal ,
  kPRealTime
}
 
- Public Types inherited from UThreadC< void >
typedef THREAD_HANDLE Handle
 
typedef void(* Handler) ()
 
typedef THREAD_HANDLE Handle
 
typedef void(* Handler) ()
 
- Static Public Member Functions inherited from UThread
static unsigned long currentThreadId ()
 
- Static Public Member Functions inherited from UThreadC< void >
static int Create (const Handler &Function, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false)
 
static int Join (Handle H)
 
static int Kill (Handle H)
 
static int Detach (Handle H)
 
static int Create (const Handler &Function, Handle *const &H=0, const bool &CreateDetached=false, const unsigned int &StackSize=0, const bool &CancelEnable=false, const bool &CancelAsync=false)
 
static int Join (const Handle &H)
 
static int Kill (const Handle &H)
 
static int Detach (const Handle &H)
 
- Static Protected Member Functions inherited from UThreadC< void >
static void Exit ()
 
static void TestCancel ()
 
static Handle Self ()
 
static void Exit ()
 
static void TestCancel ()
 
static int Self ()
 

Detailed Description

Runs an Odometry front-end in its own thread, driven by events.

The thread owns the Odometry object and calls Odometry::process() on the frames it receives, so that a slow odometry update does not block the sensor thread. It sits in the middle of the event-based pipeline: SensorCaptureThreadOdometryThreadRtabmapThread.

Input events (handled in handleEvent(), i.e. in the caller's thread):

  • SensorEvent — a frame to process. It is rejected with an error if it carries neither a laser scan nor an image with its calibration (an OdometryMono front-end accepts RGB alone).
  • IMUEvent — an IMU sample, kept in a separate buffer.
  • OdometryResetEvent — resets the odometry to the pose it carries (identity if null) and drops everything buffered. Unlike the others, it is handled even before the thread is started.

Output event: one OdometryEvent per processed frame, carrying the data, the integrated pose and the OdometryInfo. A null pose means odometry is lost; that is what RtabmapThread reads to start a new map.

Buffering. The frame buffer holds dataBufferMaxSize frames and drops the oldest when full, so with the default size of 1 the odometry always works on the freshest frame rather than falling behind. IMU samples are buffered apart and fed to the odometry up to the stamp of the frame about to be processed, so that tightly-coupled back-ends see them in order. A frame whose stamp falls outside the buffered IMU window is skipped with a warning: with an asynchronous IMU, it must be published faster (less delay) than the camera or lidar.

When the incoming SensorEvent already carries an odometry pose (a robot publishing its own odometry), the motion between two consecutive such poses is passed to Odometry::process() as a guess.

See also
Odometry
RtabmapThread
SensorCaptureThread

Definition at line 80 of file OdometryThread.h.

Constructor & Destructor Documentation

◆ OdometryThread()

rtabmap::OdometryThread::OdometryThread ( Odometry odometry,
unsigned int  dataBufferMaxSize = 1 
)

Constructor.

Parameters
odometryThe odometry to run; must not be null. The thread takes ownership and deletes it in the destructor.
dataBufferMaxSizeMaximum number of frames waiting to be processed (0 = unlimited). Beyond that the oldest frame is dropped, keeping the odometry on recent data.

Member Function Documentation

◆ handleEvent()

virtual bool rtabmap::OdometryThread::handleEvent ( UEvent event)
protectedvirtual

Receives the events listed in the class description.

Runs in the posting thread: frames and IMU samples are only buffered here, the odometry itself runs in the thread's main loop. Data events are ignored until the thread is started, an OdometryResetEvent is not.

Returns
Always false, so the event keeps being dispatched to other handlers.

Implements UEventsHandler.


The documentation for this class was generated from the following file: