Cheetah Software  1.0
SpineBoard Class Reference

#include <SpineBoard.h>

+ Collaboration diagram for SpineBoard:

Public Member Functions

 SpineBoard ()
 
void init (float side_sign, s32 board)
 
void run ()
 
void resetData ()
 
void resetCommand ()
 

Public Attributes

SpiCommandcmd = nullptr
 
SpiDatadata = nullptr
 
float torque_out [3]
 

Private Attributes

float side_sign
 
s32 board_num
 
const float max_torque [3] = {17.f, 17.f, 26.f}
 
const float wimp_torque [3] = {6.f, 6.f, 6.f}
 
const float disabled_torque [3] = {0.f, 0.f, 0.f}
 
const float q_limit_p [3] = {1.5f, 5.0f, 0.f}
 
const float q_limit_n [3] = {-1.5f, -5.0f, 0.f}
 
const float kp_softstop = 100.f
 
const float kd_softstop = 0.4f
 
s32 iter_counter = 0
 

Detailed Description

Definition at line 45 of file SpineBoard.h.

Constructor & Destructor Documentation

SpineBoard::SpineBoard ( )
inline

Definition at line 47 of file SpineBoard.h.

47 {}

Member Function Documentation

void SpineBoard::init ( float  side_sign,
s32  board 
)

Definition at line 8 of file SpineBoard.cpp.

References board_num, and side_sign.

8  {
9  printf(
10  "[Cheetah Control] Hello! I am the SPINE board for leg %d (0-indexed) "
11  "with side sign %.3f\n",
12  board, sideSign);
13  this->board_num = board;
14  this->side_sign = sideSign;
15 }
s32 board_num
Definition: SpineBoard.h:58
float side_sign
Definition: SpineBoard.h:57

+ Here is the caller graph for this function:

void SpineBoard::resetCommand ( )

Definition at line 35 of file SpineBoard.cpp.

References board_num, cmd, SpiCommand::flags, SpiCommand::kd_abad, SpiCommand::kd_hip, SpiCommand::kd_knee, SpiCommand::kp_abad, SpiCommand::kp_hip, SpiCommand::kp_knee, SpiCommand::q_des_abad, SpiCommand::q_des_hip, SpiCommand::q_des_knee, SpiCommand::qd_des_abad, SpiCommand::qd_des_hip, SpiCommand::qd_des_knee, SpiCommand::tau_abad_ff, SpiCommand::tau_hip_ff, and SpiCommand::tau_knee_ff.

35  {
36  if (cmd == nullptr) {
37  printf(
38  "[ERROR: SPINE board] reset_spine_board_command called when "
39  "cheetahlcm_spi_command_t* was null\n");
40  return;
41  }
42 
43  cmd->flags[board_num] = 0;
44  cmd->kd_abad[board_num] = 0.f;
45  cmd->kd_hip[board_num] = 0.f;
46  cmd->kd_knee[board_num] = 0.f;
47  cmd->kp_abad[board_num] = 0.f;
48  cmd->kp_hip[board_num] = 0.f;
49  cmd->kp_knee[board_num] = 0.f;
50  cmd->qd_des_abad[board_num] = 0.f;
51  cmd->qd_des_hip[board_num] = 0.f;
52  cmd->qd_des_knee[board_num] = 0.f;
53  cmd->q_des_abad[board_num] = 0.f;
54  cmd->q_des_hip[board_num] = 0.f;
55  cmd->q_des_knee[board_num] = 0.f;
56  cmd->tau_abad_ff[board_num] = 0.f;
57  cmd->tau_hip_ff[board_num] = 0.f;
58  cmd->tau_hip_ff[board_num] = 0.f;
59  cmd->tau_knee_ff[board_num] = 0.f;
60 }
SpiCommand * cmd
Definition: SpineBoard.h:52
float qd_des_knee[4]
Definition: SpineBoard.h:17
float tau_abad_ff[4]
Definition: SpineBoard.h:27
float kd_hip[4]
Definition: SpineBoard.h:24
float kd_knee[4]
Definition: SpineBoard.h:25
float q_des_knee[4]
Definition: SpineBoard.h:13
float kd_abad[4]
Definition: SpineBoard.h:23
s32 board_num
Definition: SpineBoard.h:58
float tau_knee_ff[4]
Definition: SpineBoard.h:29
float q_des_abad[4]
Definition: SpineBoard.h:11
float kp_knee[4]
Definition: SpineBoard.h:21
float q_des_hip[4]
Definition: SpineBoard.h:12
float qd_des_hip[4]
Definition: SpineBoard.h:16
int32_t flags[4]
Definition: SpineBoard.h:31
float kp_abad[4]
Definition: SpineBoard.h:19
float kp_hip[4]
Definition: SpineBoard.h:20
float tau_hip_ff[4]
Definition: SpineBoard.h:28
float qd_des_abad[4]
Definition: SpineBoard.h:15

