Loading...
Searching...
No Matches
RNSO2_RN.cpp
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2020,
5 * Max Planck Institute for Intelligent Systems (MPI-IS).
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of the MPI-IS nor the names
19 * of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *********************************************************************/
36
37/* Author: Andreas Orthey */
38
39#include <ompl/multilevel/datastructures/projections/RNSO2_RN.h>
40#include <ompl/base/spaces/SO2StateSpace.h>
41#include <ompl/base/spaces/RealVectorStateSpace.h>
42
43using namespace ompl::multilevel;
44
45Projection_RNSO2_RN::Projection_RNSO2_RN(ompl::base::StateSpacePtr BundleSpace, ompl::base::StateSpacePtr BaseSpace)
46 : BaseT(BundleSpace, BaseSpace)
47{
48 setType(PROJECTION_RNSO2_RN);
49}
50
51void Projection_RNSO2_RN::projectFiber(const ompl::base::State *xBundle, ompl::base::State *xFiber) const
52{
53 const auto *xBundle_SO2 = xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(1);
54
55 auto *xFiber_SO2 = xFiber->as<base::SO2StateSpace::StateType>();
56
57 xFiber_SO2->value = xBundle_SO2->value;
58}
59
60void Projection_RNSO2_RN::project(const ompl::base::State *xBundle, ompl::base::State *xBase) const
61{
62 const auto *xBundle_R3 = xBundle->as<base::CompoundState>()->as<base::RealVectorStateSpace::StateType>(0);
63 auto *xBase_R3 = xBase->as<base::RealVectorStateSpace::StateType>();
64
65 for (unsigned int k = 0; k < 3; k++)
66 {
67 xBase_R3->values[k] = xBundle_R3->values[k];
68 }
69}
70
71void Projection_RNSO2_RN::lift(const ompl::base::State *xBase, const ompl::base::State *xFiber,
72 ompl::base::State *xBundle) const
73{
74 auto *xBundle_R3 = xBundle->as<base::CompoundState>()->as<base::RealVectorStateSpace::StateType>(0);
75 auto *xBundle_SO2 = xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(1);
76
77 const auto *xFiber_SO2 = xFiber->as<base::SO2StateSpace::StateType>();
78
79 const auto *xBase_R3 = xBase->as<base::RealVectorStateSpace::StateType>();
80
81 for (unsigned int k = 0; k < 3; k++)
82 {
83 xBundle_R3->values[k] = xBase_R3->values[k];
84 }
85 xBundle_SO2->value = xFiber_SO2->value;
86}
87
88ompl::base::StateSpacePtr Projection_RNSO2_RN::computeFiberSpace()
89{
90 unsigned int N = getDimension();
91 unsigned int Y = getBaseDimension();
92 if (Y != (N - 1))
93 {
94 OMPL_ERROR("Assumed input is SO(2)xRN -> RN, but got %d -> %d dimensions.", N, Y);
95 throw "Invalid Dimensionality";
96 }
97 return std::make_shared<base::SO2StateSpace>();
98}
Definition of a compound state.
Definition State.h:87
double * values
The value of the actual vector in Rn
The definition of a state in SO(2)
double value
The value of the angle in the interval (-Pi, Pi].
A shared pointer wrapper for ompl::base::StateSpace.
Definition of an abstract state.
Definition State.h:50
const T * as() const
Cast this instance to a desired type.
Definition State.h:66
A single Bundle-space.
Definition BundleSpace.h:64
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
Definition Console.h:64
This namespace contains datastructures and planners to exploit multilevel abstractions,...
@ PROJECTION_RNSO2_RN
RNSO2 \rightarrow RN, n > 0.