rbprmbuilder.impl.hh 5.95 KB
Newer Older
Steve Tonneau's avatar
Steve Tonneau committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (c) 2014 CNRS
// Author: Florent Lamiraux
//
// This file is part of hpp-manipulation-corba.
// hpp-manipulation-corba is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// hpp-manipulation-corba is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Lesser Public License for more details.  You should have
// received a copy of the GNU Lesser General Public License along with
// hpp-manipulation-corba.  If not, see
// <http://www.gnu.org/licenses/>.

#ifndef HPP_RBPRM_CORBA_BUILDER_IMPL_HH
# define HPP_RBPRM_CORBA_BUILDER_IMPL_HH

# include <hpp/core/problem-solver.hh>
# include "rbprmbuilder.hh"
Steve Tonneau's avatar
Steve Tonneau committed
23
# include <hpp/rbprm/rbprm-device.hh>
Steve Tonneau's avatar
Steve Tonneau committed
24
# include <hpp/rbprm/rbprm-fullbody.hh>
Steve Tonneau's avatar
Steve Tonneau committed
25
26
# include <hpp/rbprm/rbprm-shooter.hh>
# include <hpp/rbprm/rbprm-validation.hh>
27
28
29
30
# include <hpp/core/collision-path-validation-report.hh>
# include <hpp/core/problem-solver.hh>
# include <hpp/core/discretized-collision-checking.hh>
# include <hpp/core/straight-path.hh>
Steve Tonneau's avatar
Steve Tonneau committed
31
32
33
34
35
36

namespace hpp {
  namespace rbprm {
    namespace impl {
      using CORBA::Short;

Steve Tonneau's avatar
Steve Tonneau committed
37
38
39
    struct BindShooter
    {
        BindShooter(const std::size_t shootLimit = 10000,
Steve Tonneau's avatar
Steve Tonneau committed
40
                    const std::size_t displacementLimit = 1000)
Steve Tonneau's avatar
Steve Tonneau committed
41
42
43
44
45
46
47
            : shootLimit_(shootLimit)
            , displacementLimit_(displacementLimit) {}

        hpp::rbprm::RbPrmShooterPtr_t create (const hpp::model::DevicePtr_t& robot)
        {
            hpp::model::RbPrmDevicePtr_t robotcast = boost::static_pointer_cast<hpp::model::RbPrmDevice>(robot);
            return hpp::rbprm::RbPrmShooter::create
48
                    (robotcast,problemSolver_->problem ()->collisionObstacles(),romFilter_,normalFilter_,shootLimit_,displacementLimit_);
Steve Tonneau's avatar
Steve Tonneau committed
49
        }
50
51
52
53

        hpp::core::PathValidationPtr_t createPathValidation (const hpp::model::DevicePtr_t& robot, const hpp::model::value_type& val)
        {
            hpp::model::RbPrmDevicePtr_t robotcast = boost::static_pointer_cast<hpp::model::RbPrmDevice>(robot);
54
            hpp::rbprm::RbPrmValidationPtr_t validation(hpp::rbprm::RbPrmValidation::create(robotcast, romFilter_, normalFilter_));
55
56
57
58
            hpp::core::CollisionPathValidationReport defaultValidation;
            return hpp::core::DiscretizedCollisionChecking::createWithValidation(robot,val ,defaultValidation, validation);
        }

Steve Tonneau's avatar
Steve Tonneau committed
59
        hpp::core::ProblemSolverPtr_t problemSolver_;
Steve Tonneau's avatar
Steve Tonneau committed
60
        std::vector<std::string> romFilter_;
61
        std::map<std::string, NormalFilter> normalFilter_;
Steve Tonneau's avatar
Steve Tonneau committed
62
63
64
65
        std::size_t shootLimit_;
        std::size_t displacementLimit_;
    };

Steve Tonneau's avatar
Steve Tonneau committed
66
67
68
      class RbprmBuilder : public virtual POA_hpp::corbaserver::rbprm::RbprmBuilder
      {
        public:
Steve Tonneau's avatar
Steve Tonneau committed
69
        RbprmBuilder ();
Steve Tonneau's avatar
Steve Tonneau committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

