26 unsigned char *data_fp = &rx_data[4];
28 if (sizeof_data < 87) {
return -1; }
34 mode_ = data_fp[4] >> 4;
45 printf(
"runing = %d\n",
runing_);
46 printf(
"mode = %d\n",
mode_);
47 printf(
"cmdnum = %d\n",
cmdnum_);
67 memset(tcp_offset_, 0,
sizeof(tcp_offset_));
68 memset(tcp_load_, 0,
sizeof(tcp_load_));
77 unsigned char *data_fp = &rx_data[4];
79 if (sizeof_data < 133) {
80 printf(
"sizeof_data = %d\n", sizeof_data);
87 printf(
"total_num=%d, sizeof_data=%d\n",
total_num_, sizeof_data);
92 mode_ = data_fp[4] >> 4;
98 mt_brake_ = data_fp[87];
99 mt_able_ = data_fp[88];
106 collis_sens_ = data_fp[131];
107 teach_sens_ = data_fp[132];
115 printf(
"runing = %d\n",
runing_);
116 printf(
"mode = %d\n",
mode_);
117 printf(
"cmdnum = %d\n",
cmdnum_);
123 printf(
"mode = %d\n",
mode_);
124 printf(
"mt_brake= %x\n", mt_brake_);
125 printf(
"mt_able = %x\n", mt_able_);
126 printf(
"err&war = %d %d\n", err_, war_);
129 printf(
"coll_sen= %d\n", collis_sens_);
130 printf(
"teac_sen= %d\n", teach_sens_);
148 memset(tcp_offset_, 0,
sizeof(tcp_offset_));
149 memset(tcp_load_, 0,
sizeof(tcp_load_));
159 unsigned char *data_fp = &rx_data[4];
161 if (sizeof_data < 233) {
162 printf(
"sizeof_data = %d\n", sizeof_data);
170 mode_ = data_fp[4] >> 4;
176 mt_brake_ = data_fp[87];
177 mt_able_ = data_fp[88];
182 collis_sens_ = data_fp[131];
183 teach_sens_ = data_fp[132];
186 arm_type_ = data_fp[145];
187 axis_num_ = data_fp[146];
188 master_id_ = data_fp[147];
189 slave_id_ = data_fp[148];
190 motor_tid_ = data_fp[149];
191 motor_fid_ = data_fp[150];
192 memcpy(versions_, &data_fp[151], 30);
195 trs_jerk_ = trs_msg_[0];
196 trs_accmin_ = trs_msg_[1];
197 trs_accmax_ = trs_msg_[2];
198 trs_velomin_ = trs_msg_[3];
199 trs_velomax_ = trs_msg_[4];
202 p2p_jerk_ = p2p_msg_[0];
203 p2p_accmin_ = p2p_msg_[1];
204 p2p_accmax_ = p2p_msg_[2];
205 p2p_velomin_ = p2p_msg_[3];
206 p2p_velomax_ = p2p_msg_[4];
209 rot_jerk_ = rot_msg_[0];
210 rot_accmax_ = rot_msg_[1];
212 for (
int i = 0; i < 17; i++) { sv3msg_[i] = data_fp[229 + i]; }
218 printf(
"versions= %s\n", versions_);
220 printf(
"runing = %d\n",
runing_);
221 printf(
"mode = %d\n",
mode_);
222 printf(
"cmdnum = %d\n",
cmdnum_);
227 printf(
"mode = %d\n",
mode_);
228 printf(
"mt_brake= %x\n", mt_brake_);
229 printf(
"mt_able = %x\n", mt_able_);
230 printf(
"err&war = %d %d\n", err_, war_);
233 printf(
"coll_sen= %d\n", collis_sens_);
234 printf(
"teac_sen= %d\n", teach_sens_);
237 printf(
"xarm_type = %d(axis%d)\n", arm_type_, axis_num_);
238 printf(
"xarm_msid = 0x%X 0x%X\n", master_id_, slave_id_);
239 printf(
"motor_tfid = 0x%X 0x%X\n", motor_tid_, motor_fid_);
245 printf(
"ID 执行状态 错误代码\n");
246 for (
int i = 0; i < 8; i++) {
247 printf(
"%d %d 0x%X\n", i + 1, sv3msg_[i * 2],
256 report_type = report_type_;
262 memset(angle, 0,
sizeof(angle));
263 memset(pose, 0,
sizeof(pose));
264 memset(tau, 0,
sizeof(tau));
271 memset(tcp_offset, 0,
sizeof(tcp_offset));
272 memset(tcp_load, 0,
sizeof(tcp_load));
275 memset(gravity_dir, 0,
sizeof(gravity_dir));
284 memset(versions, 0,
sizeof(versions));
297 memset(sv3msg_, 0,
sizeof(sv3msg_));
298 memset(trs_msg_, 0,
sizeof(trs_msg_));
299 memset(p2p_msg_, 0,
sizeof(p2p_msg_));
300 memset(rot_msg_, 0,
sizeof(rot_msg_));
302 memset(temperatures, 0,
sizeof(temperatures));
304 memset(rt_joint_spds, 0,
sizeof(rt_joint_spds));
306 memset(world_offset, 0,
sizeof(world_offset));
307 memset(gpio_reset_conf, 0,
sizeof(gpio_reset_conf));
309 collision_detection = 0;
310 collision_tool_type = 0;
311 memset(collision_model_params, 0,
sizeof(collision_model_params));
312 memset(voltages, 0,
sizeof(voltages));
313 memset(currents, 0,
sizeof(currents));
317 memset(cgpio_input_digitals, 0,
sizeof(cgpio_input_digitals));
318 memset(cgpio_output_digitals, 0,
sizeof(cgpio_output_digitals));
319 memset(cgpio_input_analogs, 0,
sizeof(cgpio_input_analogs));
320 memset(cgpio_output_analogs, 0,
sizeof(cgpio_output_analogs));
321 memset(cgpio_input_conf, 0,
sizeof(cgpio_input_conf));
322 memset(cgpio_output_conf, 0,
sizeof(cgpio_output_conf));
330 if (sizeof_data < 87) {
333 data_fp = &rx_data[4];
336 if (total_num < 87)
return -1;
337 state = data_fp[4] & 0x0F;
338 mode = data_fp[4] >> 4;
347 printf(
"total = %d\n", total_num);
348 printf(
"state = %d, mode = %d, cmdnum = %d\n", state, mode, cmdnum);
355 int ret = __flush_common_data(rx_data);
360 __print_common_data();
365 int ret = __flush_common_data(rx_data);
366 if (total_num < 133 || ret != 0)
return -1;
367 mt_brake = data_fp[87];
368 mt_able = data_fp[88];
373 collis_sens = data_fp[131];
374 teach_sens = data_fp[132];
380 __print_common_data();
381 printf(
"mt_brake = 0x%X, mt_able = 0x%X\n", mt_brake, mt_able);
382 printf(
"error = %d, warn = %d\n", err, war);
383 printf(
"coll_sen = %d, teach_sen = %d\n", collis_sens, teach_sens);
391 int ret = _flush_normal_data(rx_data);
392 if (total_num < 245 || ret != 0)
return -1;
393 arm_type = data_fp[145];
394 axis_num = data_fp[146];
395 master_id = data_fp[147];
396 slave_id = data_fp[148];
397 motor_tid = data_fp[149];
398 motor_fid = data_fp[150];
399 memcpy(versions, &data_fp[151], 30);
402 trs_jerk = trs_msg_[0];
403 trs_accmin = trs_msg_[1];
404 trs_accmax = trs_msg_[2];
405 trs_velomin = trs_msg_[3];
406 trs_velomax = trs_msg_[4];
409 p2p_jerk = p2p_msg_[0];
410 p2p_accmin = p2p_msg_[1];
411 p2p_accmax = p2p_msg_[2];
412 p2p_velomin = p2p_msg_[3];
413 p2p_velomax = p2p_msg_[4];
416 rot_jerk = rot_msg_[0];
417 rot_accmax = rot_msg_[1];
419 for (
int i = 0; i < 17; i++) { sv3msg_[i] = data_fp[229 + i]; }
421 if (total_num >= 252) {
422 for (
int i = 0; i < 17; i++) { temperatures[i] = data_fp[245 + i]; }
424 if (total_num >= 284) {
427 rt_tcp_spd = tcp_spd[0];
430 if (total_num >= 288) {
433 if (total_num >= 312) {
436 if (total_num >= 314) {
437 gpio_reset_conf[0] = data_fp[312];
438 gpio_reset_conf[1] = data_fp[313];
440 if (total_num >= 417) {
441 simulation_mode = data_fp[314];
442 collision_detection = data_fp[315];
443 collision_tool_type = data_fp[316];
445 for (
int i = 0; i < 7; i++) { voltages[i] = (float)
bin8_to_16(&data_fp[341 + 2 * i]) / 100; }
448 cgpio_state = data_fp[383];
449 cgpio_code = data_fp[384];
450 cgpio_input_digitals[0] =
bin8_to_16(&data_fp[385]);
451 cgpio_input_digitals[1] =
bin8_to_16(&data_fp[387]);
452 cgpio_output_digitals[0] =
bin8_to_16(&data_fp[389]);
453 cgpio_output_digitals[1] =
bin8_to_16(&data_fp[391]);
454 cgpio_input_analogs[0] = (float)(
bin8_to_16(&data_fp[393])) / 4095 * 10;
455 cgpio_input_analogs[1] = (float)(
bin8_to_16(&data_fp[395])) / 4095 * 10;
456 cgpio_output_analogs[0] = (float)(
bin8_to_16(&data_fp[397])) / 4095 * 10;
457 cgpio_output_analogs[1] = (float)(
bin8_to_16(&data_fp[399])) / 4095 * 10;
459 for (
int i = 0; i < 8; i++) {
460 cgpio_input_conf[i] = data_fp[401 + i];
461 cgpio_output_conf[i] = data_fp[409 + i];
463 if (total_num >= 433) {
464 for (
int i = 0; i < 8; i++) {
465 cgpio_input_conf[i+8] = data_fp[417 + i];
466 cgpio_output_conf[i+8] = data_fp[425 + i];
474 _print_normal_data();
475 printf(
"xarm_axis = %d, xarm_type = %d\n", axis_num, arm_type);
476 printf(
"master_id = 0x%X, slave_id = 0x%X\n", master_id, slave_id);
477 printf(
"motor_tid = 0x%X, motor_fid = 0x%X\n", motor_tid, motor_fid);
479 printf(
"versions = %s\n", versions);
485 printf(
"ID State ErrorCode\n");
486 for (
int i = 0; i < 8; i++) {
487 printf(
"%d %d 0x%X\n", i + 1, sv3msg_[i * 2], sv3msg_[i * 2 + 1]);
490 if (total_num >= 252) {
493 if (total_num >= 284) {
494 printf(
"realtime_tcp_speed: %f\n", rt_tcp_spd);
495 print_nvect(
"realtime_joint_speed: ", rt_joint_spds, 7);
497 if (total_num >= 288) {
498 printf(
"counter_val: %d\n", count);
500 if (total_num >= 312) {
503 if (total_num >= 314) {
504 printf(
"gpio_reset_conf: [ %d, %d ]\n", gpio_reset_conf[0], gpio_reset_conf[1]);
506 if (total_num >= 417) {
507 printf(
"simulation_mode: %d\n", simulation_mode);
508 printf(
"collision_detection: %d\n", collision_detection);
509 printf(
"collision_tool_type: %d\n", collision_tool_type);
510 print_nvect(
"collision_model_params: ", collision_model_params, 6);
514 printf(
"cgpio_state: %d, cgpio_code = %d\n", cgpio_state, cgpio_code);
521 printf(
"CGPIO_INPUT: \n");
523 for (
int i = 0; i < 8; ++i) { printf(
"CI%d=%d, ", i, (cgpio_input_digitals[1] >> i) & 0x0001); }
526 for (
int i = 8; i < 16; ++i) { printf(
"DI%d=%d, ", i-8, (cgpio_input_digitals[1] >> i) & 0x0001); }
528 printf(
" [AI] AI0=%f, AI1=%f\n", cgpio_input_analogs[0], cgpio_input_analogs[1]);
529 printf(
"CGPIO_OUTPUT: \n");
531 for (
int i = 0; i < 8; ++i) { printf(
"CO%d=%d, ", i, (cgpio_output_digitals[1] >> i) & 0x0001); }
534 for (
int i = 8; i < 16; ++i) { printf(
"DO%d=%d, ", i-8, (cgpio_output_digitals[1] >> i) & 0x0001); }
537 printf(
" [AO] AO0=%f, AO1=%f\n", cgpio_output_analogs[0], cgpio_output_analogs[1]);
538 printf(
"CGPIO_CONF: \n");
540 for (
int i = 0; i < 8; ++i) { printf(
"CI%d=%d, ", i, cgpio_input_conf[i]); }
543 for (
int i = 8; i < 16; ++i) { printf(
"DI%d=%d, ", i-8, cgpio_input_conf[i]); }
546 for (
int i = 0; i < 8; ++i) { printf(
"CO%d=%d, ", i, cgpio_output_conf[i]); }
549 for (
int i = 8; i < 16; ++i) { printf(
"DO%d=%d, ", i-8, cgpio_output_conf[i]); }
556 if (report_type ==
"dev") {
557 return _flush_dev_data(rx_data);
559 else if (report_type ==
"rich") {
560 return _flush_rich_data(rx_data);
563 return _flush_normal_data(rx_data);
569 if (report_type ==
"dev") {
572 else if (report_type ==
"rich") {
576 _print_normal_data();
int flush_data(unsigned char *rx_data)
int flush_data(unsigned char *rx_data)
void _print_normal_data(void)
void hex_to_nfp32(unsigned char *datahex, float *dataf, int n)
void _print_dev_data(void)
int flush_data(unsigned char *rx_data)
int bin8_to_32(unsigned char *a)
XArmReportData(std::string report_type="normal")
void _print_rich_data(void)
int __flush_common_data(unsigned char *rx_data)
int _flush_normal_data(unsigned char *rx_data)
int _flush_dev_data(unsigned char *rx_data)
int flush_data(unsigned char *rx_data)
int _flush_rich_data(unsigned char *rx_data)
void print_nvect(const char *str, double vect[], int n)
void __print_common_data(void)
int bin8_to_16(unsigned char *a)