Cheetah Software  1.0
JPosInitializer< T > Class Template Reference

#include <JPosInitializer.h>

+ Inheritance diagram for JPosInitializer< T >:
+ Collaboration diagram for JPosInitializer< T >:

Public Member Functions

 JPosInitializer (T end_time)
 
 ~JPosInitializer ()
 
bool IsInitialized (LegController< T > *)
 

Private Member Functions

void _UpdateParam ()
 
void _UpdateInitial (const LegController< T > *ctrl)
 

Private Attributes

bool _b_first_visit
 
_end_time
 
_curr_time
 
_dt
 
std::vector< T > _ini_jpos
 
std::vector< T > _target_jpos
 
std::vector< T > _mid_jpos
 
BS_Basic< T, cheetah::num_act_joint, 3, 1, 2, 2 > _jpos_trj
 

Detailed Description

template<typename T>
class JPosInitializer< T >

Definition at line 9 of file JPosInitializer.h.

Constructor & Destructor Documentation

template<typename T>
JPosInitializer< T >::JPosInitializer ( end_time)

Definition at line 7 of file JPosInitializer.cpp.

References JPosInitializer< T >::_UpdateParam().

8  : _b_first_visit(true),
9  _end_time(end_time),
10  _curr_time(0.),
11  _dt(0.001),
13  _UpdateParam();
14 }
std::vector< T > _ini_jpos
constexpr size_t num_act_joint
Definition: Quadruped.h:22

+ Here is the call graph for this function:

template<typename T >
JPosInitializer< T >::~JPosInitializer ( )

Definition at line 17 of file JPosInitializer.cpp.

17 {}

Member Function Documentation

template<typename T>
void JPosInitializer< T >::_UpdateInitial ( const LegController< T > *  ctrl)
private

Definition at line 48 of file JPosInitializer.cpp.

References JPosInitializer< T >::_end_time, JPosInitializer< T >::_ini_jpos, JPosInitializer< T >::_jpos_trj, JPosInitializer< T >::_mid_jpos, JPosInitializer< T >::_target_jpos, LegController< T >::datas, cheetah::num_act_joint, and BS_Basic< T, DIM, DEGREE, NUM_MIDDLE, CONST_LEVEL_INI, CONST_LEVEL_FIN >::SetParam().

48  {
49  T ini[3 * cheetah::num_act_joint];
50  T fin[3 * cheetah::num_act_joint];
51  T** mid = new T*[1];
52  mid[0] = new T[cheetah::num_act_joint];
53 
54  for (size_t i(cheetah::num_act_joint); i < 3 * cheetah::num_act_joint; ++i) {
55  ini[i] = 0.;
56  fin[i] = 0.;
57  }
58 
59  for (int leg(0); leg < 4; ++leg) {
60  for (int jidx(0); jidx < 3; ++jidx) {
61  ini[3 * leg + jidx] = ctrl->datas[leg].q[jidx];
62  _ini_jpos[3 * leg + jidx] = ctrl->datas[leg].q[jidx];
63  }
64  }
65 
66  for (size_t i(0); i < cheetah::num_act_joint; ++i) {
67  fin[i] = _target_jpos[i];
68  mid[0][i] = _mid_jpos[i];
69  }
70  _jpos_trj.SetParam(ini, fin, mid, _end_time);
71 
72  delete[] mid[0];
73  delete[] mid;
74 }
std::vector< T > _ini_jpos
BS_Basic< T, cheetah::num_act_joint, 3, 1, 2, 2 > _jpos_trj
constexpr size_t num_act_joint
Definition: Quadruped.h:22
LegControllerData< T > datas[4]
Definition: LegController.h:70
std::vector< T > _target_jpos
bool SetParam(T *init, T *fin, T **middle_pt, T fin_time)
Definition: BSplineBasic.h:63
std::vector< T > _mid_jpos

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void JPosInitializer< T >::_UpdateParam ( )
private

Definition at line 77 of file JPosInitializer.cpp.

References JPosInitializer< T >::_mid_jpos, and JPosInitializer< T >::_target_jpos.

77  {
78  ParamHandler handler(THIS_COM "config/initial_jpos_ctrl.yaml");
79  handler.getVector<T>("target_jpos", _target_jpos);
80  handler.getVector<T>("mid_jpos", _mid_jpos);
81 }
std::vector< T > _target_jpos
std::vector< T > _mid_jpos

+ Here is the caller graph for this function:

template<typename T>
bool JPosInitializer< T >::IsInitialized ( LegController< T > *  ctrl)

Definition at line 20 of file JPosInitializer.cpp.

References JPosInitializer< T >::_b_first_visit, JPosInitializer< T >::_curr_time, JPosInitializer< T >::_dt, JPosInitializer< T >::_end_time, JPosInitializer< T >::_jpos_trj, JPosInitializer< T >::_UpdateInitial(), LegController< T >::commands, BS_Basic< T, DIM, DEGREE, NUM_MIDDLE, CONST_LEVEL_INI, CONST_LEVEL_FIN >::getCurvePoint(), cheetah::num_act_joint, cheetah::num_leg, and cheetah::num_leg_joint.

20  {
21  _curr_time += _dt;
22  // Initial Setup
23  if (_b_first_visit) {
24  _UpdateInitial(ctrl);
25  _b_first_visit = false;
26  }
27 
28  // Smooth movement
29  if (_curr_time < _end_time) {
30  T jpos[cheetah::num_act_joint];
32 
33  // pretty_print(jpos, "jpos_cmd", cheetah::num_act_joint);
34 
35  for (size_t leg(0); leg < cheetah::num_leg; ++leg) {
36  for (size_t jidx(0); jidx < cheetah::num_leg_joint; ++jidx) {
37  ctrl->commands[leg].tauFeedForward[jidx] = 0.;
38  ctrl->commands[leg].qDes[jidx] = jpos[3 * leg + jidx];
39  ctrl->commands[leg].qdDes[jidx] = 0.;
40  }
41  }
42  return false;
43  }
44  return true;
45 }
BS_Basic< T, cheetah::num_act_joint, 3, 1, 2, 2 > _jpos_trj
constexpr size_t num_act_joint
Definition: Quadruped.h:22
constexpr size_t num_leg_joint
Definition: Quadruped.h:26
bool getCurvePoint(T u, T *ret)
Definition: BSplineBasic.h:78
void _UpdateInitial(const LegController< T > *ctrl)
constexpr size_t num_leg
Definition: Quadruped.h:25
LegControllerCommand< T > commands[4]
Definition: LegController.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

template<typename T>
bool JPosInitializer< T >::_b_first_visit
private

Definition at line 19 of file JPosInitializer.h.

template<typename T>
T JPosInitializer< T >::_curr_time
private

Definition at line 21 of file JPosInitializer.h.

template<typename T>
T JPosInitializer< T >::_dt
private

Definition at line 22 of file JPosInitializer.h.

template<typename T>
T JPosInitializer< T >::_end_time
private

Definition at line 20 of file JPosInitializer.h.

template<typename T>
std::vector<T> JPosInitializer< T >::_ini_jpos
private

Definition at line 24 of file JPosInitializer.h.

template<typename T>
BS_Basic<T, cheetah::num_act_joint, 3, 1, 2, 2> JPosInitializer< T >::_jpos_trj
private

Definition at line 28 of file JPosInitializer.h.

template<typename T>
std::vector<T> JPosInitializer< T >::_mid_jpos
private

Definition at line 26 of file JPosInitializer.h.

template<typename T>
std::vector<T> JPosInitializer< T >::_target_jpos
private

Definition at line 25 of file JPosInitializer.h.


The documentation for this class was generated from the following files: