Cheetah Software  1.0
TI_BoardControl Class Reference

#include <ti_boardcontrol.h>

+ Collaboration diagram for TI_BoardControl:

Public Member Functions

 TI_BoardControl ()=default
 
void init (float side_sign)
 
void run_ti_board_iteration ()
 
void reset_ti_board_data ()
 
void reset_ti_board_command ()
 
void set_link_lengths (float l1, float l2, float l3)
 

Public Attributes

TiBoardCommand command
 
TiBoardData data_structure
 
TiBoardDatadata
 

Private Member Functions

void kinematics (const float side_sign, const float q[3], const float dq[3], float *p, float *v, float J[][3])
 
void impedanceControl (const float side_sign, const float q[3], const float dq[3], const float position_des[3], const float velocity_des[3], const float kp[3], const float kd[3], const float force_bias[3], const float torque_bias[3], float *position, float *velocity, float *force, float *torque)
 

Private Attributes

float _side_sign
 
float _l1
 
float _l2
 
float _l3
 
bool link_lengths_set = false
 

Detailed Description

Definition at line 33 of file ti_boardcontrol.h.

Constructor & Destructor Documentation

TI_BoardControl::TI_BoardControl ( )
default

Member Function Documentation

void TI_BoardControl::impedanceControl ( const float  side_sign,
const float  q[3],
const float  dq[3],
const float  position_des[3],
const float  velocity_des[3],
const float  kp[3],
const float  kd[3],
const float  force_bias[3],
const float  torque_bias[3],
float *  position,
float *  velocity,
float *  force,
float *  torque 
)
private

Definition at line 71 of file ti_boardcontrol.cpp.

References kinematics().

75  {
76  float Jacobian[3][3];
77  kinematics(side_sign, q, dq, position, velocity, Jacobian);
78 
79  force[0] = kp[0] * (position_des[0] - position[0]) +
80  kd[0] * (velocity_des[0] - velocity[0]) + force_bias[0];
81  force[1] = kp[1] * (position_des[1] - position[1]) +
82  kd[1] * (velocity_des[1] - velocity[1]) + force_bias[1];
83  force[2] = kp[2] * (position_des[2] - position[2]) +
84  kd[2] * (velocity_des[2] - velocity[2]) + force_bias[2];
85 
86  torque[0] = (force[0] * Jacobian[0][0] + force[1] * Jacobian[1][0] +
87  force[2] * Jacobian[2][0]) +
88  torque_bias[0];
89  torque[1] = (force[0] * Jacobian[0][1] + force[1] * Jacobian[1][1] +
90  force[2] * Jacobian[2][1]) +
91  torque_bias[1];
92  torque[2] = (force[0] * Jacobian[0][2] + force[1] * Jacobian[1][2] +
93  force[2] * Jacobian[2][2]) +
94  torque_bias[2];
95 }
void kinematics(const float side_sign, const float q[3], const float dq[3], float *p, float *v, float J[][3])

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TI_BoardControl::init ( float  side_sign)

Definition at line 7 of file ti_boardcontrol.cpp.

References _side_sign, data, and data_structure.

7  {
8  std::cout << "[Cheetah Control] Hello! I am the TI board with side sign: "
9  << side_sign << "\n";
10  this->_side_sign = side_sign;
12 }
TiBoardData * data
TiBoardData data_structure

+ Here is the caller graph for this function:

void TI_BoardControl::kinematics ( const float  side_sign,
const float  q[3],
const float  dq[3],
float *  p,
float *  v,
float  J[][3] 
)
private

Definition at line 97 of file ti_boardcontrol.cpp.

References _l1, _l2, and _l3.

99  {
100  // ti_flt l1 = 0.045;
101  // ti_flt l2 = .342;
102  // ti_flt l3 = .345;
103 
104  // if(get_cheetah() == 4)
105  // {
106  // l1 = .062;
107  // l2 = .209;
108  // l3 = .175;
109  // }
110 
111  const float s1 = sin(q[0]), s2 = sin(q[1]), s3 = sin(q[2]);
112  const float c1 = cos(q[0]), c2 = cos(q[1]), c3 = cos(q[2]);
113  const float c23 = c2 * c3 - s2 * s3;
114  const float s23 = s2 * c3 + c2 * s3;
115 
116  p[0] = _l3 * s23 + _l2 * s2;
117  p[1] = _l1 * side_sign * c1 + _l3 * (s1 * c23) + _l2 * c2 * s1;
118  p[2] = _l1 * side_sign * s1 - _l3 * (c1 * c23) - _l2 * c1 * c2;
119 
120  J[0][0] = 0;
121  J[0][1] = _l3 * c23 + _l2 * c2;
122  J[0][2] = _l3 * c23;
123  J[1][0] = _l3 * c1 * c23 + _l2 * c1 * c2 - _l1 * side_sign * s1;
124  J[1][1] = -_l3 * s1 * s23 - _l2 * s1 * s2;
125  J[1][2] = -_l3 * s1 * s23;
126  J[2][0] = _l3 * s1 * c23 + _l2 * c2 * s1 + _l1 * side_sign * c1;
127  J[2][1] = _l3 * c1 * s23 + _l2 * c1 * s2;
128  J[2][2] = _l3 * c1 * s23;
129 
130  v[0] = 0;
131  v[1] = 0;
132  v[2] = 0;
133  int i, j;
134  for (i = 0; i < 3; i++) {
135  for (j = 0; j < 3; j++) {
136  v[i] += J[i][j] * dq[j];
137  }
138  }
139 }