+ Here is the caller graph for this function:

void SpineBoard::resetData ( )

Definition at line 17 of file SpineBoard.cpp.

References board_num, data, SpiData::flags, SpiData::q_abad, SpiData::q_hip, SpiData::q_knee, SpiData::qd_abad, SpiData::qd_hip, SpiData::qd_knee, and SpiData::spi_driver_status.

17  {
18  if (data == nullptr) {
19  printf(
20  "[ERROR: SPINE board] reset_spine_board_data called when "
21  "cheetahlcm_spi_data_t* was null\n");
22  return;
23  }
24 
25  data->flags[board_num] = 0;
26  data->qd_abad[board_num] = 0.f;
27  data->qd_hip[board_num] = 0.f;
28  data->qd_knee[board_num] = 0.f;
29  data->q_abad[board_num] = 0.f;
30  data->q_hip[board_num] = 0.f;
31  data->q_knee[board_num] = 0.f;
33 }
float q_knee[4]
Definition: SpineBoard.h:37
int32_t spi_driver_status
Definition: SpineBoard.h:42
float q_hip[4]
Definition: SpineBoard.h:36
s32 board_num
Definition: SpineBoard.h:58
SpiData * data
Definition: SpineBoard.h:53
float q_abad[4]
Definition: SpineBoard.h:35
float qd_abad[4]
Definition: SpineBoard.h:38
int32_t flags[4]
Definition: SpineBoard.h:41
float qd_hip[4]
Definition: SpineBoard.h:39
float qd_knee[4]
Definition: SpineBoard.h:40

+ Here is the caller graph for this function:

void SpineBoard::run ( )

Check abad softstop ///

Check hip softstop ///

No knee softstop right now ///

Definition at line 62 of file SpineBoard.cpp.

References board_num, cmd, data, disabled_torque, SpiCommand::flags, iter_counter, SpiCommand::kd_abad, SpiCommand::kd_hip, SpiCommand::kd_knee, kd_softstop, SpiCommand::kp_abad, SpiCommand::kp_hip, SpiCommand::kp_knee, kp_softstop, max_torque, SpiData::q_abad, SpiCommand::q_des_abad, SpiCommand::q_des_hip, SpiCommand::q_des_knee, SpiData::q_hip, SpiData::q_knee, q_limit_n, q_limit_p, SpiData::qd_abad, SpiCommand::qd_des_abad, SpiCommand::qd_des_hip, SpiCommand::qd_des_knee, SpiData::qd_hip, SpiData::qd_knee, SpiCommand::tau_abad_ff, SpiCommand::tau_hip_ff, SpiCommand::tau_knee_ff, torque_out, and wimp_torque.

