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 #include "CSpace.h"
30 
31 namespace armarx
32 {
33  class ScaledCSpace;
34  /**
35  * @brief An ice handle to a ScaledCSpace.
36  */
38 
39  /**
40  * @brief Takes an other cspace and scales its' dimensions.
41  * Can be used when lage translations and rotations are planned at the same time.
42  */
43  class ScaledCSpace :
44  virtual public ScaledCSpaceBase,
45  virtual public CSpaceAdaptor
46  {
47  public:
49 
50  /**
51  * @brief ctor.
52  * @param cspace The cspace to scale.
53  * @param scale The dimensions' scaling factors.
54  */
55  ScaledCSpace(const CSpaceBasePtr& cspace, const Ice::FloatSeq& scale);
56 
57  /**
58  * @return The dimensions' scaling factors.
59  */
60  Ice::FloatSeq 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, const Ice::Current& = Ice::emptyCurrent)override;
84 
85  /**
86  * @brief Initializes the collision check.
87  */
88  void initCollisionTest(const Ice::Current& = Ice::emptyCurrent) override
89  {
90  ARMARX_CHECK_EXPRESSION(static_cast<std::size_t>(originalCSpace->getDimensionality()) == scalingFactors.size());
91  unscaled.resize(scalingFactors.size());
92  originalCSpace->initCollisionTest();
93  }
94 
95  /**
96  * @return A clone of this object.
97  */
98  CSpaceBasePtr clone(const Ice::Current& = Ice::emptyCurrent) override;
99 
100  /**
101  * @return The cspace's dimensions.
102  */
103  FloatRangeSeq getDimensionsBounds(const Ice::Current& = Ice::emptyCurrent) const override;
104 
105  /**
106  * @return The cspace's dimensionality.
107  */
108  Ice::Long getDimensionality(const Ice::Current& = Ice::emptyCurrent) const override
109  {
110  return scalingFactors.size();
111  }
112 
113  protected:
114  template <class IceBaseClass, class DerivedClass> friend class armarx::GenericFactory;
115 
116  /**
117  * @brief Default ctor. Used for ice factories.
118  */
119  ScaledCSpace() = default;
120 
121  /**
122  * @brief Unscales the given configuration to a buffer.
123  * @param cfg The scaled configuration.
124  * @param buffer The buffer to fill.
125  */
126  void unscaleToBuffer(const Ice::Float* cfg, VectorXf& buffer) const;
127 
128  private:
129  /**
130  * @brief Buffer for speed up.
131  */
132  VectorXf unscaled;
133  };
134 }
armarx::ScaledCSpace::unscalePath
virtual void unscalePath(Path &path) const
Definition: ScaledCSpace.cpp:66
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::CSpace::isCollisionFree
bool isCollisionFree(const ::std::pair< const Ice::Float *, const Ice::Float * > &config, const Ice::Current &=Ice::emptyCurrent) override=0
CSpace.h
FactoryCollectionBase.h
armarx::ScaledCSpace::scalePath
virtual void scalePath(Path &path) const
Definition: ScaledCSpace.cpp:93
armarx::ScaledCSpace::getScalingFactors
Ice::FloatSeq getScalingFactors(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: ScaledCSpace.h:60
armarx::ScaledCSpace::initCollisionTest
void initCollisionTest(const Ice::Current &=Ice::emptyCurrent) override
Initializes the collision check.
Definition: ScaledCSpace.h:88
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::ScaledCSpace::unscaleToBuffer
void unscaleToBuffer(const Ice::Float *cfg, VectorXf &buffer) const
Unscales the given configuration to a buffer.
Definition: ScaledCSpace.cpp:129
armarx::CSpaceAdaptor
Definition: CSpace.h:125
armarx::ScaledCSpace::clone
CSpaceBasePtr clone(const Ice::Current &=Ice::emptyCurrent) override
Definition: ScaledCSpace.cpp:108
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::ScaledCSpace::getDimensionsBounds
FloatRangeSeq getDimensionsBounds(const Ice::Current &=Ice::emptyCurrent) const override
Definition: ScaledCSpace.cpp:116
armarx::ScaledCSpace
Takes an other cspace and scales its' dimensions.
Definition: ScaledCSpace.h:43
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::ScaledCSpace::ScaledCSpace
ScaledCSpace()=default
Default ctor.
armarx::ScaledCSpace::scaleConfig
virtual void scaleConfig(VectorXf &config) const
Definition: ScaledCSpace.cpp:84
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
armarx::ScaledCSpace::isCollisionFree
bool isCollisionFree(const ::std::pair< const Ice::Float *, const Ice::Float * > &cfg, const Ice::Current &=Ice::emptyCurrent) override
Definition: ScaledCSpace.cpp:101
armarx::ScaledCSpace::unscaleConfig
virtual void unscaleConfig(VectorXf &config) const
Definition: ScaledCSpace.cpp:60
armarx::ScaledCSpace::getDimensionality
Ice::Long getDimensionality(const Ice::Current &=Ice::emptyCurrent) const override
Definition: ScaledCSpace.h:108
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28