humoto
robot_foot_parameters.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Don Joven Agravante
5  @author Jan Michalczyk
6  @copyright 2014-2017 INRIA, 2014-2015 CNRS. Licensed under the Apache
7  License, Version 2.0. (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
8  @brief
9 */
10 
11 #pragma once
12 
13 namespace humoto
14 {
15  namespace walking
16  {
18  {
19  public:
20  enum Type
21  {
22  UNDEFINED = 0,
26  };
27  };
28 
29 
30  /**
31  * @brief Parameters
32  *
33  *
34  * '"""""""""""""' \
35  * | | | max_feet_dist
36  * ._____________. |
37  * } min_feet_dist /
38  * * <- foot position
39  * `^^^^^^' max_step_len
40  *
41  */
43  {
44  #define HUMOTO_CONFIG_SECTION_ID "RobotFootParameters"
45  #define HUMOTO_CONFIG_CONSTRUCTOR RobotFootParameters
46  #define HUMOTO_CONFIG_ENTRIES \
47  HUMOTO_CONFIG_SCALAR_(max_step_len) \
48  HUMOTO_CONFIG_SCALAR_(min_feet_dist) \
49  HUMOTO_CONFIG_SCALAR_(max_feet_dist) \
50  HUMOTO_CONFIG_SCALAR_(feet_dist_default) \
51  HUMOTO_CONFIG_SCALAR_(foot_length) \
52  HUMOTO_CONFIG_SCALAR_(foot_width)
53  #include HUMOTO_CONFIG_DEFINE_ACCESSORS
54 
55 
56  private:
57  /**
58  * @brief These parameters are defined for left and right foot/side.
59  */
61  {
62  public:
63  /// @{
64  /**
65  * Automatically computed variables, which are used to
66  * determine positions of aligned double supports with respect
67  * to single supports and vice versa.
68  */
69  etools::Vector2 foot_position_in_ads_;
70  etools::Vector2 ads_position_from_ss_;
71  /// @}
72 
73 
74  /// @{
75  /**
76  * Bounds on positions of the feet under various conditions.
77  */
81  /// @}
82 
83 
84  public:
85  /**
86  * @brief Compute position of a foot based on position
87  * and orientation of an aligned double support.
88  *
89  * @param[in] ds_R 2d orientation matrix
90  * @param[in] ds_position 2d position of the ADS
91  *
92  * @return 2d position of a foot
93  */
94  etools::Vector2 getFootPositionFromADS(const etools::Matrix2 &ds_R,
95  const etools::Vector2 &ds_position) const
96  {
97  return(etools::transform(foot_position_in_ads_, ds_R, ds_position));
98  }
99 
100 
101  /**
102  * @brief Compute position of an aligned double support
103  * based on position and orientation of a foot.
104  *
105  * @param[in] ss_R 2d orientation matrix
106  * @param[in] ss_position 2d position of the foot
107  *
108  * @return 2d position of an ADS
109  */
110  etools::Vector2 getADSPositionFromFoot(const etools::Matrix2 &ss_R,
111  const etools::Vector2 &ss_position) const
112  {
113  return(etools::transform(ads_position_from_ss_, ss_R, ss_position));
114  }
115 
116 
117  /**
118  * @brief Get bounds on the foot position
119  *
120  * @param[in] bounds_type type of the bounds
121  *
122  * @return 2d matix: [lb, ub]
123  */
125  {
126  switch (bounds_type)
127  {
129  return(foot_position_fixed_ds_);
130  break;
132  return(foot_position_bounds_ss_);
133  break;
135  return(foot_position_fixed_ss_);
136  break;
137  default:
138  HUMOTO_THROW_MSG("Unsupported type of foot position bounds.");
139  }
140  }
141  };
142 
143 
144  private:
145  /// @{
146  /**
147  * Various parameters of the feet and steps
148  */
153  double foot_length_;
154  double foot_width_;
155  /// @}
156 
157 
158  /// @{
159  /**
160  * CoP bounds in single supports and aligned double supports.
161  */
164  /// @}
165 
166 
167  /// parameters corresponding to the left and right feet
169 
170 
171 
172  protected:
173  /**
174  * @brief Create some useful parameters derived from the primal robot parameters
175  */
176  void finalize()
177  {
178  double half_foot_length = foot_length_/2.;
179  double half_foot_width = foot_width_/2.;
180  double half_total_width = (foot_width_ + feet_dist_default_)/2.;
181  double half_feet_dist_default = feet_dist_default_/2.;
182 
183  feet_.getLeft().foot_position_in_ads_ << 0., half_feet_dist_default;
184  feet_.getRight().foot_position_in_ads_ << 0., -half_feet_dist_default;
185 
186  feet_.getRight().ads_position_from_ss_ << 0., half_feet_dist_default;
187  feet_.getLeft().ads_position_from_ss_ << 0., -half_feet_dist_default;
188 
189  ss_cop_bounds_ <<
190  -half_foot_length, half_foot_length,
191  -half_foot_width, half_foot_width;
192 
193  ads_cop_bounds_ <<
194  -half_foot_length, half_foot_length,
195  -half_total_width, half_total_width;
196 
197  // With respect to the center of prseceding SS
198  feet_.getLeft().foot_position_bounds_ss_ <<
199  -max_step_len_, max_step_len_,
200  min_feet_dist_, max_feet_dist_;
201 
202  feet_.getRight().foot_position_bounds_ss_ <<
203  -max_step_len_, max_step_len_,
204  -max_feet_dist_, -min_feet_dist_;
205 
206  // With respect to the center of preceding SS (fixed position)
207  feet_.getLeft().foot_position_fixed_ss_ <<
208  0., 0.,
209  half_feet_dist_default, half_feet_dist_default;
210 
211  feet_.getRight().foot_position_fixed_ss_ <<
212  0., 0.,
213  -half_feet_dist_default, -half_feet_dist_default;
214 
215  // With respect to the center of preceding SS (fixed_position)
216  feet_.getLeft().foot_position_fixed_ds_ <<
217  0., 0.,
218  half_feet_dist_default, half_feet_dist_default;
219 
220  feet_.getRight().foot_position_fixed_ds_ <<
221  0., 0.,
222  -half_feet_dist_default, -half_feet_dist_default;
223  }
224 
225  public:
226  /**
227  * @brief Default constructor
228  */
230  {
231  setDefaults();
232  }
233 
234 
235  /**
236  * @brief Initialize to default values (HRP2)
237  */
238  void setDefaults()
239  {
240  max_step_len_ = 0.2;
241  min_feet_dist_ = 0.19; // In mpc-walkgen 0.19 is in the DS only, 0.2 afterwards
242  max_feet_dist_ = 0.3;
243  feet_dist_default_ = 0.19;
244  foot_length_ = 0.1372;
245  foot_width_ = 0.058;
246 
247  finalize();
248  }
249 
250 
251  /**
252  * @brief Get position of a foot or aligned double support
253  * based on position of an aligned support or a foot.
254  *
255  * @param[in] left_or_right left or right foot
256  * @param[in] ref_R orientation of the reference foot / ADS
257  * @param[in] ref_position position of the reference foot / ADS
258  *
259  * @return 2d position.
260  */
261  etools::Vector2 getFootPositionFromADS(const humoto::LeftOrRight::Type left_or_right,
262  const etools::Matrix2 &ref_R,
263  const etools::Vector2 &ref_position) const
264  {
265  return(feet_[left_or_right].getFootPositionFromADS(ref_R, ref_position));
266  }
267 
268 
269  /// @copydoc getFootPositionFromADS
270  etools::Vector2 getADSPositionFromFoot(const humoto::LeftOrRight::Type left_or_right,
271  const etools::Matrix2 &ref_R,
272  const etools::Vector2 &ref_position) const
273  {
274  return(feet_[left_or_right].getADSPositionFromFoot(ref_R, ref_position));
275  }
276 
277 
278 
279  /**
280  * @brief Get bounds on position of a foot.
281  *
282  * @param[in] left_or_right left or right foot
283  * @param[in] bounds_type type of the bounds
284  *
285  * @return 2x2 matrix: [lb, ub]
286  */
288  const FootBoundsType::Type bounds_type) const
289  {
290  return(feet_[left_or_right].getFootPositionBounds(bounds_type));
291  }
292 
293 
294 
295  /**
296  * @brief Return bounds on position of the CoP in ADS / SS
297  *
298  * @return 2x2 matrix: [lb, ub]
299  */
301  {
302  return(ads_cop_bounds_);
303  }
304 
305 
306  /// @copydoc getADSCoPBounds
308  {
309  return(ss_cop_bounds_);
310  }
311 
312 
313  /**
314  * @brief Log
315  *
316  * @param[in,out] logger logger
317  * @param[in] parent parent
318  * @param[in] name name
319  */
321  const LogEntryName &parent = LogEntryName(),
322  const std::string &name = "robot_foot_parameters") const
323  {
324  LogEntryName subname = parent; subname.add(name);
325 
326  logger.log(LogEntryName(subname).add("max_step_len") , max_step_len_ );
327  logger.log(LogEntryName(subname).add("min_feet_dist") , min_feet_dist_ );
328  logger.log(LogEntryName(subname).add("max_feet_dist") , max_feet_dist_ );
329  logger.log(LogEntryName(subname).add("feet_dist_default"), feet_dist_default_);
330  logger.log(LogEntryName(subname).add("foot_length") , foot_length_ );
331  logger.log(LogEntryName(subname).add("foot_width") , foot_width_ );
332  }
333  };
334  }
335 }
Eigen::Matrix< typename Eigen::MatrixBase< t_DerivedMatrix >::Scalar, Eigen::MatrixBase< t_DerivedMatrix >::RowsAtCompileTime, Eigen::MatrixBase< t_DerivedMatrix >::ColsAtCompileTime > EIGENTOOLS_VISIBILITY_ATTRIBUTE transform(const Eigen::MatrixBase< t_DerivedMatrix > &matrix, const Eigen::MatrixBase< t_DerivedRotation > &rotation, const Eigen::MatrixBase< t_DerivedTranslation > &translation)
Transform the input positions given as a concatenated set of 2d/3d vectors, given M = [v1...
Definition: eigentools.h:341
etools::Vector2 getADSPositionFromFoot(const humoto::LeftOrRight::Type left_or_right, const etools::Matrix2 &ref_R, const etools::Vector2 &ref_position) const
Get position of a foot or aligned double support based on position of an aligned support or a foot...
#define HUMOTO_LOCAL
Definition: export_import.h:26
void finalize()
Create some useful parameters derived from the primal robot parameters.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
Definition: logger.h:997
etools::Vector2 getFootPositionFromADS(const humoto::LeftOrRight::Type left_or_right, const etools::Matrix2 &ref_R, const etools::Vector2 &ref_position) const
Get position of a foot or aligned double support based on position of an aligned support or a foot...
Container for two symmetric objects.
Definition: leftright.h:58
Default configurable base is strict.
Definition: config.h:353
void setDefaults()
Initialize to default values (HRP2)
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
Definition: logger.h:169
etools::Vector2 getADSPositionFromFoot(const etools::Matrix2 &ss_R, const etools::Vector2 &ss_position) const
Compute position of an aligned double support based on position and orientation of a foot...
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
Definition: logger.h:555
etools::Matrix2 getADSCoPBounds() const
Return bounds on position of the CoP in ADS / SS.
The root namespace of HuMoTo.
Definition: config.h:12
t_Data & getRight()
Get/set/copy left or right object.
Definition: leftright.h:99
etools::Matrix2 getSSCoPBounds() const
Return bounds on position of the CoP in ADS / SS.
etools::Matrix2 getFootBounds(const humoto::LeftOrRight::Type left_or_right, const FootBoundsType::Type bounds_type) const
Get bounds on position of a foot.
LeftRightContainer< LeftRightParameters > feet_
parameters corresponding to the left and right feet
LogEntryName & add(const char *name)
extends entry name with a subname
Definition: logger.h:232
t_Data & getLeft()
Get/set/copy left or right object.
Definition: leftright.h:93
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="robot_foot_parameters") const
Log.
These parameters are defined for left and right foot/side.
etools::Vector2 getFootPositionFromADS(const etools::Matrix2 &ds_R, const etools::Vector2 &ds_position) const
Compute position of a foot based on position and orientation of an aligned double support...
etools::Matrix2 getFootPositionBounds(const FootBoundsType::Type bounds_type) const
Get bounds on the foot position.
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2
Definition: eigentools.h:76