tutrcos
読み取り中…
検索中…
一致する文字列を見つけられません
cybergear.hpp
[詳解]
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <cstring>
7
9#include "tutrcos/utility.hpp"
10
11#include "encoder_base.hpp"
12
13namespace tutrcos {
14namespace module {
15
24namespace {
25 #define CMD_POSITION 1
26 #define CMD_RESPONSE 2
27 #define CMD_ENABLE 3
28 #define CMD_RESET 4
29 #define CMD_SET_MECH_POSITION_TO_ZERO 6
30 #define CMD_CHANGE_CAN_ID 7
31 #define CMD_RAM_READ 17
32 #define CMD_RAM_WRITE 18
33 #define CMD_GET_MOTOR_FAIL 21
34
35 #define ADDR_RUN_MODE 0x7005
36 #define ADDR_IQ_REF 0x7006
37 #define ADDR_SPEED_REF 0x700A
38 #define ADDR_LIMIT_TORQUE 0x700B
39 #define ADDR_CURRENT_KP 0x7010
40 #define ADDR_CURRENT_KI 0x7011
41 #define ADDR_CURRENT_FILTER_GAIN 0x7014
42 #define ADDR_LOC_REF 0x7016
43 #define ADDR_LIMIT_SPEED 0x7017
44 #define ADDR_LIMIT_CURRENT 0x7018
45 #define ADDR_MECH_POS 0x7019
46 #define ADDR_IQF 0x701A
47 #define ADDR_MECH_VEL 0x701B
48 #define ADDR_VBUS 0x701C
49 #define ADDR_ROTATION 0x701D
50 #define ADDR_LOC_KP 0x701E
51 #define ADDR_SPD_KP 0x701F
52 #define ADDR_SPD_KI 0x7020
53
54 #define POS_MIN -12.5f
55 #define POS_MAX 12.5f
56 #define VEL_MIN -30.0f
57 #define VEL_MAX 30.0f
58 #define CUR_MIN -27.0f
59 #define CUR_MAX 27.0f
60 #define TOR_MIN -12.0f
61 #define TOR_MAX 12.0f
62
63 #define CURRENT_FILTER_GAIN_MIN 0.0f
64 #define CURRENT_FILTER_GAIN_MAX 1.0f
65
66 #define CUR_KP_MAX 200.0f
67 #define CUR_KP_MIN 0.0f
68 #define CUR_KI_MAX 200.0f
69 #define CUR_KI_MIN 0.0f
70
71 #define P_MIN -12.5f
72 #define P_MAX 12.5f
73 #define V_MIN -30.0f
74 #define V_MAX 30.0f
75
76 #define KP_MIN 0.0f
77 #define KP_MAX 500.0f
78 #define KD_MIN 0.0f
79 #define KD_MAX 5.0f
80
81 #define T_MIN -12.0f
82 #define T_MAX 12.0f
83 #define IQ_MIN -27.0f
84 #define IQ_MAX 27.0f
85 #define CURRENT_FILTER_GAIN_MIN 0.0f
86 #define CURRENT_FILTER_GAIN_MAX 1.0f
87
88 #define DEFAULT_CURRENT_KP 0.125f
89 #define DEFAULT_CURRENT_KI 0.0158f
90 #define DEFAULT_CURRENT_FINTER_GAIN 0.1f
91 #define DEFAULT_POSITION_KP 30.0f
92 #define DEFAULT_VELOCITY_KP 2.0f
93 #define DEFAULT_VELOCITY_KI 0.002f
94 #define DEFAULT_VELOCITY_LIMIT 2.0f
95 #define DEFAULT_CURRENT_LIMIT 27.0f
96 #define DEFAULT_TORQUE_LIMIT 12.0f
97
98 #define RET_CYBERGEAR_OK 0x00
99 #define RET_CYBERGEAR_MSG_NOT_AVAIL 0x01
100 #define RET_CYBERGEAR_INVALID_CAN_ID 0x02
101 #define RET_CYBERGEAR_INVALID_PACKET 0x03
102
103 #define CW 1
104 #define CCW -1
105}
106
107class Cybergear : public EncoderBase{
108public:
109 enum class MotorMode : uint8_t{
110 NONE = 0,
111 RAD = 1,
112 RADPS = 2,
113 CURRENT = 3,
114 };
115 typedef struct{
116 unsigned long stamp_usec; //< timestamp
117 uint8_t motor_id;
118 float position;
119 float velocity;
120 float effort;
122 uint16_t raw_position;
123 uint16_t raw_velocity;
124 uint16_t raw_effort;
126 } MotorStatus;
127
137
138 typedef struct {
139 unsigned long stamp_usec;
140 uint16_t run_mode;
141 float iq_ref;
142 float spd_ref;
144 float cur_kp;
145 float cur_ki;
147 float loc_ref;
150 float mech_pos;
151 float iqf;
152 float mech_vel;
153 float vbus;
154 int16_t rotation;
155 float loc_kp;
156 float spd_kp;
157 float spd_ki;
159
160 Cybergear(peripheral::CAN &can, uint8_t motor_id, uint8_t master_id)
161 : EncoderBase(1), can_{can, }, motor_id_{motor_id}, master_id_{master_id} {
162 reset();
164 enable();
165 }
166
167 virtual ~Cybergear(){}
168
169 bool update(){
170 return true;
171 }
172
173 void setCurrent(float value) {
174 // if(stop_flag) {
175 // setMotorMode(MotorMode::CURRENT);
176 // enable();
177 // }
178 enable();
179 setCurRef(value);
180 }
181
182 void stop() {
183 // setMode(MotorMode::NONE);
184 reset();
185 // setCurrent(0);
186 }
187
188 // void get_mech_position() { readRam(ADDR_MECH_POS); }
189
190 void readRam(uint16_t index) {
192 msg.data = {0};
193 std::array<uint8_t, 8U> data = {0x00};
194 data[0] = static_cast<uint8_t>(index);
195 data[1] = static_cast<uint8_t>(index >> 8);
196 // while(can_.receive(msg, 1));
197 // send(motor_id_, CMD_RAM_READ, master_id_, data);
198 // if(can_.receive(msg, 20)){
199 // process_receive_data(msg);
200 // } else {
201 // printf("timeout\r\n");
202 // }
203 send(motor_id_, CMD_RAM_READ, master_id_, data);
204 while(can_.receive(msg, 10)) {
205 // printf("id:%x / ", msg.id);
206 // printf("dlc:%d / ", msg.dlc);
207 // for(uint8_t d : msg.data) printf("%02x, ", d);
208 // printf("\n");
210 }
211 }
212
214 if(static_cast<uint16_t>(msg.id&0xffff) == static_cast<uint16_t>((motor_id_ << 8) | master_id_)){
215 uint8_t packet_type = (msg.id & 0x3F000000) >> 24;
216 switch(packet_type) {
217 case CMD_RESPONSE:
218 // process_motor_packet(msg.data);
219 // printf("response\r\n");
220 break;
221 case CMD_RAM_READ:
222 process_read_parameter_packet(msg.data);
223 break;
224 // case CMD_GET_MOTOR_FAIL:
225 // break;
226 default:
227 printf("invalid response 0x%x\r\n", packet_type);
228 break;
229 }
230 }
231 }
232
233 void enable(){
234 stop_flag = false;
235 send(motor_id_, CMD_ENABLE, master_id_, std::array<uint8_t, 8U>{0x00});
236 }
237
238 void reset(){
239 stop_flag = true;
240 send(motor_id_, CMD_RESET, master_id_, std::array<uint8_t, 8U>{0x00});
241 }
242
244 if(mode == MotorMode::NONE) return;
245 // uint8_t data[8] = {0x00};
246 std::array<uint8_t, 8U> data = {0x00};
247 data[0] = ADDR_RUN_MODE & 0x00FF;
248 data[1] = ADDR_RUN_MODE >> 8;
249 data[4] = utility::to_underlying(mode);
250 send(motor_id_, CMD_RAM_WRITE, master_id_, data);
251 }
252
253private:
254 void setPosRef(float value) { writeFloat(motor_id_, ADDR_LOC_REF, value, POS_MIN, POS_MAX); }
255 void setVelRef(float value) { writeFloat(motor_id_, ADDR_SPEED_REF, value, VEL_MIN, VEL_MAX); }
256 void setCurRef(float value) { writeFloat(motor_id_, ADDR_IQ_REF, value, CUR_MIN, CUR_MAX); }
257
258 bool transmit(peripheral::CANBase::IDType idtype, uint32_t id, const std::array<uint8_t, 8U> &data, uint32_t timeout){
259 peripheral::CANBase::Message msg;
260 msg.id_type = idtype;
261 msg.id = id;
262 msg.data = data;
263 msg.dlc = 8;
264 return can_.transmit(msg, timeout);
265 }
266
267 void process_motor_packet(const std::array<uint8_t, 8U> &data){
268 motor_status_.raw_position = data[1] | data[0] << 8;
269 motor_status_.raw_velocity = data[3] | data[2] << 8;
270 motor_status_.raw_effort = data[5] | data[4] << 8;
271 motor_status_.raw_temperature = data[7] | data[6] << 8;
272
273 // convert motor data
274 // motor_status_.stamp_usec = micros();
275 motor_status_.motor_id = motor_id_;
276 motor_status_.position = uint2float(motor_status_.raw_position, P_MIN, P_MAX);
277 motor_status_.velocity = uint2float(motor_status_.raw_velocity, V_MIN, V_MAX);
278 motor_status_.effort = uint2float(motor_status_.raw_effort, T_MIN, T_MAX);
279 motor_status_.temperature = motor_status_.raw_temperature;
280 }
281
282 void process_read_parameter_packet(const std::array<uint8_t, 8U> &data){
283 uint16_t index = data[1] << 8 | data[0];
284 uint8_t uint8_data;
285 memcpy(&uint8_data, &data[4], sizeof(uint8_t));
286 int16_t int16_data;
287 memcpy(&int16_data, &data[4], sizeof(int16_t));
288 float float_data;
289 memcpy(&float_data, &data[4], sizeof(float));
290
291 for(uint8_t d : data) printf("%02x, ", d);
292 printf("data : %02x, %04x, %f / ", uint8_data, (uint16_t)int16_data, float_data);
293 printf("\r\n");
294 return;
295
296 switch (index) {
297 case ADDR_RUN_MODE:
298 motor_param_.run_mode = uint8_data;
299 printf("ADDR_RUN_MODE = [0x%02x]\n", uint8_data);
300 break;
301 case ADDR_IQ_REF:
302 motor_param_.iq_ref = float_data;
303 printf("ADDR_IQ_REF = %f\r\n", float_data);
304 break;
305 case ADDR_SPEED_REF:
306 motor_param_.spd_ref = float_data;
307 printf("ADDR_SPEED_REF = %f\r\n", float_data);
308 break;
310 motor_param_.limit_torque = float_data;
311 printf("ADDR_LIMIT_TORQUE = %f\r\n", float_data);
312 break;
313 case ADDR_CURRENT_KP:
314 motor_param_.cur_kp = float_data;
315 printf("ADDR_CURRENT_KP = %f\r\n", float_data);
316 break;
317 case ADDR_CURRENT_KI:
318 motor_param_.cur_ki = float_data;
319 printf("ADDR_CURRENT_KI = %f\r\n", float_data);
320 break;
322 motor_param_.cur_filt_gain = float_data;
323 printf("ADDR_CURRENT_FILTER_GAIN = %f\r\n", float_data);
324 break;
325 case ADDR_LOC_REF:
326 motor_param_.loc_ref = float_data;
327 printf("ADDR_LOC_REF = %f\r\n", float_data);
328 break;
329 case ADDR_LIMIT_SPEED:
330 motor_param_.limit_spd = float_data;
331 printf("ADDR_LIMIT_SPEED = %f\r\n", float_data);
332 break;
334 motor_param_.limit_cur = float_data;
335 printf("ADDR_LIMIT_CURRENT = %f\r\n", float_data);
336 break;
337 case ADDR_MECH_POS:
338 motor_param_.mech_pos = float_data;
339 printf("ADDR_MECH_POS = %f\r\n", float_data);
340 break;
341 case ADDR_IQF:
342 motor_param_.iqf = float_data;
343 printf("ADDR_IQF = %f\r\n", float_data);
344 break;
345 case ADDR_MECH_VEL:
346 motor_param_.mech_vel = float_data;
347 printf("ADDR_MECH_VEL = %f\r\n", float_data);
348 break;
349 case ADDR_VBUS:
350 motor_param_.vbus = float_data;
351 printf("ADDR_VBUS = %f\r\n", float_data);
352 break;
353 case ADDR_ROTATION:
354 motor_param_.rotation = int16_data;
355 printf("ADDR_ROTATION = %d\r\n", int16_data);
356 break;
357 case ADDR_LOC_KP:
358 motor_param_.loc_kp = float_data;
359 printf("ADDR_LOC_KP = %f\r\n", float_data);
360 break;
361 case ADDR_SPD_KP:
362 motor_param_.spd_kp = float_data;
363 printf("ADDR_SPD_KP = %f\r\n", float_data);
364 break;
365 case ADDR_SPD_KI:
366 motor_param_.spd_ki = float_data;
367 printf("ADDR_SPD_KI = %f\r\n", float_data);
368 break;
369 default:
370 printf("Unknown index = 0x%04x\r\n", index);
371 // is_updated = false;
372 break;
373 }
374 // if (is_updated) {
375 // motor_param_.stamp_usec = micros();
376 // }
377 }
378
379 void send(uint8_t can_id, uint8_t cmd_id, uint16_t option, const std::array<uint8_t, 8U> &data){
380 uint32_t id = cmd_id << 24 | option << 8 | can_id;
381 transmit(peripheral::CANBase::IDType::EXTENDED, id, data, 1);
382 ++send_count_;
383 }
384
385 void writeFloat(uint8_t can_id, uint16_t addr, float value, float min, float max){
386 std::array<uint8_t, 8U> data = {0x00};
387 data[0] = addr & 0x00FF;
388 data[1] = addr >> 8;
389
390 union Val {
391 uint8_t data[4];
392 float f;
393 }val;
394 val.f = (max<value)? max : (min>value)? min : value;
395 data[4] = val.data[0];
396 data[5] = val.data[1];
397 data[6] = val.data[2];
398 data[7] = val.data[3];
399
400 send(can_id, CMD_RAM_WRITE, master_id_, data);
401 }
402
403 int float2unit(float x, float x_min, float x_max, int bits){
404 float span = x_max - x_min;
405 float offset = x_min;
406 x = std::clamp<float>(x, x_min, x_max);
407 return (int) ((x-offset)*((float)((1<<bits)-1))/span);
408 }
409
410 float uint2float(uint16_t x, float x_min, float x_max){
411 uint16_t type_max = 0xFFFF;
412 float span = x_max - x_min;
413 return (float) x / type_max * span + x_min;
414 }
415
416 // void setMechPos2Zero() {
417 // std::array<uint8_t, 8U> data = {0x00};
418 // data[0] = 0x01;
419 // send(motor_id_, CMD_SET_MECH_POSITION_TO_ZERO, master_id_, data);
420 // }
421
422 // void changeId(uint8_t can_id) {
423 // std::array<uint8_t, 8U> data = {0x00};
424 // uint16_t option = can_id << 8 | master_id_;
425 // send(motor_id_, CMD_CHANGE_CAN_ID, option, data);
426 // }
427
428 void processPacket(const std::array<uint8_t, 8U> &data){
429 motor_status_.raw_position = data[1] | data[0] << 8;
430 motor_status_.raw_velocity = data[3] | data[2] << 8;
431 motor_status_.raw_effort = data[5] | data[4] << 8;
432 motor_status_.raw_temperature = data[7] | data[6] << 8;
433
434 // convert motor data
435 // motor_status_.stamp_usec = micros();
436 motor_status_.motor_id = motor_id_;
437 motor_status_.position = uint2float(motor_status_.raw_position, POS_MIN, POS_MAX);
438 motor_status_.velocity = uint2float(motor_status_.raw_velocity, VEL_MIN, VEL_MAX);
439 motor_status_.effort = uint2float(motor_status_.raw_effort, TOR_MIN, TOR_MAX);
440 motor_status_.temperature = motor_status_.raw_temperature;
441 }
442
443 peripheral::CAN &can_;
444 MotorStatus motor_status_;
445 MotorParameter motor_param_;
446
447 const uint8_t motor_id_, master_id_;
448 uint8_t receive_buffer_[64];
449 unsigned long send_count_;
450 bool stop_flag = true;
451};
452
453// void set_limit_speed(float speed) { writeFloat(motor_id_, ADDR_LIMIT_SPEED, speed, 0.0f, VEL_MAX); }
454// void set_limit_current(float current) { writeFloat(motor_id_, ADDR_LIMIT_CURRENT, current, 0.0f, CUR_MAX); }
455// void set_current_kp(float kp) { writeFloat(motor_id_, ADDR_CURRENT_KP, kp, 0.0f, CUR_KP_MAX); }
456// void set_current_ki(float ki) { writeFloat(motor_id_, ADDR_CURRENT_KI, ki, 0.0f, CUR_KI_MAX); }
457// void set_current_filter_gain(float gain) { writeFloat(motor_id_, ADDR_CURRENT_FILTER_GAIN, gain, CURRENT_FILTER_GAIN_MIN, CURRENT_FILTER_GAIN_MAX); }
458// void set_limit_torque(float torque) { writeFloat(motor_id_, ADDR_LIMIT_TORQUE, torque, 0.0f, TOR_MAX); }
459// void set_position_kp(float kp) { writeFloat(motor_id_, ADDR_LOC_KP, kp, 0.0f, 200.0f); }
460// void set_velocity_kp(float kp) { writeFloat(motor_id_, ADDR_SPD_KP, kp, 0.0f, 200.0f); }
461// void set_velocity_ki(float ki) { writeFloat(motor_id_, ADDR_SPD_KI, ki, 0.0f, 200.0f); }
462// void get_mech_position() { readRam(ADDR_MECH_POS); }
463// void get_mech_velocity() { readRam(ADDR_MECH_VEL); }
464// void get_vbus() { readRam(ADDR_VBUS); }
465// void get_rotation() { readRam(ADDR_ROTATION); }
466
467// void motor_control(float position, float speed, float torque, float kp, float kd) {
468// std::array<uint8_t, 8U> data
469// data[0] = float2unit(position, POS_MIN, POS_MAX, 16) >> 8;
470// data[1] = float2unit(position, POS_MIN, POS_MAX, 16);
471// data[2] = float2unit(speed, VEL_MIN, VEL_MAX, 16) >> 8;
472// data[3] = float2unit(speed, VEL_MIN, VEL_MAX, 16);
473// data[4] = float2unit(kp, KP_MIN, KP_MAX, 16) >> 8;
474// data[5] = float2unit(kp, KP_MIN, KP_MAX, 16);
475// data[6] = float2unit(kd, KD_MIN, KD_MAX, 16) >> 8;
476// data[7] = float2unit(kd, KD_MIN, KD_MAX, 16);
477
478// uint16_t data_torque = float2unit(torque, TOR_MIN, TOR_MAX, 16);
479// send(motor_id_, CMD_POSITION, data_torque, data);
480// }
481
482// void dump_motor_param() {
483// const std::vector<uint16_t> index_array = {
484// ADDR_RUN_MODE,
485// ADDR_IQ_REF,
486// ADDR_SPEED_REF,
487// ADDR_LIMIT_TORQUE,
488// ADDR_CURRENT_KP,
489// ADDR_CURRENT_KI,
490// ADDR_CURRENT_FILTER_GAIN,
491// ADDR_LOC_REF,
492// ADDR_LIMIT_SPEED,
493// ADDR_LIMIT_CURRENT,
494// ADDR_MECH_POS,
495// ADDR_IQF,
496// ADDR_MECH_VEL,
497// ADDR_VBUS,
498// ADDR_ROTATION,
499// ADDR_LOC_KP,
500// ADDR_SPD_KP,
501// ADDR_SPD_KI
502// };
503
504// for (auto index : index_array){
505// read_ram_data(index);
506// // delay(1);
507// }
508// }
509// uint8_t getMode() const { return run_mode_; }
510
511// uint8_t getId() const { return motor_id_; }
512
513// bool process_packet() {
514// bool check_update = false;
515// while (true) {
516// if (receive_motor_data(motor_status_)) {
517// check_update = true;
518// } else {
519// break;
520// }
521// }
522// return check_update;
523// }
524
525// bool update_motor_status(unsigned long id, const uint8_t * data, unsigned long len){
526// uint8_t receive_can_id = id & 0xff;
527// if ( receive_can_id != master_id_ ) {
528// return false;
529// }
530// uint8_t motor_can_id = (id & 0xff00) >> 8;
531// if ( motor_can_id != motor_id_ ) {
532// return false;
533// }
534// // check packet type
535// uint8_t packet_type = (id & 0x3F000000) >> 24;
536// if (packet_type == CMD_RESPONSE) {
537// process_motor_packet(data, len);
538// } else if (packet_type == CMD_RAM_READ){
539// process_read_parameter_packet(data, len);
540// } else if (packet_type == CMD_GET_MOTOR_FAIL) {
541// // NOT IMPLEMENTED
542// } else {
543// printf("invalid command response [0x%x]\n", packet_type);
544// print_can_packet(id, data, len);
545// return false;
546// }
547// return true;
548// }
549
550// bool receive_motor_data(MotorStatus & mot) {
551// // receive data
552// unsigned long id;
553// uint8_t len;
554// if (!can_->read_message(id, receive_buffer_, len)) {
555// printf("received data is not available\r\n");
556// return false;
557// }
558// // if id is not mine
559// uint8_t receive_can_id = id & 0xff;
560// if ( receive_can_id != master_id_ ) {
561// printf("Invalid master can id. Expected=[0x%02x] Actual=[0x%02x] Raw=[%x]\r\n", master_id_, receive_can_id, id);
562// return false;
563// }
564// uint8_t motor_can_id = (id & 0xff00) >> 8;
565// if ( motor_can_id != motor_id_ ) {
566// printf("Invalid target can id. Expected=[0x%02x] Actual=[0x%02x] Raw=[%x]\r\n", motor_id_, motor_can_id, id);
567// return false;
568// }
569// // parse packet --------------
570// return update_motor_status(id, receive_buffer_, len);
571// }
572
573} // namespace module
574} // namespace tutrcos
Definition cybergear.hpp:107
void stop()
Definition cybergear.hpp:182
void readRam(uint16_t index)
Definition cybergear.hpp:190
void setCurrent(float value)
Definition cybergear.hpp:173
void process_receive_data(const peripheral::CANBase::Message &msg)
Definition cybergear.hpp:213
void enable()
Definition cybergear.hpp:233
virtual ~Cybergear()
Definition cybergear.hpp:167
bool update()
Definition cybergear.hpp:169
void setMotorMode(MotorMode mode)
Definition cybergear.hpp:243
MotorMode
Definition cybergear.hpp:109
void reset()
Definition cybergear.hpp:238
Cybergear(peripheral::CAN &can, uint8_t motor_id, uint8_t master_id)
Definition cybergear.hpp:160
Definition encoder_base.hpp:10
IDType
Definition can_base.hpp:12
Definition can.hpp:17
bool receive(Message &msg, uint32_t timeout) override
Definition can.hpp:86
bool transmit(const Message &msg, uint32_t timeout) override
Definition can.hpp:56
#define CMD_RAM_WRITE
Definition cybergear.hpp:32
#define CMD_RESPONSE
Definition cybergear.hpp:26
#define TOR_MIN
Definition cybergear.hpp:60
#define CMD_RAM_READ
Definition cybergear.hpp:31
#define T_MIN
Definition cybergear.hpp:81
#define ADDR_CURRENT_FILTER_GAIN
Definition cybergear.hpp:41
#define ADDR_CURRENT_KP
Definition cybergear.hpp:39
#define TOR_MAX
Definition cybergear.hpp:61
#define ADDR_LIMIT_TORQUE
Definition cybergear.hpp:38
#define ADDR_LOC_REF
Definition cybergear.hpp:42
#define ADDR_MECH_VEL
Definition cybergear.hpp:47
#define POS_MAX
Definition cybergear.hpp:55
#define ADDR_VBUS
Definition cybergear.hpp:48
#define POS_MIN
Definition cybergear.hpp:54
#define ADDR_SPD_KI
Definition cybergear.hpp:52
#define ADDR_IQ_REF
Definition cybergear.hpp:36
#define ADDR_IQF
Definition cybergear.hpp:46
#define ADDR_SPEED_REF
Definition cybergear.hpp:37
#define ADDR_LOC_KP
Definition cybergear.hpp:50
#define CUR_MAX
Definition cybergear.hpp:59
#define P_MAX
Definition cybergear.hpp:72
#define ADDR_LIMIT_CURRENT
Definition cybergear.hpp:44
#define ADDR_ROTATION
Definition cybergear.hpp:49
#define VEL_MAX
Definition cybergear.hpp:57
#define ADDR_LIMIT_SPEED
Definition cybergear.hpp:43
#define ADDR_MECH_POS
Definition cybergear.hpp:45
#define CMD_ENABLE
Definition cybergear.hpp:27
#define V_MAX
Definition cybergear.hpp:74
#define ADDR_RUN_MODE
Definition cybergear.hpp:35
#define VEL_MIN
Definition cybergear.hpp:56
#define T_MAX
Definition cybergear.hpp:82
#define V_MIN
Definition cybergear.hpp:73
#define CUR_MIN
Definition cybergear.hpp:58
#define P_MIN
Definition cybergear.hpp:71
#define ADDR_SPD_KP
Definition cybergear.hpp:51
#define ADDR_CURRENT_KI
Definition cybergear.hpp:40
#define CMD_RESET
Definition cybergear.hpp:28
constexpr std::underlying_type_t< T > to_underlying(T value) noexcept
Definition utility.hpp:23
Definition kernel.hpp:7
Definition cybergear.hpp:128
bool over_voltage
Definition cybergear.hpp:132
bool driver_chip
Definition cybergear.hpp:134
bool encoder_not_calibrated
Definition cybergear.hpp:129
bool over_current_phase_b
Definition cybergear.hpp:131
bool over_current_phase_a
Definition cybergear.hpp:130
bool under_voltage
Definition cybergear.hpp:133
bool motor_over_tempareture
Definition cybergear.hpp:135
Definition cybergear.hpp:138
float limit_spd
Definition cybergear.hpp:148
float vbus
Definition cybergear.hpp:153
float mech_vel
Definition cybergear.hpp:152
uint16_t run_mode
Definition cybergear.hpp:140
float spd_ki
Definition cybergear.hpp:157
float iqf
Definition cybergear.hpp:151
float limit_cur
Definition cybergear.hpp:149
unsigned long stamp_usec
Definition cybergear.hpp:139
float spd_ref
Definition cybergear.hpp:142
float cur_kp
Definition cybergear.hpp:144
float loc_ref
Definition cybergear.hpp:147
int16_t rotation
Definition cybergear.hpp:154
float spd_kp
Definition cybergear.hpp:156
float mech_pos
Definition cybergear.hpp:150
float loc_kp
Definition cybergear.hpp:155
float limit_torque
Definition cybergear.hpp:143
float cur_filt_gain
Definition cybergear.hpp:146
float cur_ki
Definition cybergear.hpp:145
float iq_ref
Definition cybergear.hpp:141
Definition cybergear.hpp:115
uint16_t raw_position
raw position (for sync data)
Definition cybergear.hpp:122
uint16_t raw_effort
raw effort (for sync data)
Definition cybergear.hpp:124
float position
encoder position (-4pi to 4pi)
Definition cybergear.hpp:118
uint8_t motor_id
motor id
Definition cybergear.hpp:117
float velocity
motor velocity (-30rad/s to 30rad/s)
Definition cybergear.hpp:119
unsigned long stamp_usec
Definition cybergear.hpp:116
uint16_t raw_velocity
raw velocity (for sync data)
Definition cybergear.hpp:123
float effort
motor effort (-12Nm - 12Nm)
Definition cybergear.hpp:120
uint16_t raw_temperature
raw temperature (for sync data)
Definition cybergear.hpp:125
float temperature
temperature
Definition cybergear.hpp:121
Definition can_base.hpp:17
uint32_t id
Definition can_base.hpp:19
std::array< uint8_t, 8 > data
Definition can_base.hpp:21