hpp-corbaserver: include/hpp/corbaserver/core_idl/distances.hh Source File

hpp-corbaserver 9.0.2 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
39#include <hpp/corbaserver/conversions.hh>
40#include <hpp/corbaserver/fwd.hh>
41#include <vector>
42
43#include "hpp/corbaserver/servant-base.hh"
44#include "hpp/core/distance.hh"
45#include "hpp/core/weighed-distance.hh"
46#include "hpp/core_idl/distances-idl.hh"
47
48 namespace hpp {
49 namespace corbaServer {
50 namespace core_idl {
51 template <typename D>
52 class DistanceStorage : public AbstractStorage<D, core::Distance> {
53 public:
54 typedef AbstractStorage<D, core::Distance> parent_t;
55 using parent_t::element;
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>
63 DistanceStorage<T> cast() const {
64 return DistanceStorage<T>(r, HPP_DYNAMIC_PTR_CAST(T, element.lock()));
65 }
66};
67
68 template <typename _Base, typename _Storage>
69 class DistanceServant : public ServantBase<core::Distance, _Storage>,
70 public virtual _Base {
71 SERVANT_BASE_TYPEDEFS(hpp::core_idl::Distance, core::Distance);
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
85 typedef DistanceServant<POA_hpp::core_idl::Distance,
86 DistanceStorage<core::Distance> >
87 Distance;
88
89 template <typename _Base, typename _Storage>
90 class WeighedDistanceServant : public DistanceServant<_Base, _Storage> {
91 SERVANT_BASE_TYPEDEFS(hpp::core_idl::WeighedDistance, core::Distance);
92
93 public:
94 typedef DistanceServant<Base, Storage> Parent;
95
96 WeighedDistanceServant(Server* server, const Storage& s)
97 : Parent(server, s) {}
98
99 ~WeighedDistanceServant() {}
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
112 typedef WeighedDistanceServant<POA_hpp::core_idl::WeighedDistance,
113 DistanceStorage<core::WeighedDistance> >
114 WeighedDistance;
115} // namespace core_idl
116} // end of namespace corbaServer.
117} // end of namespace hpp.
118
119#endif // HPP_CORE_IDL_DISTANCES_HH
floatSeq
Definition common-idl.hh:689
hpp::corbaServer::AbstractStorage
Definition servant-base.hh:233
hpp::corbaServer::AbstractStorage< D, core::Distance >::ptr_t
weak_ptr< D > ptr_t
Definition servant-base.hh:235
hpp::corbaServer::AbstractStorage< D, core::Distance >::element
ptr_t element
Definition servant-base.hh:237
hpp::corbaServer::ServantBase
Definition servant-base.hh:122
hpp::corbaServer::ServantBase< core::Distance, _Storage >::getS
const Storage & getS() const
Definition servant-base.hh:155
hpp::corbaServer::ServantBase< core::Distance, _Storage >::Storage
_Storage Storage
Definition servant-base.hh:124
hpp::corbaServer::ServantBase< core::Distance, _Storage >::getT
StorageElementShPtr_t getT() const
Definition servant-base.hh:146
hpp::corbaServer::ServantBase< core::Distance, _Storage >::get
virtual TShPtr_t get() const
Definition servant-base.hh:132
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition server.hh:78
hpp::corbaServer::core_idl::DistanceServant
Definition distances.hh:70
hpp::corbaServer::core_idl::DistanceServant::value
CORBA::Double value(const floatSeq &q1, const floatSeq &q2)
Definition distances.hh:78
hpp::corbaServer::core_idl::DistanceServant::~DistanceServant
virtual ~DistanceServant()
Definition distances.hh:76
hpp::corbaServer::core_idl::DistanceServant::DistanceServant
DistanceServant(Server *server, const Storage &s)
Definition distances.hh:74
hpp::corbaServer::core_idl::DistanceStorage
Definition distances.hh:52
hpp::corbaServer::core_idl::DistanceStorage::DistanceStorage
DistanceStorage(const core::DevicePtr_t &_r, const ptr_t &_d)
Definition distances.hh:59
hpp::corbaServer::core_idl::DistanceStorage::parent_t
AbstractStorage< D, core::Distance > parent_t
Definition distances.hh:54
hpp::corbaServer::core_idl::DistanceStorage::r
core::DevicePtr_t r
Definition distances.hh:58
hpp::corbaServer::core_idl::DistanceStorage::cast
DistanceStorage< T > cast() const
Definition distances.hh:63
hpp::corbaServer::core_idl::WeighedDistanceServant
Definition distances.hh:90
hpp::corbaServer::core_idl::WeighedDistanceServant::WeighedDistanceServant
WeighedDistanceServant(Server *server, const Storage &s)
Definition distances.hh:96
hpp::corbaServer::core_idl::WeighedDistanceServant::~WeighedDistanceServant
~WeighedDistanceServant()
Definition distances.hh:99
hpp::corbaServer::core_idl::WeighedDistanceServant::getWeights
floatSeq * getWeights()
Definition distances.hh:101
hpp::corbaServer::core_idl::WeighedDistanceServant::Parent
DistanceServant< Base, Storage > Parent
Definition distances.hh:94
hpp::corbaServer::core_idl::WeighedDistanceServant::setWeights
void setWeights(const floatSeq &weights)
Definition distances.hh:103
hpp::core::Distance
conversions.hh
distance.hh
distances-idl.hh
hpp::Error
Corba exception travelling through the Corba channel.
Definition common.idl:27
fwd.hh
hpp::corbaServer::makeServantDownCast
ReturnType::Object_var makeServantDownCast(Server *server, const typename ServantBaseType::Storage &t)
Definition servant-base.hh:407
SERVANT_BASE_TYPEDEFS
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition servant-base.hh:73
hpp::core_idl::Distance
Definition distances.idl:20
hpp::core_idl::WeighedDistance
To define and solve a path planning problem.
Definition distances.idl:29
hpp::corbaServer::core_idl::Distance
DistanceServant< POA_hpp::core_idl::Distance, DistanceStorage< core::Distance > > Distance
Definition distances.hh:87
hpp::corbaServer::core_idl::WeighedDistance
WeighedDistanceServant< POA_hpp::core_idl::WeighedDistance, DistanceStorage< core::WeighedDistance > > WeighedDistance
Definition distances.hh:114
hpp::corbaServer::floatSeqToConfig
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
hpp::corbaServer::Configuration_t
pinocchio::Configuration_t Configuration_t
Definition fwd.hh:65
hpp::corbaServer::vectorToFloatSeq
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
hpp::corbaServer::floatSeqToVector
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
hpp::core::DevicePtr_t
pinocchio::DevicePtr_t DevicePtr_t
hpp
Implement CORBA interface `‘Obstacle’'.
HPP_DYNAMIC_PTR_CAST
#define HPP_DYNAMIC_PTR_CAST(t, x)
servant-base.hh
weighed-distance.hh