ScaledCSpace.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotComponents
19 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20 * @date 2015
21 * @copyright http://www.gnu.org/licenses/gpl.txt
22 * GNU General Public License
23 */
24#pragma once
25
27
28#include <RobotComponents/interface/components/MotionPlanning/CSpace/ScaledCSpace.h>
29
30#include "CSpace.h"
31
32namespace armarx
33{
34 class ScaledCSpace;
35 /**
36 * @brief An ice handle to a ScaledCSpace.
37 */
39
40 /**
41 * @brief Takes an other cspace and scales its' dimensions.
42 * Can be used when lage translations and rotations are planned at the same time.
43 */
44 class ScaledCSpace : virtual public ScaledCSpaceBase, virtual public CSpaceAdaptor
45 {
46 public:
48
49 /**
50 * @brief ctor.
51 * @param cspace The cspace to scale.
52 * @param scale The dimensions' scaling factors.
53 */
54 ScaledCSpace(const CSpaceBasePtr& cspace, const Ice::FloatSeq& scale);
55
56 /**
57 * @return The dimensions' scaling factors.
58 */
59 Ice::FloatSeq
60 getScalingFactors(const ::Ice::Current& = Ice::emptyCurrent) override
61 {
62 return scalingFactors;
63 }
64
65 /**
66 * @param cfg The configuration.
67 * @return Returns the unscaled version of the configuration.
68 */
69 virtual void unscaleConfig(VectorXf& config) const;
70
71 virtual void unscalePath(Path& path) const;
72 virtual void unscalePath(PathWithCost& path) const;
73 virtual void unscalePath(VectorXfSeq& nodes) const;
74
75 virtual void scaleConfig(VectorXf& config) const;
76 virtual void scalePath(Path& path) const;
77
78 //CSpaceBase
79 /**
80 * @param cfg The configuration to check.
81 * @return Checks whether the given configuration is collision free.
82 */
83 bool isCollisionFree(const ::std::pair<const Ice::Float*, const Ice::Float*>& cfg,
84 const Ice::Current& = Ice::emptyCurrent) override;
85
86 /**
87 * @brief Initializes the collision check.
88 */
89 void
90 initCollisionTest(const Ice::Current& = Ice::emptyCurrent) override
91 {
92 ARMARX_CHECK_EXPRESSION(static_cast<std::size_t>(originalCSpace->getDimensionality()) ==
93 scalingFactors.size());
94 unscaled.resize(scalingFactors.size());
95 originalCSpace->initCollisionTest();
96 }
97
98 /**
99 * @return A clone of this object.
100 */
101 CSpaceBasePtr clone(const Ice::Current& = Ice::emptyCurrent) override;
102
103 /**
104 * @return The cspace's dimensions.
105 */
106 FloatRangeSeq getDimensionsBounds(const Ice::Current& = Ice::emptyCurrent) const override;
107
108 /**
109 * @return The cspace's dimensionality.
110 */
111 Ice::Long
112 getDimensionality(const Ice::Current& = Ice::emptyCurrent) const override
113 {
114 return scalingFactors.size();
115 }
116
117 protected:
118 template <class IceBaseClass, class DerivedClass>
120
121 /**
122 * @brief Default ctor. Used for ice factories.
123 */
124 ScaledCSpace() = default;
125
126 /**
127 * @brief Unscales the given configuration to a buffer.
128 * @param cfg The scaled configuration.
129 * @param buffer The buffer to fill.
130 */
131 void unscaleToBuffer(const Ice::Float* cfg, VectorXf& buffer) const;
132
133 private:
134 /**
135 * @brief Buffer for speed up.
136 */
137 VectorXf unscaled;
138 };
139} // namespace armarx
CSpaceAdaptor(CSpaceBasePtr originalCSpace)
Definition CSpace.h:135
bool isCollisionFree(const ::std::pair< const Ice::Float *, const Ice::Float * > &config, const Ice::Current &=Ice::emptyCurrent) override=0
Takes an other cspace and scales its' dimensions.
virtual void unscaleConfig(VectorXf &config) const
CSpaceBasePtr clone(const Ice::Current &=Ice::emptyCurrent) override
FloatRangeSeq getDimensionsBounds(const Ice::Current &=Ice::emptyCurrent) const override
Ice::Long getDimensionality(const Ice::Current &=Ice::emptyCurrent) const override
virtual void unscalePath(Path &path) const
ScaledCSpace(const CSpaceBasePtr &cspace, const Ice::FloatSeq &scale)
ctor.
ScaledCSpace()=default
Default ctor.
void unscaleToBuffer(const Ice::Float *cfg, VectorXf &buffer) const
Unscales the given configuration to a buffer.
virtual void scalePath(Path &path) const
virtual void scaleConfig(VectorXf &config) const
Ice::FloatSeq getScalingFactors(const ::Ice::Current &=Ice::emptyCurrent) override
void initCollisionTest(const Ice::Current &=Ice::emptyCurrent) override
Initializes the collision check.
bool isCollisionFree(const ::std::pair< const Ice::Float *, const Ice::Float * > &cfg, const Ice::Current &=Ice::emptyCurrent) override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ScaledCSpace > ScaledCSpacePtr
An ice handle to a ScaledCSpace.