humoto
foot_trajectory.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Jan Michalczyk
4  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
5  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6  @brief
7 */
8 
9 #pragma once
10 
11 namespace humoto
12 {
13  namespace walking
14  {
15  /**
16  * @brief Class implementing simple example foot trajectory
17  * between two 3D points.
18  *
19  * trajectory along z is composed of two separate trajectories.
20  */
22  {
23  public:
24  /**
25  * @brief Constructor.
26  */
28  {
29  }
30 
31 
32  /**
33  * @brief Constructor.
34  * Velocities set to zero at both ends of the trajectory
35  *
36  * @param[in] a initial 3D configuration [x, y, z]
37  * @param[in] b final 3D configuration [x, y, z]
38  * @param[in] step_height height of the step
39  */
40  void initialize(const etools::Vector3& a,
41  const etools::Vector3& b,
42  const double step_height)
43  {
44  HUMOTO_ASSERT(b(2) <= (a(2) + step_height), "final z position greater than step height.")
45  x_.initialize( a(0), b(0));
46  y_.initialize( a(1), b(1));
47  z1_.initialize(a(2), a(2) + step_height);
48  z2_.initialize(step_height + a(2), b(2));
49  }
50 
51 
52  /**
53  * @brief Constructor.
54  * Velocities set to non-zero at both ends of the trajectory
55  *
56  * @param[in] a initial positions [x, y, z]
57  * @param[in] adot initial velocities [xdot, ydot, zdot]
58  * @param[in] b final positions [x, y, z]
59  * @param[in] bdot final velocities [xdot, ydot, zdot]
60  * @param[in] step_height height of the step
61  */
62  void initialize(const etools::Vector3& a, const etools::Vector3& adot,
63  const etools::Vector3& b, const etools::Vector3& bdot,
64  const double step_height)
65  {
66  HUMOTO_ASSERT(b(2) <= (a(2) + step_height), "final z position greater than step height.")
67  x_.initialize( a(0), adot(0), b(0), bdot(0));
68  y_.initialize( a(1), adot(1), b(1), bdot(1));
69  z1_.initialize(a(2), adot(2), a(2) + step_height, 0.0);
70  z2_.initialize(step_height + a(2), 0.0, b(2), bdot(2));
71  }
72 
73 
74  /**
75  * @brief Constructor.
76  * Velocities set to non-zero at both ends of the trajectory
77  *
78  * @param[in] a initial point mass state
79  * @param[in] b final point mass state
80  * @param[in] step_height height of the step
81  */
84  const double step_height)
85  {
86  HUMOTO_ASSERT(b.position_(2) <= (a.position_(2) + step_height), "final z position greater than step height.")
87  x_.initialize( a.position_(0), a.velocity_(0), b.position_(0), b.velocity_(0));
88  y_.initialize( a.position_(1), a.velocity_(1), b.position_(1), b.velocity_(1));
89  z1_.initialize(a.position_(2), a.velocity_(2), a.position_(2) + step_height, 0.0);
90  z2_.initialize(step_height + a.position_(2), 0.0, b.position_(2), b.velocity_(2));
91  }
92 
93 
94  /**
95  * @brief Evaluate the foot trajectory along x/y/z coordinate.
96  *
97  * @param[in] t time instant
98  * @param[in] trajectory_type type of trajectory
99  * @return value (position/velocity/acceleration)
100  */
101  double evalx( const double t,
102  const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
103  {
104  return (x_.eval(t, trajectory_type));
105  }
106 
107 
108  /**
109  * @copydoc Simple3DFootTrajectory::evalx
110  */
111  double evaly( const double t,
112  const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
113  {
114  return (y_.eval(t, trajectory_type));
115  }
116 
117 
118  /**
119  * @copydoc Simple3DFootTrajectory::evalx
120  */
121  double evalz( const double t,
122  const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
123  {
124  if (t <= 0.5)
125  {
126  return (z1_.eval(t*2, trajectory_type));
127  }
128  else
129  {
130  return (z2_.eval((t-0.5)*2, trajectory_type));
131  }
132  }
133 
134 
135  /**
136  * @brief Evaluate the trajectory
137  *
138  * @param[in] t time instant
139  * @param[in] trajectory_type type of trajectory
140  *
141  * @return Eigen matrix with evaluated trajectory samples
142  */
143  etools::Vector3 eval( const double t,
144  const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
145  {
146  etools::Vector3 result;
147 
148  result(0) = evalx(t, trajectory_type);
149  result(1) = evaly(t, trajectory_type);
150  result(2) = evalz(t, trajectory_type);
151 
152  return (result);
153  }
154 
155 
156  /**
157  * @brief Evaluate the trajectory
158  *
159  * @param[in,out] foot_state state of the foot at the given time instant
160  * @param[in] t time instant
161  */
163  const double t) const
164  {
168  }
169 
170 
171  private:
176  };
177  }
178 }
etools::Vector3 eval(const double t, const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
Evaluate the trajectory.
Class that groups together parameters related to a robot foot.
#define HUMOTO_LOCAL
Definition: export_import.h:26
humoto::rigidbody::CubicPolynomial1D z2_
void initialize(const etools::Vector3 &a, const etools::Vector3 &b, const double step_height)
Constructor. Velocities set to zero at both ends of the trajectory.
double evalx(const double t, const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
Evaluate the foot trajectory along x/y/z coordinate.
#define HUMOTO_ASSERT(condition, message)
Class interpolating simple 1D cubic polynomial between two 1D points. Use this class to build more co...
humoto::rigidbody::CubicPolynomial1D x_
double evaly(const double t, const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
Evaluate the foot trajectory along x/y/z coordinate.
The root namespace of HuMoTo.
Definition: config.h:12
Class that groups together parmeters related to a robot foot.
Class implementing simple example foot trajectory between two 3D points.
humoto::rigidbody::CubicPolynomial1D z1_
void initialize(const etools::Vector3 &a, const etools::Vector3 &adot, const etools::Vector3 &b, const etools::Vector3 &bdot, const double step_height)
Constructor. Velocities set to non-zero at both ends of the trajectory.
void eval(humoto::rigidbody::RigidBodyState &foot_state, const double t) const
Evaluate the trajectory.
void initialize(const humoto::rigidbody::PointMassState &a, const humoto::rigidbody::PointMassState &b, const double step_height)
Constructor. Velocities set to non-zero at both ends of the trajectory.
double evalz(const double t, const rigidbody::TrajectoryEvaluationType::Type trajectory_type) const
Evaluate the foot trajectory along x/y/z coordinate.
humoto::rigidbody::CubicPolynomial1D y_