        virtual void loadRobotRomModel (const char* robotName,
                 const char* rootJointType,
                 const char* packageName,
                 const char* modelName,
                 const char* urdfSuffix,
                 const char* srdfSuffix) throw (hpp::Error);

        virtual void loadRobotCompleteModel (const char* robotName,
                 const char* rootJointType,
                 const char* packageName,
                 const char* modelName,
                 const char* urdfSuffix,
                 const char* srdfSuffix) throw (hpp::Error);

Steve Tonneau's avatar
Steve Tonneau committed
85
86
87
88
89
90
91
92

        virtual void loadFullBodyRobot (const char* robotName,
                 const char* rootJointType,
                 const char* packageName,
                 const char* modelName,
                 const char* urdfSuffix,
                 const char* srdfSuffix) throw (hpp::Error);

Steve Tonneau's avatar
Steve Tonneau committed
93
        virtual void setFilter(const hpp::Names_t& roms) throw (hpp::Error);
94
        virtual void setNormalFilter(const char* romName, const hpp::floatSeq& normal, double range) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
95

Steve Tonneau's avatar
Steve Tonneau committed
96
        virtual hpp::floatSeq* getSampleConfig(const char* limb, unsigned short sampleId) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
97
        virtual hpp::floatSeq* getSamplePosition(const char* limb, unsigned short sampleId) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
98

Steve Tonneau's avatar
Steve Tonneau committed
99
100
101
        virtual hpp::floatSeq* generateContacts(const hpp::floatSeq& configuration,
                                                const hpp::floatSeq& direction) throw (hpp::Error);

102
103
104
105
        virtual hpp::floatSeq* getContactSamplesIds(const char* limb,
                                                   const hpp::floatSeq& configuration,
                                                   const hpp::floatSeq& direction) throw (hpp::Error);

Steve Tonneau's avatar
Steve Tonneau committed
106
        virtual void addLimb(const char* id, const char* limb, const char* effector, const hpp::floatSeq& offset,  const hpp::floatSeq& normal, double x, double y, unsigned short samples, double resolution) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
107

Steve Tonneau's avatar
Steve Tonneau committed
108
109
110
        virtual void setStartState(const hpp::floatSeq& configuration, const hpp::Names_t& contactLimbs) throw (hpp::Error);
        virtual void setEndState(const hpp::floatSeq& configuration, const hpp::Names_t& contactLimbs) throw (hpp::Error);
        virtual hpp::floatSeqSeq* interpolate(double timestep) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
111
        virtual void saveComputedStates(const char* filepath) throw (hpp::Error);
Steve Tonneau's avatar
Steve Tonneau committed
112

Steve Tonneau's avatar
Steve Tonneau committed
113
        public:
Steve Tonneau's avatar
Steve Tonneau committed
114
115
116
        void SetProblemSolver (hpp::core::ProblemSolverPtr_t problemSolver);

        private:
Steve Tonneau's avatar
Steve Tonneau committed
117
118
119
120
        /// \brief Pointer to hppPlanner object of hpp::corbaServer::Server.
        core::ProblemSolverPtr_t problemSolver_;

        private:
Steve Tonneau's avatar
Steve Tonneau committed
121
        model::T_Rom romDevices_;
Steve Tonneau's avatar
Steve Tonneau committed
122
        rbprm::RbPrmFullBodyPtr_t fullBody_;
Steve Tonneau's avatar
Steve Tonneau committed
123
        bool romLoaded_;
Steve Tonneau's avatar
Steve Tonneau committed
124
        bool fullBodyLoaded_;
Steve Tonneau's avatar
Steve Tonneau committed
125
        BindShooter bindShooter_;
Steve Tonneau's avatar
Steve Tonneau committed
126
127
        rbprm::State startState_;
        rbprm::State endState_;
Steve Tonneau's avatar
Steve Tonneau committed
128
        std::vector<rbprm::State> lastStatesComputed_;
Steve Tonneau's avatar
Steve Tonneau committed
129
130
131
132
133
134
      }; // class RobotBuilder
    } // namespace impl
  } // namespace manipulation
} // namespace hpp

#endif // HPP_RBPRM_CORBA_BUILDER_IMPL_HH