lebai sdk
1.1.28
lebai c++ sdk with swig to support sereval languages.
|
机械臂的主要接口对象,通过本对象的方法与机械臂进行数据交互. More...
#include <robot.hh>
Public Member Functions | |
Robot (std::string ip, bool simulator=false) | |
构造Robot对象. More... | |
virtual | ~Robot () |
析构Robot对象. | |
std::tuple< int, std::string > | call (const std::string &method, const std::string ¶ms) |
用JSON格式字符串调用机械臂的接口. More... | |
bool | is_network_connected () |
返回是否和机械臂的网络连接正常,如果网络连接异常,调用和机械臂交互的接口会抛出异常std::runtime_error。 More... | |
void | start_sys () |
启动机械臂(机械臂上使能). | |
void | stop_sys () |
停止机械臂(机械臂下使能). | |
void | powerdown () |
关闭机器人电源(关机). | |
void | stop () |
停止运动(但不下电). | |
void | estop () |
紧急停止(急停). | |
void | teach_mode () |
进入示教模式. | |
void | end_teach_mode () |
退出示教模式. | |
void | pause () |
暂停运动. | |
void | resume () |
恢复运动. | |
void | reboot () |
重新启动机箱 | |
int | movej (const std::vector< double > &joint_positions, double a, double v, double t, double r) |
通过关节位置发送机械臂关节移动 More... | |
int | movej (const CartesianPose &cart_pose, double a, double v, double t, double r) |
通过坐标位置发送机械臂关节移动 More... | |
int | movel (const std::vector< double > &joint_positions, double a, double v, double t, double r) |
通过关节位置发送机械臂直线移动 More... | |
int | movel (const CartesianPose &cart_pose, double a, double v, double t, double r) |
通过坐标位置发送机械臂直线移动 More... | |
int | movec (const std::vector< double > &joint_via, const std::vector< double > &joint, double rad, double a, double v, double t, double r) |
通过关节位置发送机械臂圆弧运动. More... | |
int | movec (const CartesianPose &cart_via, const CartesianPose &cart, double rad, double a, double v, double t, double r) |
通过坐标位置发送机械臂圆弧运动 More... | |
int | speedj (double a, const std::vector< double > &v, double t=0.0) |
通过关节速度矢量发送机械臂关节匀速运动 More... | |
int | speedl (double a, const CartesianPose &v, double t=0.0, const CartesianPose &reference={{"x", 0.0}, {"y", 0.0}, {"z", 0.0}, {"rx", 0.0}, {"ry", 0.0}, {"rz", 0.0}}) |
通过坐标速度矢量发送机械臂关节匀速运动 More... | |
int | towardj (const std::vector< double > &joint_positions, double a, double v, double t, double r) |
通过关节位置发送机械臂关节自由移动. More... | |
void | move_pvat (std::vector< double > p, std::vector< double > v, std::vector< double > a, double t) |
伺服运动PVAT More... | |
void | wait_move (unsigned int id) |
等待运动完成. More... | |
void | wait_move () |
等待所有运动完成. | |
unsigned int | get_running_motion () |
查询当前正在运动的MotionId(无运动时返回上次MotionId). | |
std::string | get_motion_state (unsigned int id) |
查询指定MotionId的运动状态. More... | |
void | stop_move () |
停止所有运动. | |
int | get_robot_mode () |
获取机器人状态码 More... | |
int | get_estop_reason () |
查看急停原因 More... | |
bool | is_disconnected () |
是否已与手臂断开连接 More... | |
bool | is_down () |
手臂是否已下电 More... | |
std::vector< double > | get_actual_joint_positions () |
获取机械臂关节当前反馈位置 More... | |
std::vector< double > | get_target_joint_positions () |
获取机械臂关节当前控制位置 More... | |
std::vector< double > | get_actual_joint_speed () |
获取机械臂关节当前反馈速度 More... | |
std::vector< double > | get_target_joint_speed () |
获取机械臂关节当前控制力矩 More... | |
CartesianPose | get_actual_tcp_pose () |
获取机械臂末端在机械臂基坐标系下的实际位姿,CartesianPose = std::map<std::string,double>,应当包括键为x,y,z,rz,ry,rx的值. More... | |
CartesianPose | get_target_tcp_pose () |
获取机械臂末端在机械臂基坐标系下的控制位姿,CartesianPose = std::map<std::string,double>,应当包括键为x,y,z,rz,ry,rx的值. More... | |
double | get_joint_temp (unsigned int joint_index) |
获取单个关节温度 More... | |
std::vector< double > | get_actual_joint_torques () |
获取机械臂关节当前反馈力矩 More... | |
std::vector< double > | get_target_joint_torques () |
获取机械臂关节当前控制力矩 More... | |
void | set_do (std::string device, unsigned int pin, unsigned int value) |
设置数字输出 More... | |
unsigned int | get_do (std::string device, unsigned int pin) |
获取数字输出 More... | |
std::vector< unsigned int > | get_dos (std::string device, unsigned int pin, unsigned int num) |
获取多个数字输出 More... | |
unsigned int | get_di (std::string device, unsigned int pin) |
获取数字输入 More... | |
std::vector< unsigned int > | get_dis (std::string device, unsigned int pin, unsigned int num) |
获取多个数字输入 More... | |
void | set_ao (std::string device, unsigned int pin, double value) |
设置模拟输出 More... | |
double | get_ao (std::string device, unsigned int pin) |
获取模拟输出 More... | |
std::vector< double > | get_aos (std::string device, unsigned int pin, unsigned int num) |
获取多个模拟输出 More... | |
double | get_ai (std::string device, unsigned int pin) |
获取模拟输入 More... | |
std::vector< double > | get_ais (std::string device, unsigned int pin, unsigned int num) |
获取多个模拟输入 More... | |
void | set_dio_mode (std::string device, unsigned int pin, bool value) |
设置数字端口模式 More... | |
std::vector< bool > | get_dios_mode (std::string device, unsigned int pin, unsigned int count) |
获取数字端口模式 More... | |
void | set_claw (double force, double amplitude) |
设置夹爪力度(力控)和幅度(位控).如果在闭合过程中抓取到物体,则不再继续闭合以避免夹坏物体,判断的准则为这里设置的力的大小. More... | |
std::tuple< double, double, bool > | get_claw () |
获取夹爪当前数据 More... | |
ClawData | get_claw_data () |
获取夹爪当前数据 More... | |
void | set_led (unsigned int mode, unsigned int speed, const std::vector< unsigned int > &color) |
设置LED灯状态. More... | |
void | set_voice (unsigned int voice, unsigned int volume) |
设置声音 More... | |
void | set_fan (unsigned int status) |
开关风扇 More... | |
void | set_signal (unsigned int index, int value) |
设置信号量 More... | |
int | get_signal (unsigned int index) |
获取信号量 More... | |
void | add_signal (unsigned int index, int value) |
增加指定下标的信号量值,该操作是原子的. More... | |
unsigned int | start_task (const std::string &name, const std::vector< std::string > ¶ms, const std::string &dir, bool is_parallel, unsigned int loop_to) |
调用场景 More... | |
unsigned int | start_task (const std::string &name) |
调用场景 More... | |
std::vector< unsigned int > | load_task_list () |
查询任务列表 | |
void | pause_task (unsigned int id, unsigned long time, bool wait) |
暂停任务与运动 More... | |
void | pause_task (unsigned int id) |
暂停任务与运动 More... | |
void | resume_task (unsigned int id) |
恢复任务与运动 More... | |
void | cancel_task (unsigned int id) |
取消任务与运动. More... | |
unsigned int | exec_hook (unsigned int id) |
根据已设置的Hook执行对应场景 More... | |
std::string | get_task_state () |
获取任务状态. | |
std::string | get_task_state (unsigned int id) |
获取任务状态. More... | |
KinematicsForwardResp | kinematics_forward (const std::vector< double > &joint_positions) |
根据机械臂关节位置计算机器人末端位姿(位置的运动学正解). More... | |
KinematicsInverseResp | kinematics_inverse (const CartesianPose &pose, const std::vector< double > &joint_init_positions={}) |
根据机械臂的末端位姿计算关节位置(位置的运动学逆解). More... | |
CartesianPose | pose_times (const CartesianPose &a, const CartesianPose &b) |
位姿变换乘法(等价于对应的齐次坐标矩阵乘法) More... | |
CartesianPose | pose_inverse (const CartesianPose &in) |
位姿变换的逆(等价于对应的齐次坐标矩的逆) More... | |
void | save_file (const std::string &dir, const std::string &name, bool is_dir, const std::string &data) |
保存文件(以字节形式). More... | |
void | rename_file (const std::string &from_dir, const std::string &from_name, const std::string &to_dir, const std::string &to_name) |
重命名文件 More... | |
std::tuple< bool, std::string > | load_file (const std::string &dir, const std::string &name) |
查询文件 More... | |
std::vector< std::tuple< bool, std::string > > | load_file_list (const std::string &dir, const std::string &prefix, const std::string &suffix) |
查询文件列表. More... | |
void | set_tcp (std::array< double, 6 > tcp) |
设置工具中心点(TCP)坐标,坐标值相对于工具坐标系. More... | |
std::array< double, 6 > | get_tcp () |
获取当前机器人工具中心点设置. More... | |
void | set_velocity_factor (int factor) |
设置速度因子. More... | |
int | get_velocity_factor () |
获取当前的速度因子. More... | |
void | set_payload (double mass, std::map< std::string, double > cog) |
设置机器人末端负载. More... | |
void | set_payload_mass (double mass) |
设置机器人末端负载质量. More... | |
void | set_payload_cog (std::map< std::string, double > cog) |
设置机器人末端负载重心. More... | |
std::map< std::string, double > | get_payload () |
获取末端负载设置. More... | |
void | set_gravity (std::map< std::string, double > gravity) |
设置机器人重力加速度方向. More... | |
std::map< std::string, double > | get_gravity () |
获取机器人重力加速度的方向. More... | |
CartesianPose | load_tcp (std::string name, std::string dir="") |
从资源库加载tcp. More... | |
void | write_single_coil (std::string device, std::string addr, bool value) |
写单个线圈. More... | |
void | wirte_multiple_coils (std::string device, std::string addr, std::vector< bool > values) |
写多个线圈 More... | |
std::vector< bool > | read_coils (std::string device, std::string addr, unsigned int num) |
读线圈 More... | |
std::vector< bool > | read_discrete_inputs (std::string device, std::string addr, unsigned int num) |
读离散输入 More... | |
void | write_single_register (std::string device, std::string addr, unsigned int value) |
写单个寄存器 More... | |
void | write_multiple_registers (std::string device, std::string addr, std::vector< unsigned int > values) |
写多个寄存器 More... | |
std::vector< unsigned int > | read_holding_registers (std::string device, std::string addr, unsigned int num) |
读保持寄存器 More... | |
std::vector< unsigned int > | read_input_registers (std::string device, std::string addr, unsigned int num) |
读输入寄存器 More... | |
void | set_serial_baud_rate (std::string device, unsigned int baud_rate) |
设置串口波特率. More... | |
void | set_serial_parity (std::string device, unsigned int parity) |
设置串口校验位. More... | |
Protected Attributes | |
std::unique_ptr< RobotImpl > | impl_ |
机械臂的主要接口对象,通过本对象的方法与机械臂进行数据交互.
|
explicit |
构造Robot对象.
ip | 机械臂IP地址. |
simulator | 用于表示机械臂是否为仿真机械臂(docker仿真或控制器运行在仿真模式下)的macs标志.True表示仿真模式,False表示实物机械臂. |
std::tuple<int, std::string> lebai::l_master::Robot::call | ( | const std::string & | method, |
const std::string & | params | ||
) |
用JSON格式字符串调用机械臂的接口.
示例代码:
std::string movej_req =
"{\"param":{"v":0.1},"pose":{"joint":{"delta":"{\"joint":[-1.0,0.0,0.0,0.0,0.0,0.0]}}}}"; resp = robot.call("movej", movej_req); std::cout << "resp: " << std::get<0>(resp) << ", " << std::get<1>(resp) << std::endl;
[in] | method | 方法名字 |
[in] | params | 请求JSONRPC的JSON格式字符串. |
bool lebai::l_master::Robot::is_network_connected | ( | ) |
返回是否和机械臂的网络连接正常,如果网络连接异常,调用和机械臂交互的接口会抛出异常std::runtime_error。
|
protected |
内部实现数据结构,用户无需关注.