Aikido
RnEuclidean-impl.hpp
Go to the documentation of this file.
2 
3 namespace aikido {
4 namespace distance {
5 
6 //==============================================================================
7 extern template class REuclidean<0>;
8 
9 extern template class REuclidean<1>;
10 
11 extern template class REuclidean<2>;
12 
13 extern template class REuclidean<3>;
14 
15 extern template class REuclidean<6>;
16 
17 extern template class REuclidean<Eigen::Dynamic>;
18 
19 //==============================================================================
20 template <int N>
21 REuclidean<N>::REuclidean(std::shared_ptr<const statespace::R<N>> _space)
22  : mStateSpace(std::move(_space))
23 {
24  if (mStateSpace == nullptr)
25  {
26  throw std::invalid_argument("Rn is nullptr.");
27  }
28 }
29 
30 //==============================================================================
31 template <int N>
33 {
34  return mStateSpace;
35 }
36 
37 //==============================================================================
38 template <int N>
40  const statespace::StateSpace::State* _state1,
41  const statespace::StateSpace::State* _state2) const
42 {
43  auto v1 = mStateSpace->getValue(
44  static_cast<const typename statespace::R<N>::State*>(_state1));
45  auto v2 = mStateSpace->getValue(
46  static_cast<const typename statespace::R<N>::State*>(_state2));
47  return (v2 - v1).norm();
48 }
49 
50 } // namespace distance
51 } // namespace aikido
aikido::statespace::R
Represents a N-dimensional real vector space with vector addition as the group operation.
Definition: Rn.hpp:18
aikido::distance::REuclidean::getStateSpace
statespace::ConstStateSpacePtr getStateSpace() const override
Get the StateSpace associated with this metric.
Definition: RnEuclidean-impl.hpp:32
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
RnEuclidean.hpp
aikido::statespace::ConstStateSpacePtr
std::shared_ptr< const StateSpace > ConstStateSpacePtr
Definition: StateSpace.hpp:15
aikido::distance::REuclidean::REuclidean
REuclidean(std::shared_ptr< const statespace::R< N >> _space)
Constructor.
Definition: RnEuclidean-impl.hpp:21
aikido::distance::REuclidean::distance
double distance(const statespace::StateSpace::State *_state1, const statespace::StateSpace::State *_state2) const override
Computes Euclidean distance between two states.
Definition: RnEuclidean-impl.hpp:39
aikido::statespace::R::State
Point in a R<N>.
Definition: Rn.hpp:22
aikido::distance::REuclidean::mStateSpace
std::shared_ptr< const statespace::R< N > > mStateSpace
Definition: RnEuclidean.hpp:30
aikido::statespace::StateSpace::State
Definition: StateSpace.hpp:167