Choreonoid  1.8
PositionTag.h
Go to the documentation of this file.
1 #ifndef CNOID_POSITION_TAG_H
2 #define CNOID_POSITION_TAG_H
3 
4 #include "Referenced.h"
5 #include "EigenTypes.h"
6 #include "exportdecl.h"
7 
8 namespace cnoid {
9 
10 class Mapping;
11 
12 class CNOID_EXPORT PositionTag : public Referenced
13 {
14 public:
15  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
16 
17  PositionTag();
18  PositionTag(const Isometry3& T);
19  PositionTag(const Vector3& location);
20  PositionTag(const PositionTag& org);
21 
22  PositionTag& operator=(const PositionTag& rhs);
23 
24  Isometry3::ConstTranslationPart translation() const {
25  return position_.translation();
26  }
27  template<typename Derived>
28  void setTranslation(const Eigen::MatrixBase<Derived>& p) {
29  position_.translation() = p.template cast<Isometry3::Scalar>();
30  }
31 
32  bool hasAttitude() const { return hasAttitude_; }
33 
34  void clearAttitude() {
35  position_.linear().setIdentity();
36  hasAttitude_ = false;
37  }
38 
39  const Isometry3& position() const { return position_; }
40 
41  template<class Scalar, int Mode, int Options>
42  void setPosition(const Eigen::Transform<Scalar, 3, Mode, Options>& p) {
43  position_ = p.template cast<Isometry3::Scalar>();
44  hasAttitude_ = true;
45  }
46 
47  Isometry3::ConstLinearPart rotation() const { return position_.linear(); }
48 
49  template<typename Derived>
50  void setRotation(const Eigen::MatrixBase<Derived>& R) {
51  position_.linear() = R.template cast<Isometry3::Scalar>();
52  hasAttitude_ = true;
53  }
54 
55  bool read(const Mapping* archive);
56  bool write(Mapping* archive) const;
57 
58 private:
59  Isometry3 position_;
60  bool hasAttitude_;
61 };
62 
64 
65 }
66 
67 #endif
cnoid::PositionTag::clearAttitude
void clearAttitude()
Definition: PositionTag.h:34
Referenced.h
cnoid::Mapping
Definition: ValueTree.h:253
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::write
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
cnoid::PositionTag
Definition: PositionTag.h:12
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::PositionTag::translation
Isometry3::ConstTranslationPart translation() const
Definition: PositionTag.h:24
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
cnoid::PositionTag::position
const Isometry3 & position() const
Definition: PositionTag.h:39
cnoid::PositionTag::hasAttitude
bool hasAttitude() const
Definition: PositionTag.h:32
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::PositionTag::rotation
Isometry3::ConstLinearPart rotation() const
Definition: PositionTag.h:47
cnoid::Referenced
Definition: Referenced.h:54
EigenTypes.h
cnoid::PositionTag::setRotation
void setRotation(const Eigen::MatrixBase< Derived > &R)
Definition: PositionTag.h:50
cnoid::PositionTag::setPosition
void setPosition(const Eigen::Transform< Scalar, 3, Mode, Options > &p)
Definition: PositionTag.h:42
cnoid::PositionTag::setTranslation
void setTranslation(const Eigen::MatrixBase< Derived > &p)
Definition: PositionTag.h:28
cnoid::PositionTagPtr
ref_ptr< PositionTag > PositionTagPtr
Definition: PositionTag.h:63