A sparse MPC solver for walking motion generation (old version).
|
Defines the parameters of the Walking Pattern Generator. More...
#include <WMG.h>
Public Member Functions | |
WMG (const unsigned int, const unsigned int, const double step_height_=0.0135, double bezier_weight_1_=1.0, double bezier_weight_2_=2.0, double bezier_inclination_1_=0.01, double bezier_inclination_2_=0.008) | |
Initializes a WMG object. | |
~WMG () | |
Default destructor. | |
void | setFootstepDefaults (const unsigned int, const unsigned int, const double *constraints=NULL) |
Set default parameters of footsteps. | |
void | setFootstepDefaults (const unsigned int, const unsigned int, const unsigned int, const double *constraints=NULL) |
Set default parameters of footsteps. | |
void | addFootstep (const double, const double, const double, fs_type type=FS_TYPE_AUTO) |
Adds a footstep to FS. | |
bool | isSupportSwitchNeeded () |
Checks if the support foot switch is needed. | |
WMGret | formPreviewWindow (smpc_parameters &) |
Forms a preview window. | |
void | FS2file (const std::string, const bool plot_ds=true) |
Outputs the footsteps in FS to a file, that can be executed in Matlab/Octave to get a figure of the steps. | |
void | getFeetPositions (const unsigned int, double *, double *) |
Determine position and orientation of feet. | |
void | getFootsteps (std::vector< double > &, std::vector< double > &, std::vector< double > &) |
Return coordinates of footstep reference points and rotation angles of footsteps (only for SS). | |
void | changeNextSSPosition (const double *, const bool) |
Changes position of the next SS. | |
Public Attributes | |
std::vector< footstep > | FS |
A vector of footsteps. | |
unsigned int | N |
Number of iterations in a preview window. | |
unsigned int * | T_ms |
unsigned int | sampling_period |
int | current_step_number |
int | first_preview_step |
The first step in the current preview window. | |
double | step_height |
The maximum height, that can be reached by a swing foot. | |
double | def_ss_constraint [4] |
double | def_auto_ds_constraint [4] |
double | bezier_weight_1 |
double | bezier_weight_2 |
double | bezier_inclination_1 |
double | bezier_inclination_2 |
Private Member Functions | |
void | getDSFeetPositions (const int, double *, double *) |
Determine position and orientation of feet in DS. | |
void | getSSFeetPositions (const int, const double, double *, double *) |
Determine position and orientation of feet (parabolic trajectory) | |
void | getSSFeetPositionsBezier (const int, const double, double *, double *) |
Determine position and orientation of feet (using cubic Bezier curves) | |
int | getNextSS (const int, const fs_type type=FS_TYPE_AUTO) |
Returns index of the next SS. | |
int | getPrevSS (const int, const fs_type type=FS_TYPE_AUTO) |
Returns index of the previous SS. | |
Private Attributes | |
double | addstep_constraint [4] |
unsigned int | def_time_ms |
unsigned int | ds_time_ms |
unsigned int | ds_num |
unsigned int | last_time_decrement |
WMG::WMG | ( | const unsigned int | N_, |
const unsigned int | T_, | ||
const double | step_height_ = 0.0135 , |
||
double | bezier_weight_1_ = 1.0 , |
||
double | bezier_weight_2_ = 2.0 , |
||
double | bezier_inclination_1_ = 0.01 , |
||
double | bezier_inclination_2_ = 0.008 |
||
) |
Initializes a WMG object.
[in] | N_ | Number of sampling times in a preview window |
[in] | T_ | Sampling time [ms.] |
[in] | step_height_ | step height (for interpolation of feet movements) [meter] |
[in] | bezier_weight_1_ | see bezier_weight_1 |
[in] | bezier_weight_2_ | see bezier_weight_2 |
[in] | bezier_inclination_1_ | see bezier_inclination_1 |
[in] | bezier_inclination_2_ | see bezier_inclination_2 |
NAO constraint with safety margin.
void WMG::addFootstep | ( | const double | x_relative, |
const double | y_relative, | ||
const double | angle_relative, | ||
fs_type | type = FS_TYPE_AUTO |
||
) |
Adds a footstep to FS.
[in] | x_relative | x_relative X position [meter] relative to the previous footstep. |
[in] | y_relative | y_relative Y position [meter] relative to the previous footstep. |
[in] | angle_relative | angle_relative Angle [rad.] relative to the previous footstep. |
[in] | type | (optional) type of the footstep. |
void WMG::changeNextSSPosition | ( | const double * | posture, |
const bool | zero_z_coordinate | ||
) |
WMGret WMG::formPreviewWindow | ( | smpc_parameters & | par | ) |
void WMG::FS2file | ( | const std::string | filename, |
const bool | plot_ds = true |
||
) |
void WMG::getDSFeetPositions | ( | const int | support_number, |
double * | left_foot_pos, | ||
double * | right_foot_pos | ||
) | [private] |
Determine position and orientation of feet in DS.
[in] | support_number | number of the support |
[out] | left_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
[out] | right_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
Definition at line 90 of file WMG_private.cpp.
void WMG::getFeetPositions | ( | const unsigned int | shift_from_current_ms, |
double * | left_foot_pos, | ||
double * | right_foot_pos | ||
) |
Determine position and orientation of feet.
[in] | shift_from_current_ms | a positive shift in time (ms.) from the current time (allows to get positions for the future supports) |
[out] | left_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
[out] | right_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
void WMG::getFootsteps | ( | std::vector< double > & | x_coord, |
std::vector< double > & | y_coord, | ||
std::vector< double > & | angle_rot | ||
) |
int WMG::getNextSS | ( | const int | start_ind, |
const fs_type | type = FS_TYPE_AUTO |
||
) | [private] |
Returns index of the next SS.
[in] | start_ind | start search from this index. |
[in] | type | search for a footstep of certain type, by default (FS_TYPE_AUTO) both left and right are searched. |
Definition at line 23 of file WMG_private.cpp.
int WMG::getPrevSS | ( | const int | start_ind, |
const fs_type | type = FS_TYPE_AUTO |
||
) | [private] |
Returns index of the previous SS.
[in] | start_ind | start search from this index. |
[in] | type | search for a footstep of certain type, by default (FS_TYPE_AUTO) both left and right are searched. |
Definition at line 58 of file WMG_private.cpp.
void WMG::getSSFeetPositions | ( | const int | support_number, |
const double | theta, | ||
double * | left_foot_pos, | ||
double * | right_foot_pos | ||
) | [private] |
Determine position and orientation of feet (parabolic trajectory)
[in] | support_number | number of the support |
[in] | theta | a number between 0 and 1, a fraction of support time that have passed |
[out] | left_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
[out] | right_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
Definition at line 122 of file WMG_private.cpp.
void WMG::getSSFeetPositionsBezier | ( | const int | support_number, |
const double | theta, | ||
double * | left_foot_pos, | ||
double * | right_foot_pos | ||
) | [private] |
Determine position and orientation of feet (using cubic Bezier curves)
[in] | support_number | number of the support |
[in] | theta | a number between 0 and 1, a fraction of support time that have passed |
[out] | left_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
[out] | right_foot_pos | 4x4 homogeneous matrix, which represents position and orientation |
Definition at line 184 of file WMG_private.cpp.
bool WMG::isSupportSwitchNeeded | ( | ) |
void WMG::setFootstepDefaults | ( | const unsigned int | def_num_, |
const unsigned int | ds_num_, | ||
const double * | constraints = NULL |
||
) |
Set default parameters of footsteps.
[in] | def_num_ | default time in ms (for SS or DS depending on the type of added footstep) |
[in] | ds_num_ | number of DS to be generated automatically. |
[in] | constraints | Vector of the PoS constraints (assumed to be [4 x 1], can be NULL). |
void WMG::setFootstepDefaults | ( | const unsigned int | def_time_ms_, |
const unsigned int | ds_time_ms_, | ||
const unsigned int | ds_num_, | ||
const double * | constraints = NULL |
||
) |
Set default parameters of footsteps.
[in] | def_time_ms_ | default time in ms (for SS or DS depending on the type of added footstep) |
[in] | ds_time_ms_ | length of one automatically generated DS [ms.] |
[in] | ds_num_ | number of DS to be generated automatically. |
[in] | constraints | Vector of the PoS constraints (assumed to be [4 x 1], can be NULL). |
double WMG::addstep_constraint[4] [private] |
double WMG::bezier_inclination_1 |
The foot trajectories, that are build using Bezier curve have four control points (0,1,3,4). The first and the last points are defined by positions of adjacent steps of a foot on the floor. The 1 and 2 points are computed depending on the given parameters.
The step height is fixed in the middle (theta = 0.5) of the step, note, that this is not the geometrical middle.
The control points have weights, the weights of the first and the last points are always equal to 1.0. The weights of other two points can be given by the user.
The 1 and 2 points also have inclination, i.e. the shift along y axis (in the frame fixed in the step reference point). The values of inclinations are given in meters.
double WMG::bezier_inclination_2 |
The foot trajectories, that are build using Bezier curve have four control points (0,1,3,4). The first and the last points are defined by positions of adjacent steps of a foot on the floor. The 1 and 2 points are computed depending on the given parameters.
The step height is fixed in the middle (theta = 0.5) of the step, note, that this is not the geometrical middle.
The control points have weights, the weights of the first and the last points are always equal to 1.0. The weights of other two points can be given by the user.
The 1 and 2 points also have inclination, i.e. the shift along y axis (in the frame fixed in the step reference point). The values of inclinations are given in meters.
double WMG::bezier_weight_1 |
The foot trajectories, that are build using Bezier curve have four control points (0,1,3,4). The first and the last points are defined by positions of adjacent steps of a foot on the floor. The 1 and 2 points are computed depending on the given parameters.
The step height is fixed in the middle (theta = 0.5) of the step, note, that this is not the geometrical middle.
The control points have weights, the weights of the first and the last points are always equal to 1.0. The weights of other two points can be given by the user.
The 1 and 2 points also have inclination, i.e. the shift along y axis (in the frame fixed in the step reference point). The values of inclinations are given in meters.
double WMG::bezier_weight_2 |
The foot trajectories, that are build using Bezier curve have four control points (0,1,3,4). The first and the last points are defined by positions of adjacent steps of a foot on the floor. The 1 and 2 points are computed depending on the given parameters.
The step height is fixed in the middle (theta = 0.5) of the step, note, that this is not the geometrical middle.
The control points have weights, the weights of the first and the last points are always equal to 1.0. The weights of other two points can be given by the user.
The 1 and 2 points also have inclination, i.e. the shift along y axis (in the frame fixed in the step reference point). The values of inclinations are given in meters.
double WMG::def_auto_ds_constraint[4] |
double WMG::def_ss_constraint[4] |
unsigned int WMG::def_time_ms [private] |
unsigned int WMG::ds_num [private] |
unsigned int WMG::ds_time_ms [private] |
unsigned int WMG::last_time_decrement [private] |
unsigned int WMG::sampling_period |
double WMG::step_height |