Camera.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include "rtabmap/core/Camera.h"
29 #include "rtabmap/core/IMUFilter.h"
30 
31 #include <rtabmap/utilite/UStl.h>
32 #include <rtabmap/utilite/UFile.h>
35 
36 namespace rtabmap
37 {
38 
39 Camera::Camera(float imageRate, const Transform & localTransform) :
40  SensorCapture(imageRate, localTransform*CameraModel::opticalRotation()),
41  imuFilter_(0),
42  publishInterIMU_(false)
43 {}
44 
46 {
47  delete imuFilter_;
48 }
49 
50 bool Camera::initFromFile(const std::string & calibrationPath)
51 {
52  return init(UDirectory::getDir(calibrationPath), uSplit(UFile::getName(calibrationPath), '.').front());
53 }
54 
55 void Camera::setInterIMUPublishing(bool enabled, IMUFilter * filter)
56 {
57  publishInterIMU_ = enabled;
58  delete imuFilter_;
59  imuFilter_ = filter;
60 }
61 
62 void Camera::postInterIMU(const IMU & imu, double stamp)
63 {
64  if(imuFilter_)
65  {
67  imu.angularVelocity()[0], imu.angularVelocity()[1], imu.angularVelocity()[2],
68  imu.linearAcceleration()[0], imu.linearAcceleration()[1], imu.linearAcceleration()[2],
69  stamp);
70  cv::Vec4d q;
71  imuFilter_->getOrientation(q[0],q[1],q[2],q[3]);
73  q, cv::Mat(),
76  imu.localTransform()),
77  stamp));
78  return;
79  }
80  UEventsManager::post(new IMUEvent(imu, stamp));
81 }
82 
83 } // namespace rtabmap
UFile::getName
std::string getName()
Definition: UFile.h:135
rtabmap::IMU::linearAcceleration
const cv::Vec3d linearAcceleration() const
Definition: IMU.h:59
UDirectory.h
rtabmap::CameraModel
Definition: CameraModel.h:38
rtabmap::IMUEvent
Definition: IMU.h:85
rtabmap::IMU::angularVelocityCovariance
const cv::Mat & angularVelocityCovariance() const
Definition: IMU.h:57
rtabmap::IMU::localTransform
const Transform & localTransform() const
Definition: IMU.h:62
rtabmap::IMUFilter::update
void update(double gx, double gy, double gz, double ax, double ay, double az, double stamp)
Definition: IMUFilter.cpp:72
rtabmap::IMUFilter::getOrientation
virtual void getOrientation(double &qx, double &qy, double &qz, double &qw) const =0
rtabmap::IMU::linearAccelerationCovariance
const cv::Mat & linearAccelerationCovariance() const
Definition: IMU.h:60
rtabmap::Camera::setInterIMUPublishing
void setInterIMUPublishing(bool enabled, IMUFilter *filter=0)
Definition: Camera.cpp:55
rtabmap::SensorCapture::init
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")=0
rtabmap::IMU
Definition: IMU.h:19
rtabmap::IMUFilter
Definition: IMUFilter.h:37
UDirectory::getDir
static std::string getDir(const std::string &filePath)
Definition: UDirectory.cpp:273
q
EIGEN_DEVICE_FUNC const Scalar & q
rtabmap::Camera::postInterIMU
void postInterIMU(const IMU &imu, double stamp)
Definition: Camera.cpp:62
rtabmap::SensorCapture
Definition: SensorCapture.h:49
rtabmap::Transform
Definition: Transform.h:41
uSplit
std::list< std::string > uSplit(const std::string &str, char separator=' ')
Definition: UStl.h:564
IMUFilter.h
rtabmap::Camera::publishInterIMU_
bool publishInterIMU_
Definition: Camera.h:75
UStl.h
Wrappers of STL for convenient functions.
UEventsManager::post
static void post(UEvent *event, bool async=true, const UEventsSender *sender=0)
Definition: UEventsManager.cpp:54
Camera.h
rtabmap::IMU::angularVelocity
const cv::Vec3d & angularVelocity() const
Definition: IMU.h:56
false
#define false
Definition: ConvertUTF.c:56
rtabmap::Camera::initFromFile
bool initFromFile(const std::string &calibrationPath)
Definition: Camera.cpp:50
UFile.h
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::Camera::~Camera
virtual ~Camera()
Definition: Camera.cpp:45
UEventsManager.h
rtabmap::Camera::imuFilter_
IMUFilter * imuFilter_
Definition: Camera.h:74
rtabmap::Camera::Camera
Camera(float imageRate=0, const Transform &localTransform=Transform::getIdentity())
Definition: Camera.cpp:39


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:06