+ Here is the caller graph for this function:

void TI_BoardControl::reset_ti_board_command ( )

Definition at line 28 of file ti_boardcontrol.cpp.

References command, data_structure, TiBoardCommand::kd, TiBoardCommand::kp, TiBoardCommand::position_des, TiBoardData::tau_des, and TiBoardCommand::velocity_des.

28  {
29  command.position_des[0] = 0;
30  command.position_des[1] = 0;
31  command.position_des[2] = 0;
32 
33  std::fill_n(command.velocity_des, 3, 0);
34  std::fill_n(command.kp, 3, 0);
35  std::fill_n(command.kd, 3, 0);
36  std::fill_n(data_structure.tau_des, 3, 0);
37 }
float tau_des[3]
float velocity_des[3]
TiBoardData data_structure
TiBoardCommand command
float position_des[3]

+ Here is the caller graph for this function:

void TI_BoardControl::reset_ti_board_data ( )

Definition at line 21 of file ti_boardcontrol.cpp.

References data_structure, TiBoardData::ethercat_count_ti, TiBoardData::loop_count_ti, TiBoardData::microtime_ti, and TiBoardData::tau_des.

21  {
22  std::fill_n(data_structure.tau_des, 3, 0);
26 }
float tau_des[3]
TiBoardData data_structure

+ Here is the caller graph for this function:

void TI_BoardControl::run_ti_board_iteration ( )

Definition at line 39 of file ti_boardcontrol.cpp.

References _side_sign, command, data, TiBoardData::dq, TiBoardCommand::enable, TiBoardData::force, TiBoardCommand::force_ff, impedanceControl(), TiBoardCommand::kd, kinematics(), TiBoardCommand::kp, link_lengths_set, TiBoardData::loop_count_ti, TiBoardCommand::max_torque, TiBoardData::position, TiBoardCommand::position_des, TiBoardData::q, TiBoardData::tau_des, TiBoardCommand::tau_ff, TiBoardData::velocity, and TiBoardCommand::velocity_des.

39  {
40  if (!link_lengths_set) {
41  std::cout << "[TI Board] Error. Link lengths haven't been set.\n";
42  return;
43  }
44 
45  if (command.enable == 1 && command.max_torque > 1e-9) {
50 
51  for (int i = 0; i < 3; ++i) {
52  if (std::abs(data->tau_des[i]) > command.max_torque) {
53  data->tau_des[i] =
54  data->tau_des[i] / std::abs(data->tau_des[i]) * command.max_torque;
55  }
56  }
57  } else {
58  float Jacobian[3][3];
60  Jacobian);
61  data->force[0] = 0;
62  data->force[1] = 0;
63  data->force[2] = 0;
64  data->tau_des[0] = 0;
65  data->tau_des[1] = 0;
66  data->tau_des[2] = 0;
67  }
68  data->loop_count_ti += 1;
69 }
float tau_des[3]
void impedanceControl(const float side_sign, const float q[3], const float dq[3], const float position_des[3], const float velocity_des[3], const float kp[3], const float kd[3], const float force_bias[3], const float torque_bias[3], float *position, float *velocity, float *force, float *torque)
float velocity_des[3]
TiBoardData * data
float velocity[3]
float position[3]
TiBoardCommand command
void kinematics(const float side_sign, const float q[3], const float dq[3], float *p, float *v, float J[][3])
float force[3]
float position_des[3]

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TI_BoardControl::set_link_lengths ( float  l1,
float  l2,
float  l3 
)

Definition at line 14 of file ti_boardcontrol.cpp.

References _l1, _l2, _l3, and link_lengths_set.

14  {
15  link_lengths_set = true;
16  this->_l1 = l1;
17  this->_l2 = l2;
18  this->_l3 = l3;
19 }

+ Here is the caller graph for this function:

Member Data Documentation

float TI_BoardControl::_l1
private

Definition at line 58 of file ti_boardcontrol.h.

float TI_BoardControl::_l2
private

Definition at line 58 of file ti_boardcontrol.h.

float TI_BoardControl::_l3
private

Definition at line 58 of file ti_boardcontrol.h.

float TI_BoardControl::_side_sign
private

Definition at line 57 of file ti_boardcontrol.h.

TiBoardCommand TI_BoardControl::command

Definition at line 41 of file ti_boardcontrol.h.

TiBoardData* TI_BoardControl::data

Definition at line 45 of file ti_boardcontrol.h.

TiBoardData TI_BoardControl::data_structure

Definition at line 42 of file ti_boardcontrol.h.

bool TI_BoardControl::link_lengths_set = false
private

Definition at line 59 of file ti_boardcontrol.h.


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