|
AGVC SDK API
0.7.0
|
|
|
|
RTDE客户端 更多...
#include <rtde.h>
Public 类型 | |
| enum | Event { Connected , Disconnected } |
Public 成员函数 | |
| RtdeClient (int mode=0) | |
| RTDE客户端初始化 | |
| ~RtdeClient () | |
| void | setLogHandler (std::function< void(int, const char *, int, const std::string &)> handler) |
| 设置日志处理器 | |
| int | connect (const std::string &ip="", int port=0) |
| 连接到服务器 | |
| bool | hasConnected () const |
| socket 是否已连接 | |
| bool | hasConnected1 (std::function< void(bool)> callback) |
| socket 是否已连接 | |
| int | login (const std::string &usrname, const std::string &passwd) |
| 登录 | |
| bool | hasLogined () |
| 是否已经登录 | |
| int | logout () |
| 登出 | |
| int | disconnect () |
| 断开连接 | |
| int | getProtocolVersion () |
| 获取协议版本号 | |
| std::map< std::string, int > | getInputMaps () |
| 获取输入列表 | |
| std::map< std::string, int > | getOutputMaps () |
| 获取输出列表 | |
| int | setTopic (bool to_server, const std::vector< std::string > &names, double freq, int expected_chanel) |
| 设置话题 | |
| int | removeTopic (bool to_server, int chanel) |
| 取消订阅 | |
| std::unordered_map< int, agvc_interface::RtdeRecipe > | getRegisteredInputRecipe () |
| 获取已注册的输入菜单 | |
| std::unordered_map< int, agvc_interface::RtdeRecipe > | getRegisteredOutputRecipe () |
| 获取已注册的输出菜单 | |
| int | subscribe (int chanel, std::function< void(InputParser &)> callback) |
| 订阅 subscribe from output | |
| int | publish (int chanel, std::function< void(OutputBuilder &)> callback) |
| 发布 publish to input | |
| int | setEventHandler (std::function< void(int)> cb) |
| 设置事件处理 | |
Private 属性 | |
| Impl * | impl |
| agvc_interface::RtdeClient::RtdeClient | ( | int | mode = 0 | ) |
RTDE客户端初始化
| mode | 设置通讯方式, 0 tcp通讯 1 uds通讯 |
| agvc_interface::RtdeClient::~RtdeClient | ( | ) |
| int agvc_interface::RtdeClient::connect | ( | const std::string & | ip = "", |
| int | port = 0 ) |
连接到服务器
| ip | IP地址 |
| port | 端口号,RTDE 端口号为30110 |
| 0 | 连接成功 |
| 1 | 在执行函数前,已连接 |
| -1 | 连接失败 |
| int agvc_interface::RtdeClient::disconnect | ( | ) |
断开连接
| 0 | 成功 |
| -1 | 失败 |
| std::map< std::string, int > agvc_interface::RtdeClient::getInputMaps | ( | ) |
获取输入列表
| std::map< std::string, int > agvc_interface::RtdeClient::getOutputMaps | ( | ) |
获取输出列表
| int agvc_interface::RtdeClient::getProtocolVersion | ( | ) |
获取协议版本号
| std::unordered_map< int, agvc_interface::RtdeRecipe > agvc_interface::RtdeClient::getRegisteredInputRecipe | ( | ) |
获取已注册的输入菜单
| std::unordered_map< int, agvc_interface::RtdeRecipe > agvc_interface::RtdeClient::getRegisteredOutputRecipe | ( | ) |
获取已注册的输出菜单
| bool agvc_interface::RtdeClient::hasConnected | ( | ) | const |
socket 是否已连接
| true | 已连接socket |
| false | 未连接socket |
| bool agvc_interface::RtdeClient::hasConnected1 | ( | std::function< void(bool)> | callback | ) |
socket 是否已连接
| callback |
| true | 已连接socket |
| false | 未连接socket |
| bool agvc_interface::RtdeClient::hasLogined | ( | ) |
是否已经登录
| true | 已登录 |
| false | 未登录 |
| int agvc_interface::RtdeClient::login | ( | const std::string & | usrname, |
| const std::string & | passwd ) |
登录
| usrname | 用户名 |
| passwd | 密码 |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::RtdeClient::logout | ( | ) |
登出
| int agvc_interface::RtdeClient::publish | ( | int | chanel, |
| std::function< void(OutputBuilder &)> | callback ) |
发布 publish to input
| chanel | 通道 |
| callback | 回调函数,用于构建发布的输出信息。 回调函数的定义如下: void callback(OutputBuilder &builder) |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::RtdeClient::removeTopic | ( | bool | to_server, |
| int | chanel ) |
取消订阅
| to_server | 数据流向 true 表示客户端给服务器发送消息,false 表示服务器给客户端发送消息 |
| chanel | 通道 |
| 0 | 成功 |
| 1 | 失败 |
| int agvc_interface::RtdeClient::setEventHandler | ( | std::function< void(int)> | cb | ) |
设置事件处理
| cb |
| void agvc_interface::RtdeClient::setLogHandler | ( | std::function< void(int, const char *, int, const std::string &)> | handler | ) |
设置日志处理器
此函数可设置自定义的日志处理函数来处理日志消息。
Aubo SDK 有一套默认的日志系统,按照默认的格式输出到默认的文件。 如果用户不希望采用默认的格式或者不希望输出到默认的文件,那就可以通过这个接口重新自定义格式,或者输出路径。 这个函数可以将用户自定义的日志系统与 Aubo SDK 默认的日志系统合并。
| handler | 日志处理函数 此日志处理函数的下定义如下: void handler(int level, const char* filename, int line, const std::string& message) level 表示日志等级 0: LOGLEVEL_FATAL 严重的错误 1: LOGLEVEL_ERROR 错误 2: LOGLEVEL_WARNING 警告 3: LOGLEVEL_INFO 通知 4: LOGLEVEL_DEBUG 调试 5: LOGLEVEL_BACKTRACE 跟踪 filename 表示文件名 line 表示代码行号 message 表示日志信息 |
| int agvc_interface::RtdeClient::setTopic | ( | bool | to_server, |
| const std::vector< std::string > & | names, | ||
| double | freq, | ||
| int | expected_chanel ) |
设置话题
| to_server | 数据流向。 true 表示客户端给服务器发送消息,false 表示服务器给客户端发送消息 |
| names | 服务器推送的信息列表 |
| freq | 服务器推送信息的频率 |
| expected_chanel | 通道。 取值范围:0~99, 发布不同的话题走不同的通道 |
| expected_chanel参数的值 | 成功 |
| -1 | 失败 |
| int agvc_interface::RtdeClient::subscribe | ( | int | chanel, |
| std::function< void(InputParser &)> | callback ) |
订阅 subscribe from output
| chanel | 通道 |
| callback | 回调函数,用于处理订阅的输入信息。 回调函数的定义如下: void callback(InputParser &parser) |