|
AGVC SDK
0.8.0
|
|
|
|
RPC客户端 更多...
#include <rpc.h>


Public 类型 | |
| enum | Event { Connected , Disconnected } |
Public 成员函数 | |
| RpcClient (int mode=0) | |
| RpcClient | |
| ~RpcClient () | |
| void | setLogHandler (std::function< void(int, const char *, int, const std::string &)> handler) |
| 设置日志处理器 | |
| int | connect (const std::string &ip="", int port=0) |
| 连接到RPC服务 | |
| int | disconnect () |
| 断开RPC连接 | |
| bool | hasConnected () const |
| 判断是否连接RPC | |
| int | login (const std::string &usrname, const std::string &passwd) |
| 登录 | |
| int | logout () |
| 登出 | |
| bool | hasLogined () |
| 判断是否登录 | |
| int | setRequestTimeout (int timeout=10) |
| 设置RPC请求超时时间 | |
| int | setEventHandler (std::function< void(int)> cb) |
| 设置事件处理 | |
| int | setExceptionFree (bool enable) |
| 是否关闭异常抛出 | |
| int | errorCode () const |
| 返回错误代码 | |
| Public 成员函数 继承自 agvc_interface::AgvcInterface | |
| AgvcInterface () | |
| virtual | ~AgvcInterface () |
| int | setSystemClock (const std::string &stamp) |
| 设置AGV系统时间。 时间戳,格式为YYYY-MM-DDTHH:mm:ss.ssZ,例如“2017-04-15T11:40:03.12Z”。 | |
| AgvDetails | getAgvDetails () |
| RunningInfo | getRunningInfo () |
| Pose2d | getAgvCurrentPose () |
| std::vector< Point2d > | getLaserPointCloud () |
| AsyncInterfaceResultStatus | getAsyncInterfaceResultStatus () |
| 查询异步接口的运行情况,不代表异步接口本身的运行结果。 异步接口:saveMap, switchMap, changeRunningMode, relocation, sendBase64PngMapToAgv。 异步接口:getGridMapAllInfo, setGridMapAllInfo, sendGridMapToAgv, getGridMapFromAgv。 异步接口:getPngMapAllInfo, setPngMapAllInfo, getBase64PngMapFromAgv, previewPngMapFromAgv。 异步接口:autoAlignRailway。 客户端与AGV断联后,可调用该接口获取异步接口运行情况。 返回值的每个字段中均有header,其中header.id表示下发异步任务时的id号。 NONE:异步接口未运行;RUNNING:异步接口运行中;FINISH:异步接口运行结束。 | |
| std::vector< StationMark > | getAllStations () |
| 查询当前地图的所有站点信息。 当前地图的所有站点信息。 | |
| std::vector< StationMark > | getAllStationsOfTargetMap (const Header &map_header) |
| 查询指定地图的所有站点信息。 指定地图header(命令id,名称,时间,地图id)。 指定地图的所有站点信息。 | |
| int | addStation (const StationMark &station) |
| 添加或修改一个站点。 待添加或修改的站点信息。 10100000:添加或修改站点成功;else:添加或修改站点失败。 | |
| int | addStations (const std::vector< StationMark > &stations) |
| 添加或修改多个站点。 待添加或修改的站点信息。 10100000:添加或修改站点成功;else:添加或修改站点失败。 | |
| int | addCPStationUseChargingBoard (const Header &station_header, const double &dis_station_board=1.5) |
| 通过自动识别充电桩位姿来添加充电站点。 待添加或修改的充电站点信息(站点id,名称,时间,地图id)。 充电站点与充电桩之间的距离(充电站点位于AGV中心),单位:m,范围[1.0~2.0]。 10100000:添加充电站点成功;else:添加充电站点失败。 | |
| int | deleteStation (const Header &station_header) |
| 删除指定站点,会删除与该站点相关的路径。 待删除站点信息(站点id,名称,时间,地图id)。 10100000:删除站点成功;else:删除站点失败。 | |
| int | deleteStations (const std::vector< Header > &stations_header) |
| 删除多个站点,会删除与站点相关的路径。 待删除站点信息(站点id,名称,时间,地图id)。 10100000:删除站点成功;else:删除站点失败。 | |
| std::vector< PathStation > | getAllPaths () |
| 查询当前地图的所有路径信息。 当前地图的所有路径信息。 | |
| std::vector< PathStation > | getAllPathsOfTargetMap (const Header &map_header) |
| 查询指定地图的所有路径信息。 指定地图header(命令id,名称,时间,地图id)。 指定地图的所有路径信息。 | |
| PathStation | getCurrentPath () |
| 查询AGV当前正在跟踪的路径信息。 当前正在跟踪的路径信息。 | |
| int | generatePath (const PathStation &path_station) |
| 生成或修改一条路径。 待生成或修改的路径信息。 10100000:修改或生成路径成功;else:修改或生成路径失败。 | |
| int | generatePaths (const std::vector< PathStation > &paths_station) |
| 生成或修改多条路径。 待生成或修改的路径信息。 10100000:修改或生成路径成功;else:修改或生成路径失败。 | |
| int | deletePath (const Header &path_header) |
| 删除一条路径。 待删除路径信息(路径id,名称,时间,地图id)。 10100000:删除路径成功;else:删除路径失败。 | |
| int | deletePaths (const std::vector< Header > &paths_header) |
| 删除多条路径。 待删除路径信息(路径id,名称,时间,地图id)。 10100000:删除路径成功;else:删除路径失败。 | |
| std::vector< Header > | getMapList () |
| 获取AGV所有地图的信息头。 所有地图的信息头(命令id,名称,时间,地图id)。 | |
| Header | getCurrentMapHeader () |
| 查询当前AGV地图的信息头。 当前地图的信息头(命令id,名称,时间,地图id)。 | |
| OccupancyGridMap | getGridMapFromAgv (const Header &map_header) |
| 获取指定栅格地图信息。 指定地图的信息头(本次异步命令id,名称,时间,地图id)。 map_id为"current_map"时,可特指为当前地图。 指定栅格地图信息。 | |
| Base64PngMap | getBase64PngMapFromAgv (const Header &map_header) |
| Base64PngMap | previewPngMapFromAgv (const Header &map_header, const int &image_width_px=0, const int &image_height_px=0) |
| int | sendGridMapToAgv (const OccupancyGridMap &map) |
| int | sendBase64PngMapToAgv (const Base64PngMap &map) |
| int | saveMap (const Header &map_header) |
| int | switchMap (const Header &map_header) |
| int | deleteMap (const Header &map_header) |
| 删除一张指定地图。 指定地图的信息头(命令id,名称,时间,地图id)。 10100000:删除地图成功;else:删除地图失败。 | |
| int | deleteMaps (const std::vector< Header > &map_headers) |
| 删除多张指定地图。 多个指定地图的信息头(命令id,名称,时间,地图id)。 10100000:删除地图成功;else:删除地图失败。 | |
| std::vector< MapVirtualArea > | getAllMapVirtualArea () |
| 查询当前地图的虚拟区域。 当前地图的虚拟区域信息。 | |
| std::vector< MapVirtualArea > | getAllMapVirtualAreaOfTargetMap (const Header &map_header) |
| 查询目标地图的虚拟区域。 指定地图header(命令id,名称,时间,地图id)。 指定地图的所有虚拟区域。 | |
| int | addMapVirtualArea (const MapVirtualArea &map_virtual_area) |
| 添加或修改一个虚拟区域。 待添加或修改的虚拟区域信息。 10100000:添加或修改虚拟区域成功;else:添加或修改虚拟区域失败。 | |
| int | addMapVirtualAreas (const std::vector< MapVirtualArea > &map_virtual_areas) |
| 添加或修改多个虚拟区域。 待添加或修改的虚拟区域信息。 10100000:添加或修改虚拟区域成功;else:添加或修改虚拟区域失败。 | |
| int | deleteMapVirtualArea (const Header &virtual_area_header) |
| 删除指定虚拟区域。 指定虚拟区域信息头(命令id,虚拟区域名称,时间,所在地图id)。 10100000:删除虚拟区域成功;else:删除虚拟区域失败。 | |
| int | deleteMapVirtualAreas (const std::vector< Header > &virtual_areas_header) |
| 删除多个指定虚拟区域。 指定虚拟区域信息头(命令id,虚拟区域名称,时间,所在地图id)。 10100000:删除虚拟区域成功;else:删除虚拟区域失败。 | |
| MapAllInfo | getGridMapAllInfo (const Header &map_header) |
| MapAllInfo | getPngMapAllInfo (const Header &map_header) |
| int | setGridMapAllInfo (const MapAllInfo &map_all_info, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| int | setPngMapAllInfo (const MapAllInfo &map_all_info, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| int | deleteMapAllInfo (const Header &map_header) |
| 删除指定地图的全部信息,包括地图数据、站点、路径、虚拟区信息。 指定地图信息头(命令id,地图名称,时间,地图id)。 10100000:删除成功;else:删除失败。 | |
| std::vector< std::string > | getWifiList () |
| int | connectWifi (const std::string &ssid, const std::string &password) |
| 连接到指定WiFi,自动切换到WiFi模式。 必须在有线连接时调用,且执行时间较长。 WiFi名称。 WiFi密码。 10100000:连接WiFi成功;else:连接WiFi失败。 | |
| int | enableHotspot (const std::string &password) |
| 开启热点,自动切换到热点模式。 必须在有线连接时调用,且执行时间较长。 热点密码;如果为空使用"administrator"为默认密码,SSID默认为SN码。 10100000:启用热点成功;else:启用热点失败。 | |
| std::vector< IpAddressInfo > | getIpAddressList () |
| 获取本机所有IP地址。 本机所有IP地址。 | |
| int | changeRunningMode (const RunningMode &running_mode, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| int | setControlSpeed (const Speed &speed) |
| int | setNavGoal (const NavGoalType &target) |
| NavInfo | getNavInfo () |
| int | pauseAgvSpeed () |
| int | resumeAgvSpeed () |
| int | cancelNavigation () |
| int | relocation (const Pose2d &init_pose, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| std::string | getAgvControllerParametersFile () |
| 获取AGV控制器的参数文件。 当前AGV控制器中的参数信息。 | |
| int | setAgvControllerParametersFile (const std::string &agv_parameters) |
| int | refreshAgvControllerParametersFile () |
| int | resetAgvControllerParametersFile () |
| int | checkPowerAndAutoCharge (const Header &check_power_header={ "99999", "99999", 99999, "99999" }, const std::string &nav_board_charge_station_id="99999") |
| int | setLeaveBoardTargetStation (const Header &leave_board_target_station_header) |
| 设置自动下桩时的目标站点。 自动下桩的站点header信息。 10100000:设置自动下桩站点成功;else:设置自动下桩站点失败。 | |
| Header | getLeaveBoardTargetStation () |
| 获取自动下桩时的目标站点。 自动下桩时的目标站点Header信息。 | |
| int | forcedAgvToChargingBoard (const Header &forced_charge_header={ "99999", "99999", 99999, "99999" }, const std::string &nav_board_charge_station_id="99999") |
| int | forcedAgvLeaveChargingBoard (const Header &forced_leave_header={ "99999", "99999", 99999, "99999" }, const std::string &leave_board_target_station_id="99999") |
| int | sendAutoChargingCommand (const AutoChargingCommand &auto_charging_command) |
| std::string | getAgvLogMessage () |
| 获取AGV运行中的日志信息。 AGV运行中的日志信息。 | |
| int | updateSoftware (const std::string &upgrade_pack_path) |
| AGV软件升级。 升级包路径,例如"/root/agvc_release-0.1.1+398d1f7-Linux_x86_64.tar.gz"。 10100000:目标版本升级成功;10100201:正在升级中;else:升级失败。 | |
| std::vector< std::string > | getSoftwareVersionList () |
| 获取AGV软件版本列表。 软件版本列表集合 {0.3.2+3b807d1-Linux_x86_64,0.6.3-patch.3+b8c6aa4-Linux_x86_64}。 | |
| int | switchSoftwareVersion (const std::string &software_version) |
| 切换AGV软件版本。 软件版本,例如"0.3.2+3b807d1-Linux_x86_64"。 10100000:软件版本切换成功;else:软件版本切换失败。 | |
| int | uninstallSoftware (const std::string &software_version) |
| 卸载AGV软件版本。 软件版本,例如"0.3.2+3b807d1-Linux_x86_64"。 10100000:软件版本卸载成功;else:软件版本卸载失败。 | |
| int | updateFirmware (const FirmwareUpdateParam &update_firmware) |
| AGV固件更新。 配置要更新固件的模块、固件存储路径。 10100000:下发固件更新信息成功;else:固件正在更新中。 | |
| FirmwareUpdateProcessInfo | getUpdateFirmwareProcess () |
| 获取固件更新过程信息。 固件更新步骤信息(步骤信息为failed代表更新失败),更新进度(进度信息为1.0代表更新成功)。 | |
| int | startCollectCalibrationData (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| 开始采集数据。 LASER_ODOM标定采集数据量要求大于1000组,具体数据量可以在配置文件中修改。 标定类型。 id字段代表下发本次命令的id;其他字段无特殊含义。 10100000:接口调用成功;10120202:无控制权;else:接口调用失败。 | |
| int | cancelCollectCalibrationData (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| 取消采集数据。 标定类型。 id字段代表下发本次命令的id;其他字段无特殊含义。 10100000:接口调用成功;10120202:无控制权;else:接口调用失败。 | |
| int | startCalibration (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" }) |
| 开始标定。 标定类型。 id字段代表下发本次命令的id;其他字段无特殊含义。 10100000:接口调用成功;10120202:无控制权;else:接口调用失败。 | |
| CalibrationProcessInfo | getCalibrationProcessInfo (const CalibrationType &type) |
| 获取标定信息。 标定类型。 标定信息。 | |
| int | restartAgv () |
| 重启AGV。 10100000:重启指令执行成功;else:重启指令执行失败。 | |
| int | setAgvName (const std::string &agv_name) |
| 设置AGV的名称。 设置的AGV名称。 10100000:设置名称成功;else:设置名称失败。 | |
| int | setPriority (const std::string &name, const std::string &ip="") |
| 设置控制权。 1. | |
| int | releasePriority () |
| 释放控制权。 10100000:释放控制权成功;else:释放控制权失败。 | |
| int | scriptPaused () |
| 暂停脚本。 10100000:脚本暂停成功;else:脚本暂停失败。 | |
| int | scriptResume () |
| 恢复脚本。 10100000:脚本恢复成功;else:脚本恢复失败。 | |
| int | scriptStop () |
| 停止脚本。 10100000:脚本停止成功;else:脚本停止失败。 | |
| ScriptRuntimeState | getScriptStatus () |
| 获取脚本运行状态。 脚本运行状态。 | |
| int | setScriptStatus (ScriptRuntimeState status) |
| 设置脚本运行状态。 10100000:设置脚本运行状态成功;else:设置脚本运行状态失败。 | |
| std::string | errorCodeDecoder (const int &error_code) |
| 错误码查询。 错误码。 错误码含义;为空表示错误码未知。 | |
| std::vector< Header > | getCurrentErrorCodes () |
| 获取当前的错误码。 错误码集合。 | |
| int | soundLightPrompt () |
| 寻找AGV,自动播放语音并特殊灯光闪烁。 10100000:寻找指令下发成功;else:下发指令失败。 | |
| bool | isObstacleAhead (const double &detect_distance=1.0) |
| AGV行进方向是否有障碍物。 检测距离,默认为1.0m。 true:行进方向存在障碍物;false:行进方向无障碍物。 | |
| StationMark | getNearestStation (const double &detect_distance=1.0) |
| 获取指定检测距离范围内的最近站点信息。 检测距离,默认为1.0m。 最近站点信息,id为NONE代表检测距离内无站点。 | |
| int | autoAlignRailway (const Header &command_header={ "99999", "99999", 1, "99999" }) |
| agvc_interface::RpcClient::RpcClient | ( | int | mode = 0 | ) |
| mode | 0-TCP 1-UDS |
| agvc_interface::RpcClient::~RpcClient | ( | ) |
| int agvc_interface::RpcClient::connect | ( | const std::string & | ip = "", |
| int | port = 0 ) |
连接到RPC服务
| ip | IP地址 |
| port | 端口号,RPC的端口号是30104 |
| ip和port为空时,采用unix | domain sockets通讯方式 |
| 0 | RPC连接成功 |
| -8 | RPC连接失败,RPC连接被拒绝 |
| -15 | RPC连接失败,SDK版本与Server版本不兼容 |
| int agvc_interface::RpcClient::disconnect | ( | ) |
断开RPC连接
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::RpcClient::errorCode | ( | ) | const |
返回错误代码
| bool agvc_interface::RpcClient::hasConnected | ( | ) | const |
判断是否连接RPC
| true | 已连接RPC |
| false | 未连接RPC |
| bool agvc_interface::RpcClient::hasLogined | ( | ) |
判断是否登录
| true | 已登录 |
| false | 未登录 |
| int agvc_interface::RpcClient::login | ( | const std::string & | usrname, |
| const std::string & | passwd ) |
登录
| usrname | 用户名 |
| passwd | 密码 |
| int agvc_interface::RpcClient::logout | ( | ) |
登出
| int agvc_interface::RpcClient::setEventHandler | ( | std::function< void(int)> | cb | ) |
设置事件处理
| cb |
| int agvc_interface::RpcClient::setExceptionFree | ( | bool | enable | ) |
是否关闭异常抛出
| enable |
| void agvc_interface::RpcClient::setLogHandler | ( | std::function< void(int, const char *, int, const std::string &)> | handler | ) |
设置日志处理器
此函数可设置自定义的日志处理函数来处理日志消息。
Agvc SDK 有一套默认的日志系统,按照默认的格式输出到默认的文件。 如果用户不希望采用默认的格式或者不希望输出到默认的文件,那就可以通过这个接口重新自定义格式,或者输出路径。 这个函数可以将用户自定义的日志系统与 Agvc 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::RpcClient::setRequestTimeout | ( | int | timeout = 10 | ) |
设置RPC请求超时时间
| timeout | 请求超时时间,单位 ms |