9 #ifndef WRAPPER_XARM_API_H_ 10 #define WRAPPER_XARM_API_H_ 29 #define DEFAULT_IS_RADIAN false 30 #define RAD_DEGREE 57.295779513082320876798154814105 33 #define SDK_VERSION "1.6.0" 35 typedef unsigned int u32;
45 unsigned char gPR = 0;
46 unsigned char gPO = 0;
47 unsigned char gCU = 0;
70 XArmAPI(
const std::string &port =
"",
72 bool do_not_open =
false,
73 bool check_tcp_limit =
true,
74 bool check_joint_limit =
true,
75 bool check_cmdnum_limit =
true,
76 bool check_robot_sn =
false,
77 bool check_is_ready =
true,
78 bool check_is_pause =
true,
79 int max_callback_thread_count = -1,
80 int max_cmdnum = 256);
101 unsigned char version[30];
102 unsigned char sn[40];
157 bool has_err_warn(
void);
162 bool has_error(
void);
172 bool is_connected(
void);
177 bool is_reported(
void);
188 int connect(
const std::string &port =
"");
193 void disconnect(
void);
196 void _recv_report_data(
void);
203 int get_version(
unsigned char version[40]);
210 int get_robot_sn(
unsigned char robot_sn[40]);
221 int get_state(
int *state);
229 int shutdown_system(
int value = 1);
235 int get_cmdnum(
int *cmdnum);
241 int get_err_warn_code(
int err_warn[2]);
250 int get_position(
fp32 pose[6]);
259 int get_servo_angle(
fp32 angles[7]);
296 int set_servo_attach(
int servo_id);
303 int set_servo_detach(
int servo_id);
309 int clean_error(
void);
315 int clean_warn(
void);
322 int set_pause_time(
fp32 sltime);
329 int set_collision_sensitivity(
int sensitivity);
336 int set_teach_sensitivity(
int sensitivity);
343 int set_gravity_direction(
fp32 gravity_dir[3]);
351 int clean_conf(
void);
419 int set_servo_angle(
int servo_id,
fp32 angle,
bool wait =
false,
fp32 timeout =
NO_TIMEOUT,
fp32 radius = -1);
448 int set_servo_cartesian(
fp32 pose[6],
fp32 speed = 0,
fp32 acc = 0,
fp32 mvtime = 0,
bool is_tool_coord =
false);
496 void emergency_stop(
void);
505 int set_tcp_offset(
fp32 pose_offset[6]);
513 int set_tcp_load(
fp32 weight,
fp32 center_of_gravity[3]);
520 int set_tcp_jerk(
fp32 jerk);
527 int set_tcp_maxacc(
fp32 acc);
536 int set_joint_jerk(
fp32 jerk);
545 int set_joint_maxacc(
fp32 acc);
557 int get_inverse_kinematics(
fp32 pose[6],
fp32 angles[7]);
569 int get_forward_kinematics(
fp32 angles[7],
fp32 pose[6]);
579 int is_tcp_limit(
fp32 pose[6],
int *limit);
589 int is_joint_limit(
fp32 angles[7],
int *limit);
596 int set_gripper_enable(
bool enable);
603 int set_gripper_mode(
int mode);
610 int get_gripper_position(
fp32 *pos);
619 int set_gripper_position(
fp32 pos,
bool wait =
false,
fp32 timeout = 10);
626 int set_gripper_speed(
fp32 speed);
633 int get_gripper_err_code(
int *err);
639 int clean_gripper_error(
void);
647 int get_tgpio_digital(
int *io0_value,
int *io1_value);
656 int set_tgpio_digital(
int ionum,
int value,
float delay_sec=0);
664 int get_tgpio_analog(
int ionum,
float *value);
672 int get_cgpio_digital(
int *digitals,
int *digitals2 = NULL);
680 int get_cgpio_analog(
int ionum,
fp32 *value);
689 int set_cgpio_digital(
int ionum,
int value,
float delay_sec=0);
697 int set_cgpio_analog(
int ionum,
fp32 value);
713 int set_cgpio_digital_input_function(
int ionum,
int fun);
729 int set_cgpio_digital_output_function(
int ionum,
int fun);
757 int get_cgpio_state(
int *state,
int *digit_io,
fp32 *analog,
int *input_conf,
int *output_conf,
int *input_conf2 = NULL,
int *output_conf2 = NULL);
762 int register_report_location_callback(
void(*callback)(
const fp32 *pose,
const fp32 *angles));
767 int register_connect_changed_callback(
void(*callback)(
bool connected,
bool reported));
772 int register_state_changed_callback(
void(*callback)(
int state));
777 int register_mode_changed_callback(
void(*callback)(
int mode));
782 int register_mtable_mtbrake_changed_callback(
void(*callback)(
int mtable,
int mtbrake));
787 int register_error_warn_changed_callback(
void(*callback)(
int err_code,
int warn_code));
792 int register_cmdnum_changed_callback(
void(*callback)(
int cmdnum));
797 int register_temperature_changed_callback(
void(*callback)(
const fp32 *temps));
802 int register_count_changed_callback(
void(*callback)(
int count));
808 int release_report_location_callback(
void(*callback)(
const fp32 *pose,
const fp32 *angles) = NULL);
814 int release_connect_changed_callback(
void(*callback)(
bool connected,
bool reported) = NULL);
820 int release_state_changed_callback(
void(*callback)(
int state) = NULL);
826 int release_mode_changed_callback(
void(*callback)(
int mode) = NULL);
832 int release_mtable_mtbrake_changed_callback(
void(*callback)(
int mtable,
int mtbrake) = NULL);
838 int release_error_warn_changed_callback(
void(*callback)(
int err_code,
int warn_code) = NULL);
844 int release_cmdnum_changed_callback(
void(*callback)(
int cmdnum) = NULL);
850 int release_temperature_changed_callback(
void(*callback)(
const fp32 *temps) = NULL);
856 int release_count_changed_callback(
void(*callback)(
int count) = NULL);
865 int get_suction_cup(
int *val);
876 int set_suction_cup(
bool on,
bool wait =
false,
float timeout = 3,
float delay_sec = 0);
877 int set_vacuum_gripper(
bool on,
bool wait =
false,
float timeout = 3,
float delay_sec = 0) {
return set_suction_cup(on, wait, timeout, delay_sec); }
883 int get_gripper_version(
unsigned char versions[3]);
889 int get_servo_version(
unsigned char versions[3],
int servo_id = 1);
895 int get_tgpio_version(
unsigned char versions[3]);
901 int reload_dynamics(
void);
908 int set_reduced_mode(
bool on);
915 int set_reduced_max_tcp_speed(
float speed);
924 int set_reduced_max_joint_speed(
float speed);
933 int get_reduced_mode(
int *mode);
956 int get_reduced_states(
int *on,
int *xyz_list,
float *tcp_speed,
float *joint_speed,
float jrange[14] = NULL,
int *fense_is_on = NULL,
int *collision_rebound_is_on = NULL);
963 int set_reduced_tcp_boundary(
int boundary[6]);
972 int set_reduced_joint_range(
float jrange[14]);
979 int set_fense_mode(
bool on);
987 int set_collision_rebound(
bool on);
996 int set_world_offset(
float pose_offset[6]);
1002 int start_record_trajectory(
void);
1013 int stop_record_trajectory(
char* filename = NULL);
1023 int save_record_trajectory(
char* filename,
float timeout = 10);
1031 int load_trajectory(
char* filename,
float timeout = 10);
1042 int playback_trajectory(
int times = 1,
char* filename = NULL,
bool wait =
false,
int double_speed = 1);
1056 int get_trajectory_rw_status(
int *status);
1062 int set_counter_reset(
void);
1068 int set_counter_increase(
void);
1078 int set_tgpio_digital_with_xyz(
int ionum,
int value,
float xyz[3],
float tol_r);
1088 int set_cgpio_digital_with_xyz(
int ionum,
int value,
float xyz[3],
float tol_r);
1098 int set_cgpio_analog_with_xyz(
int ionum,
float value,
float xyz[3],
float tol_r);
1105 int config_tgpio_reset_when_stop(
bool on_off);
1112 int config_cgpio_reset_when_stop(
bool on_off);
1128 int set_position_aa(
fp32 pose[6],
fp32 speed = 0,
fp32 acc = 0,
fp32 mvtime = 0,
bool is_tool_coord =
false,
bool relative =
false,
bool wait =
false,
fp32 timeout =
NO_TIMEOUT);
1129 int set_position_aa(
fp32 pose[6],
bool is_tool_coord =
false,
bool relative =
false,
bool wait =
false,
fp32 timeout =
NO_TIMEOUT);
1143 int set_servo_cartesian_aa(
fp32 pose[6],
fp32 speed = 0,
fp32 acc = 0,
bool is_tool_coord =
false,
bool relative =
false);
1144 int set_servo_cartesian_aa(
fp32 pose[6],
bool is_tool_coord =
false,
bool relative =
false);
1159 int get_pose_offset(
float pose1[6],
float pose2[6],
float offset[6],
int orient_type_in = 0,
int orient_type_out = 0);
1168 int get_position_aa(
fp32 pose[6]);
1175 int robotiq_reset(
unsigned char ret_data[6] = NULL);
1184 int robotiq_set_activate(
bool wait =
true,
fp32 timeout = 3,
unsigned char ret_data[6] = NULL);
1185 int robotiq_set_activate(
bool wait =
true,
unsigned char ret_data[6] = NULL);
1186 int robotiq_set_activate(
unsigned char ret_data[6] = NULL);
1198 int robotiq_set_position(
unsigned char pos,
unsigned char speed = 0xFF,
unsigned char force = 0xFF,
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1199 int robotiq_set_position(
unsigned char pos,
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1200 int robotiq_set_position(
unsigned char pos,
bool wait =
true,
unsigned char ret_data[6] = NULL);
1201 int robotiq_set_position(
unsigned char pos,
unsigned char ret_data[6] = NULL);
1212 int robotiq_open(
unsigned char speed = 0xFF,
unsigned char force = 0xFF,
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1213 int robotiq_open(
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1214 int robotiq_open(
bool wait =
true,
unsigned char ret_data[6] = NULL);
1215 int robotiq_open(
unsigned char ret_data[6] = NULL);
1226 int robotiq_close(
unsigned char speed = 0xFF,
unsigned char force = 0xFF,
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1227 int robotiq_close(
bool wait =
true,
fp32 timeout = 5,
unsigned char ret_data[6] = NULL);
1228 int robotiq_close(
bool wait =
true,
unsigned char ret_data[6] = NULL);
1229 int robotiq_close(
unsigned char ret_data[6] = NULL);
1245 int robotiq_get_status(
unsigned char ret_data[9],
unsigned char number_of_registers = 3);
1256 int set_bio_gripper_enable(
bool enable,
bool wait =
true,
fp32 timeout = 3);
1265 int set_bio_gripper_speed(
int speed);
1276 int open_bio_gripper(
int speed = 0,
bool wait =
true,
fp32 timeout = 5);
1277 int open_bio_gripper(
bool wait =
true,
fp32 timeout = 5);
1288 int close_bio_gripper(
int speed = 0,
bool wait =
true,
fp32 timeout = 5);
1289 int close_bio_gripper(
bool wait =
true,
fp32 timeout = 5);
1305 int get_bio_gripper_status(
int *status);
1314 int get_bio_gripper_error(
int *err);
1321 int clean_bio_gripper_error(
void);
1330 int set_tgpio_modbus_timeout(
int timeout);
1339 int set_tgpio_modbus_baudrate(
int baud);
1348 int get_tgpio_modbus_baudrate(
int *baud);
1360 int getset_tgpio_modbus_data(
unsigned char *modbus_data,
int modbus_length,
unsigned char *ret_data,
int ret_length);
1371 int set_report_tau_or_i(
int tau_or_i = 0);
1380 int get_report_tau_or_i(
int *tau_or_i);
1389 int set_self_collision_detection(
bool on);
1416 int set_collision_tool_model(
int tool_type,
int n = 0, ...);
1425 int set_simulation_robot(
bool on);
1437 int vc_set_joint_velocity(
fp32 speeds[7],
bool is_sync =
true);
1449 int vc_set_cartesian_velocity(
fp32 speeds[6],
bool is_tool_coord =
false);
1451 int set_timeout(
fp32 timeout);
1455 void _check_version(
void);
1456 bool _version_is_ge(
int major = 1,
int minor = 2,
int revision = 11);
1457 void _check_is_pause(
void);
1458 int _wait_until_cmdnum_lt_max(
void);
1459 int _check_code(
int code,
bool is_move_cmd =
false);
1460 int _wait_move(
fp32 timeout);
1461 void _update_old(
unsigned char *data);
1462 void _update(
unsigned char *data);
1463 template<
typename callable_vector,
typename callable>
1464 inline int _register_event_callback(callable_vector&& callbacks, callable&&
f);
1465 template<
typename callable_vector,
typename callable>
1466 inline int _release_event_callback(callable_vector&& callbacks, callable&&
f);
1467 template<
typename callable_vector,
class... arguments>
1468 inline void _report_callback(callable_vector&& callbacks, arguments&&... args);
1469 inline void _report_location_callback(
void);
1470 inline void _report_connect_changed_callback(
void);
1471 inline void _report_state_changed_callback(
void);
1472 inline void _report_mode_changed_callback(
void);
1473 inline void _report_mtable_mtbrake_changed_callback(
void);
1474 inline void _report_error_warn_changed_callback(
void);
1475 inline void _report_cmdnum_changed_callback(
void);
1476 inline void _report_temperature_changed_callback(
void);
1477 inline void _report_count_changed_callback(
void);
1478 int _check_modbus_code(
int ret,
unsigned char *rx_data = NULL);
1479 int _get_modbus_baudrate(
int *baud_inx);
1480 int _checkset_modbus_baud(
int baudrate,
bool check =
true);
1481 int _robotiq_set(
unsigned char *params,
int length,
unsigned char ret_data[6]);
1482 int _robotiq_get(
unsigned char ret_data[9],
unsigned char number_of_registers = 0x03);
1483 int _robotiq_wait_activation_completed(
fp32 timeout = 3);
1484 int _robotiq_wait_motion_completed(
fp32 timeout = 5,
bool check_detected =
false);
1486 int _get_bio_gripper_register(
unsigned char *ret_data,
int address = 0x00,
int number_of_registers = 1);
1487 int _bio_gripper_send_modbus(
unsigned char *send_data,
int length,
unsigned char *ret_data,
int ret_length);
1488 int _bio_gripper_wait_motion_completed(
fp32 timeout = 5);
1489 int _bio_gripper_wait_enable_completed(
fp32 timeout = 3);
1490 int _set_bio_gripper_position(
int pos,
int speed = 0,
bool wait =
true,
fp32 timeout = 5);
1491 int _set_bio_gripper_position(
int pos,
bool wait =
true,
fp32 timeout = 5);
1493 int _check_gripper_position(
fp32 target_pos,
fp32 timeout = 10);
1494 int _check_gripper_status(
fp32 timeout = 10);
1495 bool _gripper_is_support_status(
void);
1496 int _get_gripper_status(
int *status);
1550 int gripper_version_numbers_[3];
bool * motor_brake_states
int set_fence_mode(bool on)
int major_version_number_
fp32 * collision_model_params
std::vector< void(*)(int)> state_changed_callbacks_
bool robotiq_is_activated_
fp32 last_used_joint_speed
SocketPort * stream_tcp_report_
int * cgpio_input_digitals
fp32 * cgpio_output_anglogs
std::vector< void(*)(int)> mode_changed_callbacks_
int minor_version_number_
std::vector< void(*)(int, int)> error_warn_changed_callbacks_
std::vector< void(*)(bool, bool)> connect_changed_callbacks_
std::vector< void(*)(int)> cmdnum_changed_callbacks_
unsigned char * gpio_reset_config
int collision_sensitivity
long long max_report_interval_
long long sleep_finish_time_
int xarm_gripper_error_code_
std::vector< void(*)(const fp32 *)> temperature_changed_callbacks_
bool bio_gripper_is_enabled_
int get_vacuum_gripper(int *val)
int * cgpio_output_digitals
std::vector< void(*)(int)> count_changed_callbacks_
int bio_gripper_error_code_
fp32 * last_used_position
std::thread report_thread_
bool control_box_type_is_1300_
fp32 * realtime_joint_speeds
#define DEFAULT_IS_RADIAN
std::condition_variable cond_
long long last_report_time_
int is_collision_detection
int set_vacuum_gripper(bool on, bool wait=false, float timeout=3, float delay_sec=0)
std::vector< void(*)(const fp32 *, const fp32 *)> report_location_callbacks_
int motion_enable(bool enable, xarm_msgs::SetAxis srv, ros::ServiceClient client)
int revision_version_number_
std::vector< void(*)(int, int)> mtable_mtbrake_changed_callbacks_
fp32 * cgpio_intput_anglogs
bool * motor_enable_states