Loading...
Searching...
No Matches
SO2N_SO2M.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/SO2N_SO2M.h>
40#include <ompl/base/spaces/SO2StateSpace.h>
41
42using namespace ompl::multilevel;
43
44Projection_SO2N_SO2M::Projection_SO2N_SO2M(ompl::base::StateSpacePtr BundleSpace, ompl::base::StateSpacePtr BaseSpace)
45 : BaseT(BundleSpace, BaseSpace)
46{
47 setType(PROJECTION_SO2N_SO2M);
48}
49
50void Projection_SO2N_SO2M::projectFiber(const ompl::base::State *xBundle, ompl::base::State *xFiber) const
51{
52 for (unsigned int k = 0; k < getFiberDimension(); k++)
53 {
54 const auto *SO2bundle =
55 xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k + getBaseDimension());
56 auto *SO2fiber = xFiber->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
57
58 SO2fiber->value = SO2bundle->value;
59 }
60}
61
62void Projection_SO2N_SO2M::project(const ompl::base::State *xBundle, ompl::base::State *xBase) const
63{
64 for (unsigned int k = 0; k < getBaseDimension(); k++)
65 {
66 const auto *SO2bundle = xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
67
69
70 if (getBaseDimension() <= 1)
71 {
72 SO2base = xBase->as<base::SO2StateSpace::StateType>();
73 }
74 else
75 {
76 SO2base = xBase->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
77 }
78
79 SO2base->value = SO2bundle->value;
80 }
81}
82
83void Projection_SO2N_SO2M::lift(const ompl::base::State *xBase, const ompl::base::State *xFiber,
84 ompl::base::State *xBundle) const
85{
86 for (unsigned int k = 0; k < getBaseDimension(); k++)
87 {
88 auto *SO2bundle = xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
89 const base::SO2StateSpace::StateType *SO2base;
90
91 if (getBaseDimension() <= 1)
92 {
93 SO2base = xBase->as<base::SO2StateSpace::StateType>();
94 }
95 else
96 {
97 SO2base = xBase->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
98 }
99
100 SO2bundle->value = SO2base->value;
101 }
102 for (unsigned int k = getBaseDimension(); k < getBaseDimension() + getFiberDimension(); k++)
103 {
104 auto *SO2bundle = xBundle->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k);
105 const auto *SO2fiber =
106 xFiber->as<base::CompoundState>()->as<base::SO2StateSpace::StateType>(k - getBaseDimension());
107
108 SO2bundle->value = SO2fiber->value;
109 }
110}
111
112ompl::base::StateSpacePtr Projection_SO2N_SO2M::computeFiberSpace()
113{
114 unsigned int N = getDimension() - getBaseDimension();
115 auto fiberSpace = std::make_shared<base::CompoundStateSpace>();
116 for (unsigned int k = 0; k < N; k++)
117 {
118 base::StateSpacePtr SO2Space = std::make_shared<base::SO2StateSpace>();
119 fiberSpace->addSubspace(SO2Space, 1.0);
120 }
121 return fiberSpace;
122}
Definition of a compound state.
Definition State.h:87
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
unsigned int getFiberDimension() const
Dimension of Fiber Space.
This namespace contains datastructures and planners to exploit multilevel abstractions,...
@ PROJECTION_SO2N_SO2M
SO2N \rightarrow SO2M (N copies of SO2 onto M copies of SO2)