Kindr
Kinematics and Dynamics for Robotics
PoseBase.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Christian Gehring, Hannes Sommer, Paul Furgale, Remo Diethelm
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 Autonomous Systems Lab, ETH Zurich 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 Christian Gehring, Hannes Sommer, Paul Furgale,
20  * Remo Diethelm BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (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 
29 #pragma once
30 
31 
32 #include "kindr/common/common.hpp"
33 
34 
35 namespace kindr {
37 
40 namespace internal {
41 
47 template<typename Pose_>
48 class TransformationTraits {
49  public:
50 // inline static Position transform(const Pose& pose, const Position& position);
51 // inline static Position inverseTransform(const Pose& pose, const Position& position);
52 };
53 
59 template<typename Pose_>
60 class get_position {
61  public:
62 // typedef typename positions::Position3D Position;
63 };
64 
65 } // namespace internal
66 
67 
68 
78 template<typename Derived_>
79 class PoseBase {
80  public:
85  PoseBase() = default;
86 
90  PoseBase(const Derived_&) = delete; // on purpose!!
91 
97  operator Derived_& () {
98  return static_cast<Derived_&>(*this);
99  }
100 
106  operator const Derived_& () const {
107  return static_cast<const Derived_&>(*this);
108  }
109 
115  const Derived_& derived() const {
116  return static_cast<const Derived_&>(*this);
117  }
118 
119 
124  return internal::TransformationTraits<Derived_>::transform(this->derived(), position);
125  }
126 
131  return internal::TransformationTraits<Derived_>::inverseTransform(this->derived(), position);
132  }
133 
137  template<typename OtherDerived_>
138  Derived_ operator *(const PoseBase<OtherDerived_>& other) const {
139  return internal::MultiplicationTraits<PoseBase<Derived_>,PoseBase<OtherDerived_>>::mult(this->derived(), other.derived()); // todo: 1. ok? 2. may be optimized
140  }
141 
145  template<typename OtherDerived_>
146  bool operator ==(const PoseBase<OtherDerived_>& other) const {
147  return internal::ComparisonTraits<PoseBase<Derived_>,PoseBase<OtherDerived_>>::isEqual(*this, other);
148  }
149 
153  Derived_& setIdentity();
154 };
155 
156 
157 } // namespace kindr
158 
internal::get_position< Derived_ >::Position inverseTransform(const typename internal::get_position< Derived_ >::Position &position) const
Transforms a position in reverse.
Definition: PoseBase.hpp:130
internal::get_position< Derived_ >::Position transform(const typename internal::get_position< Derived_ >::Position &position) const
Transforms a position.
Definition: PoseBase.hpp:123
Vector< PhysicalType_, PrimType_, Dimension_ > operator*(PrimTypeFactor_ factor, const Vector< PhysicalType_, PrimType_, Dimension_ > &vector)
Multiplies a vector with a scalar.
Definition: Vector.hpp:578
const Derived_ & derived() const
Gets the derived pose.
Definition: PoseBase.hpp:115
Base class that defines the interface of a pose of a rigid body.
Definition: PoseBase.hpp:79
Vector< PhysicalType::Position, PrimType_, Dimension_ > Position
Position-Vector.