41 #ifndef INCLUDE_OKVIS_THREADEDKFVIO_HPP_
42 #define INCLUDE_OKVIS_THREADEDKFVIO_HPP_
46 #include <condition_variable>
63 #include <../test/MockVioFrontendInterface.hpp>
64 #include <../test/MockVioBackendInterface.hpp>
91 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
94 #ifdef DEACTIVATE_TIMERS
131 const cv::Mat & image,
132 const std::vector<cv::KeyPoint> * keypoints = 0,
133 bool* asKeyframe = 0);
147 const std::vector<cv::KeyPoint> & keypoints,
148 const std::vector<uint64_t> & landmarkIds,
149 const cv::Mat& descriptors = cv::Mat(),
150 bool* asKeyframe = 0);
160 const Eigen::Vector3d & alpha,
161 const Eigen::Vector3d & omega);
172 const okvis::Time & stamp,
const Eigen::Vector3d & position,
173 const Eigen::Vector3d & positionOffset,
174 const Eigen::Matrix3d & positionCovariance);
187 double lat_wgs84_deg,
double lon_wgs84_deg,
188 double alt_wgs84_deg,
189 const Eigen::Vector3d & positionOffset,
190 const Eigen::Matrix3d & positionCovarianceENU);
200 const okvis::Time & stamp,
const Eigen::Vector3d & fluxDensityMeas,
211 double staticPressure,
double stdev);
221 double differentialPressure,
295 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
316 std::shared_ptr<okvis::MapPointVector>
map_;
347 std::vector<std::shared_ptr<
Eigen::Matrix< double, 3, 1 > omega_S
Definition: ThreadedKFVio.hpp:299
std::mutex lastState_mutex_
Lock when accessing any of the 'lastOptimized*' variables.
Definition: ThreadedKFVio.hpp:388
okvis::kinematics::Transformation T_WS_propagated_
The pose propagated by the IMU measurements.
Definition: ThreadedKFVio.hpp:315
The estimator class.
Definition: Estimator.hpp:77
Header file for the NCameraSystem class.
Definition: MockVioFrontendInterface.hpp:43
virtual bool addImuMeasurement(const okvis::Time &stamp, const Eigen::Vector3d &alpha, const Eigen::Vector3d &omega)
Add an IMU measurement.
Definition: ThreadedKFVio.cpp:244
okvis::threadsafe::ThreadSafeQueue< std::vector< cv::Mat > > displayImages_
The queue containing the actual display images.
Definition: ThreadedKFVio.hpp:374
std::deque< PositionMeasurement, Eigen::aligned_allocator< PositionMeasurement > > PositionMeasurementDeque
Definition: Measurements.hpp:188
This class is to safely notify different threads whether IMU measurements up to a timestamp (e...
Definition: ImuFrameSynchronizer.hpp:59
std::thread visualizationThread_
Thread running visualizationLoop().
Definition: ThreadedKFVio.hpp:408
int deleteImuMeasurements(const okvis::Time &eraseUntil)
Remove IMU measurements from the internal buffer.
Definition: ThreadedKFVio.cpp:700
ImuFrameSynchronizer imuFrameSynchronizer_
Definition: ThreadedKFVio.hpp:334
std::shared_ptr< okvis::MapPointVector > map_
The map. Unused.
Definition: ThreadedKFVio.hpp:316
okvis::Estimator estimator_
The backend estimator.
Definition: ThreadedKFVio.hpp:420
const size_t maxImuInputQueueSize_
Definition: ThreadedKFVio.hpp:434
void visualizationLoop()
Loop that visualizes completed frames.
Definition: ThreadedKFVio.cpp:631
std::deque< ImuMeasurement, Eigen::aligned_allocator< ImuMeasurement > > ImuMeasurementDeque
Definition: Measurements.hpp:163
void differentialConsumerLoop()
Loop to process differential pressure measurements.
Definition: ThreadedKFVio.cpp:627
virtual void addGpsMeasurement(const okvis::Time &stamp, double lat_wgs84_deg, double lon_wgs84_deg, double alt_wgs84_deg, const Eigen::Vector3d &positionOffset, const Eigen::Matrix3d &positionCovarianceENU)
Add a GPS measurement.
Definition: ThreadedKFVio.cpp:285
okvis::SpeedAndBias speedAndBiases
The speeds and biases.
Definition: ThreadedKFVio.hpp:298
okvis::SpeedAndBias lastOptimizedSpeedAndBiases_
Resulting speeds and IMU biases after last optimization.
Definition: ThreadedKFVio.hpp:324
std::thread magnetometerConsumerThread_
Thread running magnetometerConsumerLoop().
Definition: ThreadedKFVio.hpp:401
ThreadedKFVio(okvis::VioParameters ¶meters)
Constructor.
Definition: ThreadedKFVio.cpp:73
A frontend using BRISK features.
Definition: Frontend.hpp:57
Header file for the MultiFrame class.
void imuConsumerLoop()
Loop to process IMU measurements.
Definition: ThreadedKFVio.cpp:542
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef okvis::timing::Timer TimerSwitchable
Definition: ThreadedKFVio.hpp:97
okvis::Time lastOptimizedStateTimestamp_
Timestamp of newest frame used in the last optimization.
Definition: ThreadedKFVio.hpp:327
std::atomic_bool repropagationNeeded_
Definition: ThreadedKFVio.hpp:330
Header file for the VioVisualizer class.
Eigen::Matrix< double, 9, 1 > SpeedAndBias
Definition: FrameTypedefs.hpp:234
Definition: Timer.hpp:104
size_t numCameraPairs_
Number of camera pairs in the system.
Definition: ThreadedKFVio.hpp:427
void frameConsumerLoop(size_t cameraIndex)
Loop to process frames from camera with index cameraIndex.
Definition: ThreadedKFVio.cpp:322
Definition: MockVioBackendInterface.hpp:44
This file contains the templated measurement structs, structs encapsulating Sensor data and related t...
size_t numCameras_
Number of cameras in the system.
Definition: ThreadedKFVio.hpp:426
const size_t maxPositionInputQueueSize_
Max position measurements before dropping.
Definition: ThreadedKFVio.hpp:437
std::condition_variable optimizationNotification_
Definition: ThreadedKFVio.hpp:385
virtual ~ThreadedKFVio()
Destructor. This calls Shutdown() for all threadsafe queues and joins all threads.
Definition: ThreadedKFVio.cpp:152
okvis::MapPointVector transferredLandmarks
Vector of the landmarks that have been marginalized out.
Definition: ThreadedKFVio.hpp:304
std::vector< MapPoint, Eigen::aligned_allocator< MapPoint > > MapPointVector
Definition: FrameTypedefs.hpp:172
virtual void setBlocking(bool blocking)
Set the blocking variable that indicates whether the addMeasurement() functions should return immedia...
Definition: ThreadedKFVio.cpp:312
Header file for the ImuFrameSynchronizer class.
okvis::threadsafe::ThreadSafeQueue< okvis::PositionMeasurement > positionMeasurementsReceived_
Position measurement input queue.
Definition: ThreadedKFVio.hpp:353
std::mutex frameSynchronizer_mutex_
Lock when accessing the frameSynchronizer_.
Definition: ThreadedKFVio.hpp:382
okvis::PositionMeasurementDeque positionMeasurements_
The Position measurements.
Definition: ThreadedKFVio.hpp:368
okvis::FrameSynchronizer frameSynchronizer_
The frame synchronizer responsible for merging frames into multiframes.
Definition: ThreadedKFVio.hpp:337
okvis::ImuMeasurementDeque imuMeasurements_
The IMU measurements.
Definition: ThreadedKFVio.hpp:365
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
bool onlyPublishLandmarks
Boolean to signalise the publisherLoop() that only the landmarks should be published.
Definition: ThreadedKFVio.hpp:305
This file contains some useful assert macros.
This struct contains the results of the optimization for ease of publication. It is also used for pub...
Definition: ThreadedKFVio.hpp:294
void display()
Trigger display (needed because OSX won't allow threaded display).
Definition: ThreadedKFVio.cpp:647
std::mutex positionMeasurements_mutex_
Lock when accessing imuMeasurements_.
Definition: ThreadedKFVio.hpp:381
virtual bool addKeypoints(const okvis::Time &stamp, size_t cameraIndex, const std::vector< cv::KeyPoint > &keypoints, const std::vector< uint64_t > &landmarkIds, const cv::Mat &descriptors=cv::Mat(), bool *asKeyframe=0)
Add an abstracted image observation.
Definition: ThreadedKFVio.cpp:231
void matchingLoop()
Loop that matches frames with existing frames.
Definition: ThreadedKFVio.cpp:456
void publisherLoop()
Loop that publishes the newest state and landmarks.
Definition: ThreadedKFVio.cpp:857
okvis::MapPointVector landmarksVector
Vector containing the current landmarks.
Definition: ThreadedKFVio.hpp:303
Struct to combine all parameters and settings.
Definition: Parameters.hpp:280
Header file for the ThreadsafeQueue class.
virtual void addDifferentialPressureMeasurement(const okvis::Time &stamp, double differentialPressure, double stdev)
Add a differential pressure measurement.
Definition: ThreadedKFVio.cpp:304
std::thread gpsConsumerThread_
Thread running gpsConsumerLoop().
Definition: ThreadedKFVio.hpp:400
Class that implements a threadsafe FIFO queue.
Definition: ThreadsafeQueue.hpp:74
okvis::Time lastAddedImageTimestamp_
Timestamp of the newest image added to the image input queue.
Definition: ThreadedKFVio.hpp:340
void init()
Initialises settings and calls startThreads().
Definition: ThreadedKFVio.cpp:92
virtual void addPositionMeasurement(const okvis::Time &stamp, const Eigen::Vector3d &position, const Eigen::Vector3d &positionOffset, const Eigen::Matrix3d &positionCovariance)
Add a position measurement.
Definition: ThreadedKFVio.cpp:264
std::vector< std::thread > matchesConsumerThreads_
Unused.
Definition: ThreadedKFVio.hpp:397
std::vector< std::shared_ptr< okvis::threadsafe::ThreadSafeQueue< std::shared_ptr< okvis::CameraMeasurement > > > > cameraMeasurementsReceived_
Camera measurement input queues. For each camera in the configuration one.
Definition: ThreadedKFVio.hpp:348
std::thread imuConsumerThread_
Thread running imuConsumerLoop().
Definition: ThreadedKFVio.hpp:398
EIGEN_MAKE_ALIGNED_OPERATOR_NEW okvis::Time stamp
Timestamp of the optimized/propagated pose.
Definition: ThreadedKFVio.hpp:296
virtual void startThreads()
Start all threads.
Definition: ThreadedKFVio.cpp:127
void gpsConsumerLoop()
Loop to process GPS measurements.
Definition: ThreadedKFVio.cpp:619
okvis::threadsafe::ThreadSafeQueue< okvis::ImuMeasurement > imuMeasurementsReceived_
IMU measurement input queue.
Definition: ThreadedKFVio.hpp:350
virtual void addBarometerMeasurement(const okvis::Time &stamp, double staticPressure, double stdev)
Add a static pressure measurement.
Definition: ThreadedKFVio.cpp:298
std::thread publisherThread_
Thread running publisherLoop().
Definition: ThreadedKFVio.hpp:410
virtual void addMagnetometerMeasurement(const okvis::Time &stamp, const Eigen::Vector3d &fluxDensityMeas, double stdev)
Add a magnetometer measurement.
Definition: ThreadedKFVio.cpp:292
okvis::ImuMeasurementDeque getImuMeasurments(okvis::Time &start, okvis::Time &end)
Get a subset of the recorded IMU measurements.
Definition: ThreadedKFVio.cpp:663
okvis::threadsafe::ThreadSafeQueue< std::shared_ptr< okvis::MultiFrame > > keypointMeasurements_
The queue containing multiframes with completely detected frames.
Definition: ThreadedKFVio.hpp:360
okvis::kinematics::Transformation lastOptimized_T_WS_
Resulting pose of the last optimization.
Definition: ThreadedKFVio.hpp:321
An abstract base class for interfaces between Front- and Backend.
Definition: VioInterface.hpp:66
Header file for the FrameSynchronizer class.
Header file for the Estimator class. This does all the backend work.
IMU parameters.
Definition: Parameters.hpp:105
This class combines multiple frames with the same or similar timestamp into one multiframe.
Definition: FrameSynchronizer.hpp:60
Header file for the Frontend class.
std::vector< std::thread > frameConsumerThreads_
Threads running the frameConsumerLoop(). One per camera.
Definition: ThreadedKFVio.hpp:395
std::thread differentialConsumerThread_
Thread running differentialConsumerLoop().
Definition: ThreadedKFVio.hpp:402
std::vector< std::thread > keypointConsumerThreads_
Threads running matchingLoop().
Definition: ThreadedKFVio.hpp:396
okvis::threadsafe::ThreadSafeQueue< std::shared_ptr< okvis::MultiFrame > > matchedFrames_
The queue containing multiframes with completely matched frames. These are already part of the estima...
Definition: ThreadedKFVio.hpp:362
Time representation. May either represent wall clock time or ROS clock time.
Definition: Time.hpp:187
void optimizationLoop()
Loop that performs the optimization and marginalisation.
Definition: ThreadedKFVio.cpp:720
virtual bool addImage(const okvis::Time &stamp, size_t cameraIndex, const cv::Mat &image, const std::vector< cv::KeyPoint > *keypoints=0, bool *asKeyframe=0)
Add a new image.
Definition: ThreadedKFVio.cpp:192
This file contains struct definitions that encapsulate parameters and settings.
Header file for the VioFrontendInterface class.
std::atomic_bool optimizationDone_
Boolean flag for whether optimization is done for the last state that has been added to the estimator...
Definition: ThreadedKFVio.hpp:387
This class manages the complete data flow in and out of the algorithm, as well as between the process...
Definition: ThreadedKFVio.hpp:88
std::vector< okvis::kinematics::Transformation, Eigen::aligned_allocator< okvis::kinematics::Transformation > > vector_of_T_SCi
The relative transformation of the cameras to the sensor (IMU) frame.
Definition: ThreadedKFVio.hpp:302
okvis::SpeedAndBias speedAndBiases_propagated_
Definition: ThreadedKFVio.hpp:311
std::thread positionConsumerThread_
Thread running positionConsumerLoop().
Definition: ThreadedKFVio.hpp:399
okvis::Frontend frontend_
The frontend.
Definition: ThreadedKFVio.hpp:421
okvis::threadsafe::ThreadSafeQueue< OptimizationResults > optimizationResults_
The queue containing the results of the optimization or IMU propagation ready for publishing...
Definition: ThreadedKFVio.hpp:370
okvis::kinematics::Transformation T_WS
The pose.
Definition: ThreadedKFVio.hpp:297
okvis::ImuParameters imu_params_
The IMU parameters.
Definition: ThreadedKFVio.hpp:314
void positionConsumerLoop()
Loop to process position measurements.
Definition: ThreadedKFVio.cpp:604
std::thread optimizationThread_
Thread running optimizationLoop().
Definition: ThreadedKFVio.hpp:409
okvis::threadsafe::ThreadSafeQueue< VioVisualizer::VisualizationData::Ptr > visualizationData_
The queue containing visualization data that is ready to be displayed.
Definition: ThreadedKFVio.hpp:372
okvis::VioParameters parameters_
The parameters and settings.
Definition: ThreadedKFVio.hpp:429
std::mutex imuMeasurements_mutex_
Lock when accessing imuMeasurements_.
Definition: ThreadedKFVio.hpp:380
okvis::Time lastAddedStateTimestamp_
Timestamp of the newest state in the Estimator.
Definition: ThreadedKFVio.hpp:339
void magnetometerConsumerLoop()
Loop to process magnetometer measurements.
Definition: ThreadedKFVio.cpp:623
std::mutex estimator_mutex_
Condition variable to signalise that optimization is done.
Definition: ThreadedKFVio.hpp:383