8 std::cout <<
"[Cheetah Control] Hello! I am the TI board with side sign: " 41 std::cout <<
"[TI Board] Error. Link lengths haven't been set.\n";
51 for (
int i = 0; i < 3; ++i) {
72 const float side_sign,
const float q[3],
const float dq[3],
73 const float position_des[3],
const float velocity_des[3],
const float kp[3],
74 const float kd[3],
const float force_bias[3],
const float torque_bias[3],
75 float *position,
float *velocity,
float *force,
float *torque) {
77 kinematics(side_sign, q, dq, position, velocity, Jacobian);
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];
86 torque[0] = (force[0] * Jacobian[0][0] + force[1] * Jacobian[1][0] +
87 force[2] * Jacobian[2][0]) +
89 torque[1] = (force[0] * Jacobian[0][1] + force[1] * Jacobian[1][1] +
90 force[2] * Jacobian[2][1]) +
92 torque[2] = (force[0] * Jacobian[0][2] + force[1] * Jacobian[1][2] +
93 force[2] * Jacobian[2][2]) +
98 const float dq[3],
float *p,
float *v,
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;
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;
121 J[0][1] =
_l3 * c23 +
_l2 * c2;
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;
134 for (i = 0; i < 3; i++) {
135 for (j = 0; j < 3; j++) {
136 v[i] += J[i][j] * dq[j];
void reset_ti_board_data()
void set_link_lengths(float l1, float l2, float l3)
void reset_ti_board_command()
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)
void init(float side_sign)
TiBoardData data_structure
void run_ti_board_iteration()
void kinematics(const float side_sign, const float q[3], const float dq[3], float *p, float *v, float J[][3])