BodySensor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rbdyn/Device.h>
8 #include <mc_rtc/deprecated.h>
9 
10 #include <Eigen/StdVector>
11 
12 namespace mc_rbdyn
13 {
14 
20 {
21  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23  inline BodySensor() : BodySensor("", "", sva::PTransformd::Identity()) {}
24 
34  inline BodySensor(const std::string & name, const std::string & bodyName, const sva::PTransformd & X_b_s)
35  : Device(name, bodyName, X_b_s)
36  {
37  type_ = "BodySensor";
38  }
39 
40  BodySensor(const BodySensor & bs) : BodySensor(bs.name(), bs.parent(), bs.X_b_s())
41  {
42  position_ = bs.position_;
43  orientation_ = bs.orientation_;
44  linear_velocity_ = bs.linear_velocity_;
45  angular_velocity_ = bs.angular_velocity_;
46  linear_acceleration_ = bs.linear_acceleration_;
47  angular_acceleration_ = bs.angular_acceleration_;
48  }
49 
51  {
52  name_ = bs.name_;
53  parent_ = bs.parent_;
54  X_p_s_ = bs.X_p_s_;
55  position_ = bs.position_;
56  orientation_ = bs.orientation_;
57  linear_velocity_ = bs.linear_velocity_;
58  angular_velocity_ = bs.angular_velocity_;
59  linear_acceleration_ = bs.linear_acceleration_;
60  angular_acceleration_ = bs.angular_acceleration_;
61  return *this;
62  }
63 
64  BodySensor(BodySensor &&) = default;
65  BodySensor & operator=(BodySensor &&) = default;
66 
67  ~BodySensor() noexcept override;
68 
70  inline const std::string & parentBody() const { return Device::parent(); }
71 
73  inline const sva::PTransformd & X_b_s() const { return Device::X_p_s(); }
74 
76  inline const Eigen::Vector3d & position() const { return position_; }
77 
79  inline void position(const Eigen::Vector3d & position) { position_ = position; }
80 
82  inline const Eigen::Quaterniond & orientation() const { return orientation_; }
83 
90  inline void orientation(const Eigen::Quaterniond & orientation) { orientation_ = orientation; }
91 
93  inline const Eigen::Vector3d & linearVelocity() const { return linear_velocity_; }
94 
96  inline void linearVelocity(const Eigen::Vector3d & linear_velocity) { linear_velocity_ = linear_velocity; }
97 
99  inline const Eigen::Vector3d & angularVelocity() const { return angular_velocity_; }
100 
102  inline void angularVelocity(const Eigen::Vector3d & angular_velocity) { angular_velocity_ = angular_velocity; }
103 
108  MC_RTC_DEPRECATED inline const Eigen::Vector3d & acceleration() const { return linearAcceleration(); }
109 
114  MC_RTC_DEPRECATED inline void acceleration(const Eigen::Vector3d & acceleration) { linearAcceleration(acceleration); }
115 
117  inline const Eigen::Vector3d & linearAcceleration() const { return linear_acceleration_; }
118 
120  inline void linearAcceleration(const Eigen::Vector3d & linear_acceleration)
121  {
122  linear_acceleration_ = linear_acceleration;
123  }
124 
126  inline const Eigen::Vector3d & angularAcceleration() const { return angular_acceleration_; }
127 
129  inline void angularAcceleration(const Eigen::Vector3d & angular_acceleration)
130  {
131  angular_acceleration_ = angular_acceleration;
132  }
133 
134  DevicePtr clone() const override;
135 
136 private:
137  Eigen::Vector3d position_ = Eigen::Vector3d::Zero();
138  Eigen::Quaterniond orientation_ = Eigen::Quaterniond::Identity();
139  Eigen::Vector3d linear_velocity_ = Eigen::Vector3d::Zero();
140  Eigen::Vector3d angular_velocity_ = Eigen::Vector3d::Zero();
141  Eigen::Vector3d linear_acceleration_ = Eigen::Vector3d::Zero();
142  Eigen::Vector3d angular_acceleration_ = Eigen::Vector3d::Zero();
143 };
144 
145 typedef std::vector<BodySensor, Eigen::aligned_allocator<BodySensor>> BodySensorVector;
146 
147 inline bool operator==(const mc_rbdyn::BodySensor & lhs, const mc_rbdyn::BodySensor & rhs)
148 {
149  return lhs.name() == rhs.name() && lhs.parentBody() == rhs.parentBody() && lhs.X_b_s() == rhs.X_b_s();
150 }
151 
152 } // namespace mc_rbdyn
mc_rbdyn::BodySensor::angularVelocity
void angularVelocity(const Eigen::Vector3d &angular_velocity)
Definition: BodySensor.h:102
Device.h
mc_rbdyn::BodySensor::angularAcceleration
const Eigen::Vector3d & angularAcceleration() const
Definition: BodySensor.h:126
mc_rbdyn::BodySensor::angularVelocity
const Eigen::Vector3d & angularVelocity() const
Definition: BodySensor.h:99
mc_rbdyn::BodySensor::acceleration
MC_RTC_DEPRECATED void acceleration(const Eigen::Vector3d &acceleration)
Definition: BodySensor.h:114
mc_rbdyn::BodySensor::parentBody
const std::string & parentBody() const
Definition: BodySensor.h:70
mc_rbdyn::BodySensor::BodySensor
BodySensor(const BodySensor &bs)
Definition: BodySensor.h:40
mc_rbdyn::BodySensor::linearVelocity
const Eigen::Vector3d & linearVelocity() const
Definition: BodySensor.h:93
mc_rbdyn::BodySensor::position
const Eigen::Vector3d & position() const
Definition: BodySensor.h:76
mc_rbdyn::BodySensor::orientation
void orientation(const Eigen::Quaterniond &orientation)
Definition: BodySensor.h:90
mc_rbdyn::Device::parent_
std::string parent_
Definition: Device.h:87
mc_rbdyn::Device
Definition: Device.h:29
mc_rbdyn::Device::X_p_s
const sva::PTransformd & X_p_s() const
Definition: Device.h:64
mc_rbdyn::BodySensor::linearAcceleration
void linearAcceleration(const Eigen::Vector3d &linear_acceleration)
Definition: BodySensor.h:120
mc_rbdyn::Device::name_
std::string name_
Definition: Device.h:85
mc_rbdyn::BodySensor::X_b_s
const sva::PTransformd & X_b_s() const
Definition: BodySensor.h:73
mc_rbdyn::BodySensor::acceleration
const MC_RTC_DEPRECATED Eigen::Vector3d & acceleration() const
Definition: BodySensor.h:108
mc_rbdyn::Device::name
const std::string & name() const
Definition: Device.h:49
mc_rbdyn::BodySensor
Definition: BodySensor.h:19
mc_rbdyn::BodySensor::BodySensor
BodySensor(const std::string &name, const std::string &bodyName, const sva::PTransformd &X_b_s)
Definition: BodySensor.h:34
MC_RBDYN_DLLAPI
#define MC_RBDYN_DLLAPI
Definition: api.h:50
mc_rbdyn::operator==
bool operator==(const mc_rbdyn::BodySensor &lhs, const mc_rbdyn::BodySensor &rhs)
Definition: BodySensor.h:147
mc_rbdyn::BodySensor::angularAcceleration
void angularAcceleration(const Eigen::Vector3d &angular_acceleration)
Definition: BodySensor.h:129
deprecated.h
mc_rbdyn::Device::parent
const std::string & parent() const
Definition: Device.h:55
std
Definition: Contact.h:66
mc_rbdyn::BodySensorVector
std::vector< BodySensor, Eigen::aligned_allocator< BodySensor > > BodySensorVector
Definition: BodySensor.h:145
mc_rbdyn::DevicePtr
std::unique_ptr< Device > DevicePtr
Definition: Device.h:20
mc_rbdyn::BodySensor::BodySensor
EIGEN_MAKE_ALIGNED_OPERATOR_NEW BodySensor()
Definition: BodySensor.h:23
mc_rbdyn::BodySensor::operator=
BodySensor & operator=(const BodySensor &bs)
Definition: BodySensor.h:50
mc_rbdyn::BodySensor::orientation
const Eigen::Quaterniond & orientation() const
Definition: BodySensor.h:82
mc_rbdyn::BodySensor::position
void position(const Eigen::Vector3d &position)
Definition: BodySensor.h:79
mc_rbdyn
Definition: generic_gripper.h:14
mc_rbdyn::BodySensor::linearAcceleration
const Eigen::Vector3d & linearAcceleration() const
Definition: BodySensor.h:117
mc_rbdyn::Device::X_p_s_
sva::PTransformd X_p_s_
Definition: Device.h:89
mc_rbdyn::BodySensor::linearVelocity
void linearVelocity(const Eigen::Vector3d &linear_velocity)
Definition: BodySensor.h:96