mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
mars_types.h
Go to the documentation of this file.
1 // Copyright (C) 2022 Christian Brommer, Control of Networked Systems, University of Klagenfurt, Austria.
2 //
3 // All rights reserved.
4 //
5 // This software is licensed under the terms of the BSD-2-Clause-License with
6 // no commercial use allowed, the full terms of which are made available
7 // in the LICENSE file. No license in patents is granted.
8 //
9 // You can contact the author at <christian.brommer@ieee.org>
10 
11 #ifndef MARSTYPES_H
12 #define MARSTYPES_H
13 
14 #include <Eigen/Dense>
15 
16 namespace mars
17 {
18 class Pose
19 {
20 public:
21  Eigen::Vector3d p_{ Eigen::Vector3d::Zero() };
22  Eigen::Quaterniond q_{ Eigen::Quaterniond::Identity() };
23 
24  Eigen::Vector3d n_p_{ Eigen::Vector3d::Ones() * 0.1 };
25  Eigen::Vector3d n_r_{ Eigen::Vector3d::Ones() * 0.1 };
26 
27  Pose() = default;
28  Pose(const Eigen::Vector3d& position, const Eigen::Quaterniond& orientation) : p_(position), q_(orientation)
29  {
30  }
31 
32  Pose(const Eigen::Vector3d& position, const Eigen::Matrix3d& rotation) : p_(position), q_(rotation)
33  {
34  }
35 
36  void set_meas_noise(Eigen::Vector3d n_p, Eigen::Vector3d n_r)
37  {
38  n_p_ = n_p;
39  n_r_ = n_r;
40  }
41 
42  bool operator==(const Pose& rhs) const
43  {
44  return ((p_ == rhs.p_) && ((q_.coeffs() == rhs.q_.coeffs())));
45  }
46 
47  friend std::ostream& operator<<(std::ostream& out, const Pose& data)
48  {
49  out << "p: " << data.p_[0] << ", " << data.p_[1] << ", " << data.p_[2];
50  out << " q: " << data.q_.w() << ", " << data.q_.x() << ", " << data.q_.y() << ", " << data.q_.z();
51 
52  return out;
53  }
54 
55  Eigen::Matrix<double, 6, 6> get_meas_noise_mat() const
56  {
57  Eigen::Matrix<double, 6, 1> vec;
58  vec << n_p_, n_r_;
59  return vec.asDiagonal();
60  }
61 
67  {
68  return Pose(-q_.toRotationMatrix().transpose() * p_, q_.conjugate());
69  }
70 };
71 } // namespace mars
72 
73 #endif // MARSTYPES_H
Definition: mars_types.h:19
Pose()=default
friend std::ostream & operator<<(std::ostream &out, const Pose &data)
Definition: mars_types.h:47
Eigen::Vector3d n_r_
Definition: mars_types.h:25
void set_meas_noise(Eigen::Vector3d n_p, Eigen::Vector3d n_r)
Definition: mars_types.h:36
Eigen::Vector3d p_
Definition: mars_types.h:21
Pose get_inverse_pose() const
Return inverse transformation (T_AB -> T_BA) as mars::Pose.
Definition: mars_types.h:66
Eigen::Vector3d n_p_
Definition: mars_types.h:24
Eigen::Matrix< double, 6, 6 > get_meas_noise_mat() const
Definition: mars_types.h:55
Pose(const Eigen::Vector3d &position, const Eigen::Quaterniond &orientation)
Definition: mars_types.h:28
Pose(const Eigen::Vector3d &position, const Eigen::Matrix3d &rotation)
Definition: mars_types.h:32
bool operator==(const Pose &rhs) const
Definition: mars_types.h:42
Eigen::Quaterniond q_
Definition: mars_types.h:22
Definition: buffer.h:27