SwingFoot.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, CNRS-UM LIRMM
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 
30 #include <mc_rtc/log/Logger.h>
31 
32 #include <SpaceVecAlg/SpaceVecAlg>
33 
35 
36 namespace lipm_walking
37 {
38 
42 struct SwingFoot
43 {
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 
51  void addLogEntries(mc_rtc::Logger & logger);
52 
58  void integrate(double dt);
59 
65  void removeLogEntries(mc_rtc::Logger & logger);
66 
78  void reset(const sva::PTransformd & initPose, const sva::PTransformd & targetPose, double duration, double height);
79 
83  sva::MotionVecd accel() const
84  {
85  return sva::MotionVecd({0., 0., 0.}, accel_);
86  }
87 
91  double height()
92  {
93  return pos_.z() - initPose_.translation().z();
94  }
95 
101  void landingDuration(double duration)
102  {
103  landingDuration_ = duration;
104  }
105 
111  void landingPitch(double pitch)
112  {
113  landingPitch_ = pitch;
114  }
115 
119  sva::PTransformd pose() const
120  {
121  return sva::PTransformd(ori_, pos_);
122  }
123 
127  double remTime() const
128  {
129  return (duration_ - playback_);
130  }
131 
137  void takeoffDuration(double duration)
138  {
139  takeoffDuration_ = duration;
140  }
141 
147  void takeoffOffset(const Eigen::Vector3d & offset)
148  {
149  takeoffOffset_ = offset;
150  }
151 
157  void takeoffPitch(double pitch)
158  {
159  takeoffPitch_ = pitch;
160  }
161 
165  sva::MotionVecd vel() const
166  {
167  return sva::MotionVecd({0., 0., 0.}, vel_);
168  }
169 
170 private:
176  void updatePose(double t);
177 
183  void updateZ(double t);
184 
190  void updateXY(double t);
191 
197  void updatePitch(double t);
198 
199 private:
200  Eigen::Quaterniond ori_;
201  Eigen::Vector3d accel_;
202  Eigen::Vector3d pos_;
203  Eigen::Vector3d takeoffOffset_ = Eigen::Vector3d::Zero(); // [m]
204  Eigen::Vector3d vel_;
213  double aerialStart_;
214  double duration_;
215  double height_;
216  double landingDuration_ = 0.; // [s]
217  double landingPitch_ = 0.; // [rad]
218  double pitch_;
219  double playback_;
220  double takeoffDuration_ = 0.; // [s]
221  double takeoffPitch_ = 0.; // [rad]
222  sva::PTransformd initPose_;
223  sva::PTransformd targetPose_;
224  sva::PTransformd touchdownPose_;
225 };
226 
227 } // namespace lipm_walking
double remTime() const
Timing remaining until heel strike.
Definition: SwingFoot.h:127
void integrate(double dt)
Progress by dt along the swing foot trajectory.
Definition: SwingFoot.cpp:95
void landingPitch(double pitch)
Upward pitch angle before landing.
Definition: SwingFoot.h:111
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void addLogEntries(mc_rtc::Logger &logger)
Add swing foot entries to log.
Definition: SwingFoot.cpp:77
sva::MotionVecd accel() const
Get current acceleration as motion vector.
Definition: SwingFoot.h:83
Swing foot interpolator.
Definition: SwingFoot.h:42
void takeoffPitch(double pitch)
Downward pitch angle after takeoff.
Definition: SwingFoot.h:157
Polynomial whose argument is retimed to by .
Definition: polynomials.h:662
double height()
Get current swing foot height.
Definition: SwingFoot.h:91
Main controller namespace.
Definition: build.dox:1
void takeoffOffset(const Eigen::Vector3d &offset)
Offset applied to horizontal position after takeoff.
Definition: SwingFoot.h:147
sva::PTransformd pose() const
Get current pose as Plucker transform.
Definition: SwingFoot.h:119
void landingDuration(double duration)
Duration of landing phase.
Definition: SwingFoot.h:101
void takeoffDuration(double duration)
Set duration of takeoff phase.
Definition: SwingFoot.h:137
sva::MotionVecd vel() const
Get current velocity as motion vector.
Definition: SwingFoot.h:165
void removeLogEntries(mc_rtc::Logger &logger)
Remove swing foot entries from log.
Definition: SwingFoot.cpp:86
void reset(const sva::PTransformd &initPose, const sva::PTransformd &targetPose, double duration, double height)
Recompute swing foot trajectory for a new pair of contacts.
Definition: SwingFoot.cpp:36