hpp-corbaserver 4.14.0
Corba server for Humanoid Path Planner applications
Loading...
Searching...
No Matches
distances.hh
Go to the documentation of this file.
1// Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
2//
3
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26// DAMAGE.
27//
28// This software is provided "as is" without warranty of any kind,
29// either expressed or implied, including but not limited to the
30// implied warranties of fitness for a particular purpose.
31//
32// See the COPYING file for more information.
33
34#ifndef HPP_CORE_IDL_DISTANCES_HH
35#define HPP_CORE_IDL_DISTANCES_HH
36
37#include <stdlib.h>
38
41#include <vector>
42
44#include "hpp/core/distance.hh"
45#include "hpp/core/weighed-distance.hh"
47
48namespace hpp {
49namespace corbaServer {
50namespace core_idl {
51template <typename D>
52class DistanceStorage : public AbstractStorage<D, core::Distance> {
53 public:
56 using typename parent_t::ptr_t;
57
58 core::DevicePtr_t r;
59 DistanceStorage(const core::DevicePtr_t& _r, const ptr_t& _d)
60 : parent_t(_d), r(_r) {}
61
62 template <typename T>
64 return DistanceStorage<T>(r, HPP_DYNAMIC_PTR_CAST(T, element.lock()));
65 }
66};
67
68template <typename _Base, typename _Storage>
69class DistanceServant : public ServantBase<core::Distance, _Storage>,
70 public virtual _Base {
72
73 public:
74 DistanceServant(Server* server, const Storage& s) : _ServantBase(server, s) {}
75
76 virtual ~DistanceServant() {}
77
78 CORBA::Double value(const floatSeq& q1, const floatSeq& q2) {
79 Configuration_t qq1(floatSeqToConfig(getS().r, q1, true)),
80 qq2(floatSeqToConfig(getS().r, q2, true));
81 return (*get())(qq1, qq2);
82 }
83};
84
85typedef DistanceServant<POA_hpp::core_idl::Distance,
86 DistanceStorage<core::Distance> >
88
89template <typename _Base, typename _Storage>
90class WeighedDistanceServant : public DistanceServant<_Base, _Storage> {
92
93 public:
95
97 : Parent(server, s) {}
98
100
101 floatSeq* getWeights() { return vectorToFloatSeq(getT()->weights()); }
102
103 void setWeights(const floatSeq& weights) {
104 try {
105 return getT()->weights(floatSeqToVector(weights));
106 } catch (const std::exception& e) {
107 throw Error(e.what());
108 }
109 }
110};
111
112typedef WeighedDistanceServant<POA_hpp::core_idl::WeighedDistance,
113 DistanceStorage<core::WeighedDistance> >
115} // namespace core_idl
116} // end of namespace corbaServer.
117} // end of namespace hpp.
118
119#endif // HPP_CORE_IDL_DISTANCES_HH
Definition: common-idl.hh:689
Definition: servant-base.hh:218
weak_ptr< D > ptr_t
Definition: servant-base.hh:220
ptr_t element
Definition: servant-base.hh:222
Definition: servant-base.hh:120
const Storage & getS() const
Definition: servant-base.hh:148
_Storage Storage
Definition: servant-base.hh:122
StorageElementShPtr_t getT() const
Definition: servant-base.hh:139
virtual TShPtr_t get() const
Definition: servant-base.hh:130
Implementation of Hpp module Corba server.
Definition: server.hh:77
CORBA::Double value(const floatSeq &q1, const floatSeq &q2)
Definition: distances.hh:78
virtual ~DistanceServant()
Definition: distances.hh:76
DistanceServant(Server *server, const Storage &s)
Definition: distances.hh:74
DistanceStorage(const core::DevicePtr_t &_r, const ptr_t &_d)
Definition: distances.hh:59
AbstractStorage< D, core::Distance > parent_t
Definition: distances.hh:54
core::DevicePtr_t r
Definition: distances.hh:58
DistanceStorage< T > cast() const
Definition: distances.hh:63
WeighedDistanceServant(Server *server, const Storage &s)
Definition: distances.hh:96
~WeighedDistanceServant()
Definition: distances.hh:99
floatSeq * getWeights()
Definition: distances.hh:101
DistanceServant< Base, Storage > Parent
Definition: distances.hh:94
void setWeights(const floatSeq &weights)
Definition: distances.hh:103
Corba exception travelling through the Corba channel.
Definition: common.idl:27
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition: servant-base.hh:73
Definition: distances.idl:20
To define and solve a path planning problem.
Definition: distances.idl:27
DistanceServant< POA_hpp::core_idl::Distance, DistanceStorage< core::Distance > > Distance
Definition: distances.hh:87
WeighedDistanceServant< POA_hpp::core_idl::WeighedDistance, DistanceStorage< core::WeighedDistance > > WeighedDistance
Definition: distances.hh:114
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:66
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
Implement CORBA interface `‘Obstacle’'.
Definition: basic-server.hh:35