GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/hpp/rbprm/interpolation/time-constraint-path.hh Lines: 0 37 0.0 %
Date: 2024-02-02 12:21:48 Branches: 0 38 0.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2014 CNRS
3
// Authors: Florent Lamiraux
4
//
5
// This file is part of hpp-core
6
// hpp-core is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU Lesser General Public
8
// License as published by the Free Software Foundation, either version
9
// 3 of the License, or (at your option) any later version.
10
//
11
// hpp-core is distributed in the hope that it will be
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Lesser Public License for more details.  You should have
15
// received a copy of the GNU Lesser General Public License along with
16
// hpp-core  If not, see
17
// <http://www.gnu.org/licenses/>.
18
19
#ifndef HPP_RBPRM_TIMECONSTRAINT_PATH_HH
20
#define HPP_RBPRM_TIMECONSTRAINT_PATH_HH
21
22
#include <hpp/core/config.hh>
23
#include <hpp/core/fwd.hh>
24
#include <hpp/core/path.hh>
25
#include <hpp/rbprm/interpolation/time-dependant.hh>
26
27
namespace hpp {
28
namespace rbprm {
29
namespace interpolation {
30
HPP_PREDEF_CLASS(TimeConstraintPath);
31
typedef shared_ptr<TimeConstraintPath> TimeConstraintPathPtr_t;
32
/// Linear interpolation between two configurations
33
///
34
/// Degrees of freedom are interpolated depending on the type of
35
/// \link hpp::pinocchio::Joint joint \endlink
36
/// they parameterize:
37
///   \li linear interpolation for translation joints, bounded rotation
38
///       joints, and translation part of freeflyer joints,
39
///   \li angular interpolation for unbounded rotation joints,
40
///   \li constant angular velocity for SO(3) part of freeflyer joints.
41
class HPP_CORE_DLLAPI TimeConstraintPath : public core::Path {
42
 public:
43
  typedef Path parent_t;
44
  /// Destructor
45
  virtual ~TimeConstraintPath() {}
46
47
  /// Create instance and return shared pointer
48
  /// \param device Robot corresponding to configurations
49
  /// \param init, end Start and end configurations of the path
50
  /// \param length Distance between the configurations.
51
  static TimeConstraintPathPtr_t create(const core::DevicePtr_t& device,
52
                                        core::ConfigurationIn_t init,
53
                                        core::ConfigurationIn_t end,
54
                                        core::value_type length,
55
                                        const std::size_t pathDofRank,
56
                                        const T_TimeDependant& tds) {
57
    TimeConstraintPath* ptr =
58
        new TimeConstraintPath(device, init, end, length, pathDofRank, tds);
59
    TimeConstraintPathPtr_t shPtr(ptr);
60
    ptr->init(shPtr);
61
    ptr->checkPath();
62
    return shPtr;
63
  }
64
65
  /// Create instance and return shared pointer
66
  /// \param device Robot corresponding to configurations
67
  /// \param init, end Start and end configurations of the path
68
  /// \param length Distance between the configurations.
69
  /// \param constraints the path is subject to
70
  static TimeConstraintPathPtr_t create(const core::DevicePtr_t& device,
71
                                        core::ConfigurationIn_t init,
72
                                        core::ConfigurationIn_t end,
73
                                        core::value_type length,
74
                                        core::ConstraintSetPtr_t constraints,
75
                                        const std::size_t pathDofRank,
76
                                        const T_TimeDependant& tds) {
77
    TimeConstraintPath* ptr = new TimeConstraintPath(
78
        device, init, end, length, constraints, pathDofRank, tds);
79
    TimeConstraintPathPtr_t shPtr(ptr);
80
    ptr->init(shPtr);
81
    ptr->checkPath();
82
    return shPtr;
83
  }
84
85
  /// Create copy and return shared pointer
86
  /// \param path path to copy
87
  static TimeConstraintPathPtr_t createCopy(
88
      const TimeConstraintPathPtr_t& path) {
89
    TimeConstraintPath* ptr = new TimeConstraintPath(*path);
90
    TimeConstraintPathPtr_t shPtr(ptr);
91
    ptr->initCopy(shPtr);
92
    ptr->checkPath();
93
    return shPtr;
94
  }
95
96
  /// Create copy and return shared pointer
97
  /// \param path path to copy
98
  /// \param constraints the path is subject to
99
  static TimeConstraintPathPtr_t createCopy(
100
      const TimeConstraintPathPtr_t& path,
101
      const core::ConstraintSetPtr_t& constraints) {
102
    TimeConstraintPath* ptr = new TimeConstraintPath(*path, constraints);
103
    TimeConstraintPathPtr_t shPtr(ptr);
104
    ptr->initCopy(shPtr);
105
    ptr->checkPath();
106
    return shPtr;
107
  }
108
109
  /// Return a shared pointer to this
110
  ///
111
  /// As TimeConstraintPathP are immutable, and refered to by shared pointers,
112
  /// they do not need to be copied.
113
  virtual core::PathPtr_t copy() const { return createCopy(weak_.lock()); }
114
115
  /// Return a shared pointer to a copy of this and set constraints
116
  ///
117
  /// \param constraints constraints to apply to the copy
118
  /// \precond *this should not have constraints.
119
  virtual core::PathPtr_t copy(
120
      const core::ConstraintSetPtr_t& constraints) const {
121
    return createCopy(weak_.lock(), constraints);
122
  }
123
124
  /// Extraction/Reversion of a sub-path
125
  /// \param subInterval interval of definition of the extract path
126
  /// If upper bound of subInterval is smaller than lower bound,
127
  /// result is reversed.
128
  virtual core::PathPtr_t extract(const core::interval_t& subInterval) const;
129
130
  /// Modify initial configuration
131
  /// \param initial new initial configuration
132
  /// \pre input configuration should be of the same size as current initial
133
  /// configuration
134
  void initialConfig(core::ConfigurationIn_t initial) {
135
    assert(initial.size() == initial_.size());
136
    pinocchio::value_type dof = initial_[pathDofRank_];
137
    initial_ = initial;
138
    initial_[pathDofRank_] = dof;
139
  }
140
141
  /// Modify end configuration
142
  /// \param end new end configuration
143
  /// \pre input configuration should be of the same size as current end
144
  /// configuration
145
  void endConfig(core::ConfigurationIn_t end) {
146
    assert(end.size() == end_.size());
147
    pinocchio::value_type dof = end_[pathDofRank_];
148
    end_ = end;
149
    end_[pathDofRank_] = dof;
150
  }
151
152
  /// Return the internal robot.
153
  core::DevicePtr_t device() const;
154
155
  /// Get the initial configuration
156
  core::Configuration_t initial() const { return initial_; }
157
158
  /// Get the final configuration
159
  core::Configuration_t end() const { return end_; }
160
161
  virtual void checkPath() const;
162
163
 protected:
164
  /// Print path in a stream
165
  virtual std::ostream& print(std::ostream& os) const {
166
    os << "TimeConstraintPath:" << std::endl;
167
    os << "interval: [ " << timeRange().first << ", " << timeRange().second
168
       << " ]" << std::endl;
169
    os << "initial configuration: " << initial_.transpose() << std::endl;
170
    os << "final configuration:   " << end_.transpose() << std::endl;
171
    return os;
172
  }
173
  /// Constructor
174
  TimeConstraintPath(const core::DevicePtr_t& robot,
175
                     core::ConfigurationIn_t init, core::ConfigurationIn_t end,
176
                     core::value_type length, const std::size_t pathDofRank,
177
                     const T_TimeDependant& tds);
178
179
  /// Constructor with constraints
180
  TimeConstraintPath(const core::DevicePtr_t& robot,
181
                     core::ConfigurationIn_t init, core::ConfigurationIn_t end,
182
                     core::value_type length,
183
                     core::ConstraintSetPtr_t constraints,
184
                     const std::size_t pathDofRank, const T_TimeDependant& tds);
185
186
  /// Copy constructor
187
  TimeConstraintPath(const TimeConstraintPath& path);
188
189
  /// Copy constructor with constraints
190
  TimeConstraintPath(const TimeConstraintPath& path,
191
                     const core::ConstraintSetPtr_t& constraints);
192
193
  void init(TimeConstraintPathPtr_t self) {
194
    parent_t::init(self);
195
    weak_ = self;
196
  }
197
198
  void initCopy(TimeConstraintPathPtr_t self) {
199
    parent_t::init(self);
200
    weak_ = self;
201
  }
202
203
  virtual bool impl_compute(core::ConfigurationOut_t result,
204
                            core::value_type param) const;
205
206
 private:
207
  void updateConstraints(core::ConfigurationOut_t configuration) const;
208
209
 private:
210
  core::DevicePtr_t device_;
211
  core::Configuration_t initial_;
212
  core::Configuration_t end_;
213
214
 public:
215
  const std::size_t pathDofRank_;
216
  const T_TimeDependant tds_;
217
218
 private:
219
  TimeConstraintPathWkPtr_t weak_;
220
};  // class TimeConstraintPath
221
}  // namespace interpolation
222
}  // namespace rbprm
223
}  // namespace hpp
224
#endif  // HPP_RBPRM_TIMECONSTRAINT_PATH_HH