62  {
63  iter_counter++;
64  if (cmd == nullptr || data == nullptr) {
65  printf(
66  "[ERROR: SPINE board] run_spine_board_iteration called with null "
67  "command or data!\n");
68  torque_out[0] = 0.f;
69  torque_out[1] = 0.f;
70  torque_out[2] = 0.f;
71  return;
72  }
73 
75  if (data->q_abad[board_num] > q_limit_p[0]) {
79  } else if (data->q_abad[board_num] < q_limit_n[0]) {
83  } else {
89  }
90 
92  if (data->q_hip[board_num] > q_limit_p[1]) {
96  } else if (data->q_hip[board_num] < q_limit_n[1]) {
100  } else {
101  torque_out[1] = cmd->kp_hip[board_num] *
103  cmd->kd_hip[board_num] *
106  }
107 
111  cmd->kd_knee[board_num] *
114 
115  const float* torque_limits = disabled_torque;
116 
117  if (cmd->flags[board_num] & 0b1) {
118  if (cmd->flags[board_num] & 0b10)
119  torque_limits = wimp_torque;
120  else
121  torque_limits = max_torque;
122  }
123 
124  for (int i = 0; i < 3; i++) {
125  if (torque_out[i] > torque_limits[i]) torque_out[i] = torque_limits[i];
126  if (torque_out[i] < -torque_limits[i]) torque_out[i] = -torque_limits[i];
127  }
128 
129  // if(! (iter_counter % 100))
130  // {
131  // printf("SPINE BOARD %d: flags: 0x%hx, torque out: %.3f %.3f %.3f\n",
132  // board_num, cmd->flags[board_num],
133  // torque_out[0], torque_out[1], torque_out[2]);
134  // }
135 }
float q_knee[4]
Definition: SpineBoard.h:37
const float q_limit_n[3]
Definition: SpineBoard.h:63
SpiCommand * cmd
Definition: SpineBoard.h:52
float qd_des_knee[4]
Definition: SpineBoard.h:17
const float q_limit_p[3]
Definition: SpineBoard.h:62
const float max_torque[3]
Definition: SpineBoard.h:59
float tau_abad_ff[4]
Definition: SpineBoard.h:27
float kd_hip[4]
Definition: SpineBoard.h:24
float kd_knee[4]
Definition: SpineBoard.h:25
float q_hip[4]
Definition: SpineBoard.h:36
float q_des_knee[4]
Definition: SpineBoard.h:13
float kd_abad[4]
Definition: SpineBoard.h:23
s32 board_num
Definition: SpineBoard.h:58
float tau_knee_ff[4]
Definition: SpineBoard.h:29
float q_des_abad[4]
Definition: SpineBoard.h:11
float kp_knee[4]
Definition: SpineBoard.h:21
float q_des_hip[4]
Definition: SpineBoard.h:12
float qd_des_hip[4]
Definition: SpineBoard.h:16
int32_t flags[4]
Definition: SpineBoard.h:31
SpiData * data
Definition: SpineBoard.h:53
float kp_abad[4]
Definition: SpineBoard.h:19
float kp_hip[4]
Definition: SpineBoard.h:20
float q_abad[4]
Definition: SpineBoard.h:35
float torque_out[3]
Definition: SpineBoard.h:54
float qd_abad[4]
Definition: SpineBoard.h:38
float tau_hip_ff[4]
Definition: SpineBoard.h:28
const float disabled_torque[3]
Definition: SpineBoard.h:61
const float kp_softstop
Definition: SpineBoard.h:64
const float kd_softstop
Definition: SpineBoard.h:65
float qd_des_abad[4]
Definition: SpineBoard.h:15
const float wimp_torque[3]
Definition: SpineBoard.h:60
s32 iter_counter
Definition: SpineBoard.h:66
float qd_hip[4]
Definition: SpineBoard.h:39
float qd_knee[4]
Definition: SpineBoard.h:40

Member Data Documentation

s32 SpineBoard::board_num
private

Definition at line 58 of file SpineBoard.h.

SpiCommand* SpineBoard::cmd = nullptr

Definition at line 52 of file SpineBoard.h.

SpiData* SpineBoard::data = nullptr

Definition at line 53 of file SpineBoard.h.

const float SpineBoard::disabled_torque[3] = {0.f, 0.f, 0.f}
private

Definition at line 61 of file SpineBoard.h.

s32 SpineBoard::iter_counter = 0
private

Definition at line 66 of file SpineBoard.h.

const float SpineBoard::kd_softstop = 0.4f
private

Definition at line 65 of file SpineBoard.h.

const float SpineBoard::kp_softstop = 100.f
private

Definition at line 64 of file SpineBoard.h.

const float SpineBoard::max_torque[3] = {17.f, 17.f, 26.f}
private

Definition at line 59 of file SpineBoard.h.

const float SpineBoard::q_limit_n[3] = {-1.5f, -5.0f, 0.f}
private

Definition at line 63 of file SpineBoard.h.

const float SpineBoard::q_limit_p[3] = {1.5f, 5.0f, 0.f}
private

Definition at line 62 of file SpineBoard.h.

float SpineBoard::side_sign
private

Definition at line 57 of file SpineBoard.h.

float SpineBoard::torque_out[3]

Definition at line 54 of file SpineBoard.h.

const float SpineBoard::wimp_torque[3] = {6.f, 6.f, 6.f}
private

Definition at line 60 of file SpineBoard.h.


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