PDF
AGVC SDK  0.8.0
agvc_interface::RpcClient Class Reference

RPC客户端 More...

#include <rpc.h>

Inheritance diagram for agvc_interface::RpcClient:
Collaboration diagram for agvc_interface::RpcClient:

Public Types

enum  Event { Connected , Disconnected }

Public Member Functions

 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 Member Functions inherited from agvc_interface::AgvcInterface
 AgvcInterface ()
virtual ~AgvcInterface ()
int setSystemClock (const std::string &stamp)
 Sets the AGV system time.
AgvDetails getAgvDetails ()
 Queries current AGV information.
RunningInfo getRunningInfo ()
 Queries current AGV running information.
Pose2d getAgvCurrentPose ()
 Queries the current AGV pose.
std::vector< Point2dgetLaserPointCloud ()
 Queries the current laser point cloud data.
AsyncInterfaceResultStatus getAsyncInterfaceResultStatus ()
 Queries the running status of asynchronous APIs; this does not represent each API's own execution result.
std::vector< StationMarkgetAllStations ()
 Queries all station information on the current map.
std::vector< StationMarkgetAllStationsOfTargetMap (const Header &map_header)
 Queries all station information on the specified map.
int addStation (const StationMark &station)
 Adds or modifies one station.
int addStations (const std::vector< StationMark > &stations)
 Adds or modifies multiple stations.
int addCPStationUseChargingBoard (const Header &station_header, const double &dis_station_board=1.5)
 Adds a charging station by automatically recognizing the charging board pose.
int deleteStation (const Header &station_header)
 Deletes the specified station and its related paths.
int deleteStations (const std::vector< Header > &stations_header)
 Deletes multiple stations and their related paths.
std::vector< PathStationgetAllPaths ()
 Queries all path information on the current map.
std::vector< PathStationgetAllPathsOfTargetMap (const Header &map_header)
 Queries all path information on the specified map.
PathStation getCurrentPath ()
 Queries the path currently being tracked by the AGV.
int generatePath (const PathStation &path_station)
 Generates or modifies one path.
int generatePaths (const std::vector< PathStation > &paths_station)
 Generates or modifies multiple paths.
int deletePath (const Header &path_header)
 Deletes one path.
int deletePaths (const std::vector< Header > &paths_header)
 Deletes multiple paths.
std::vector< HeadergetMapList ()
 Gets the headers of all maps on the AGV.
Header getCurrentMapHeader ()
 Queries the header of the current AGV map.
OccupancyGridMap getGridMapFromAgv (const Header &map_header)
 Gets the specified occupancy grid map information.
Base64PngMap getBase64PngMapFromAgv (const Header &map_header)
 Gets Base64-encoded PNG map information.
Base64PngMap previewPngMapFromAgv (const Header &map_header, const int &image_width_px=0, const int &image_height_px=0)
 Gets a preview image with optional width and height.
int sendGridMapToAgv (const OccupancyGridMap &map)
 Sends occupancy grid map information to the AGV.
int sendBase64PngMapToAgv (const Base64PngMap &map)
 Sends a Base64-encoded PNG map to the AGV.
int saveMap (const Header &map_header)
 Saves the map after mapping is complete.
int switchMap (const Header &map_header)
 Switches to the specified map.
int deleteMap (const Header &map_header)
 Deletes one specified map.
int deleteMaps (const std::vector< Header > &map_headers)
 Deletes multiple specified maps.
std::vector< MapVirtualAreagetAllMapVirtualArea ()
 Queries virtual areas on the current map.
std::vector< MapVirtualAreagetAllMapVirtualAreaOfTargetMap (const Header &map_header)
 Queries virtual areas on the target map.
int addMapVirtualArea (const MapVirtualArea &map_virtual_area)
 Adds or modifies one virtual area.
int addMapVirtualAreas (const std::vector< MapVirtualArea > &map_virtual_areas)
 Adds or modifies multiple virtual areas.
int deleteMapVirtualArea (const Header &virtual_area_header)
 Deletes the specified virtual area.
int deleteMapVirtualAreas (const std::vector< Header > &virtual_areas_header)
 Deletes multiple specified virtual areas.
MapAllInfo getGridMapAllInfo (const Header &map_header)
 Gets occupancy grid map data, paths, stations, and virtual areas for the specified map.
MapAllInfo getPngMapAllInfo (const Header &map_header)
 Gets Base64 map data, paths, stations, and virtual areas for the specified map.
int setGridMapAllInfo (const MapAllInfo &map_all_info, const Header &command_header={ "99999", "99999", 1, "99999" })
 Sets occupancy grid map, path, station, and virtual area information.
int setPngMapAllInfo (const MapAllInfo &map_all_info, const Header &command_header={ "99999", "99999", 1, "99999" })
 Sets Base64 map, path, station, and virtual area information.
int deleteMapAllInfo (const Header &map_header)
 Deletes all information of the specified map, including map data, stations, paths, and virtual areas.
std::vector< std::string > getWifiList ()
 Gets the currently scanned WiFi list.
int connectWifi (const std::string &ssid, const std::string &password)
 Connects to the specified WiFi and automatically switches to WiFi mode.
int enableHotspot (const std::string &password)
 Enables hotspot mode and automatically switches to hotspot mode.
std::vector< IpAddressInfogetIpAddressList ()
 Gets all local IP addresses.
int changeRunningMode (const RunningMode &running_mode, const Header &command_header={ "99999", "99999", 1, "99999" })
 Switches the AGV running mode.
int setControlSpeed (const Speed &speed)
 Controls AGV motion.
int setNavGoal (const NavGoalType &target)
 Sends a navigation goal to the AGV.
NavInfo getNavInfo ()
 Gets current navigation information.
int pauseAgvSpeed ()
 Pauses AGV speed.
int resumeAgvSpeed ()
 Resumes AGV speed after a pause.
int cancelNavigation ()
 Cancels the navigation task.
int relocation (const Pose2d &init_pose, const Header &command_header={ "99999", "99999", 1, "99999" })
 Relocates the AGV.
std::string getAgvControllerParametersFile ()
 Gets the AGV controller parameter file.
int setAgvControllerParametersFile (const std::string &agv_parameters)
 Sets the AGV controller parameter file.
int refreshAgvControllerParametersFile ()
 Refreshes parameters on AGV nodes after the AGV controller parameter file is modified.
int resetAgvControllerParametersFile ()
 Restores the AGV controller parameter file to factory defaults.
int checkPowerAndAutoCharge (const Header &check_power_header={ "99999", "99999", 99999, "99999" }, const std::string &nav_board_charge_station_id="99999")
 Checks the current battery level and automatically docks for charging when the battery is low.
int setLeaveBoardTargetStation (const Header &leave_board_target_station_header)
 Sets the target station for automatic undocking.
Header getLeaveBoardTargetStation ()
 Gets the target station for automatic undocking.
int forcedAgvToChargingBoard (const Header &forced_charge_header={ "99999", "99999", 99999, "99999" }, const std::string &nav_board_charge_station_id="99999")
 Forces the AGV to dock for charging.
int forcedAgvLeaveChargingBoard (const Header &forced_leave_header={ "99999", "99999", 99999, "99999" }, const std::string &leave_board_target_station_id="99999")
 Forces the AGV to leave the charging board.
int sendAutoChargingCommand (const AutoChargingCommand &auto_charging_command)
 Sends an automatic charging command.
std::string getAgvLogMessage ()
 Gets AGV runtime log messages.
int updateSoftware (const std::string &upgrade_pack_path)
 Upgrades AGV software.
std::vector< std::string > getSoftwareVersionList ()
 Gets the AGV software version list.
int switchSoftwareVersion (const std::string &software_version)
 Switches the AGV software version.
int uninstallSoftware (const std::string &software_version)
 Uninstalls an AGV software version.
int updateFirmware (const FirmwareUpdateParam &update_firmware)
 Updates AGV firmware.
FirmwareUpdateProcessInfo getUpdateFirmwareProcess ()
 Gets firmware update process information.
int startCollectCalibrationData (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" })
 Starts collecting calibration data.
int cancelCollectCalibrationData (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" })
 Cancels calibration data collection.
int startCalibration (const CalibrationType &type, const Header &command_header={ "99999", "99999", 1, "99999" })
 Starts calibration.
CalibrationProcessInfo getCalibrationProcessInfo (const CalibrationType &type)
 Gets calibration information.
int restartAgv ()
 Restarts the AGV.
int setAgvName (const std::string &agv_name)
 Sets the AGV name.
int setPriority (const std::string &name, const std::string &ip="")
 Sets control priority.
int releasePriority ()
 Releases control priority.
int scriptPaused ()
 Pauses the script.
int scriptResume ()
 Resumes the script.
int scriptStop ()
 Stops the script.
ScriptRuntimeState getScriptStatus ()
 Gets the script runtime state.
int setScriptStatus (ScriptRuntimeState status)
 Sets the script runtime state.
std::string errorCodeDecoder (const int &error_code)
 Queries an error code.
std::vector< HeadergetCurrentErrorCodes ()
 Gets current error codes.
int soundLightPrompt ()
 Locates the AGV by automatically playing audio and flashing special lights.
bool isObstacleAhead (const double &detect_distance=1.0)
 Checks whether there is an obstacle in the AGV travel direction.
StationMark getNearestStation (const double &detect_distance=1.0)
 Gets the nearest station within the specified detection distance.
int autoAlignRailway (const Header &command_header={ "99999", "99999", 1, "99999" })
 Automatically aligns with the rail and boards the rail.

Detailed Description

RPC客户端

Definition at line 17 of file rpc.h.

Member Enumeration Documentation

◆ Event

Enumerator
Connected 
Disconnected 

Definition at line 20 of file rpc.h.

Constructor & Destructor Documentation

◆ RpcClient()

agvc_interface::RpcClient::RpcClient ( int mode = 0)

RpcClient.

Parameters
mode0-TCP 1-UDS

◆ ~RpcClient()

agvc_interface::RpcClient::~RpcClient ( )

Member Function Documentation

◆ connect()

int agvc_interface::RpcClient::connect ( const std::string & ip = "",
int port = 0 )

连接到RPC服务

Parameters
ipIP地址
port端口号,RPC的端口号是30104
ip和port为空时,采用unixdomain sockets通讯方式
Return values
0RPC连接成功
-8RPC连接失败,RPC连接被拒绝
-15RPC连接失败,SDK版本与Server版本不兼容

◆ disconnect()

int agvc_interface::RpcClient::disconnect ( )

断开RPC连接

Return values
0成功
-1失败

◆ errorCode()

int agvc_interface::RpcClient::errorCode ( ) const

返回错误代码

Returns

◆ hasConnected()

bool agvc_interface::RpcClient::hasConnected ( ) const

判断是否连接RPC

Return values
true已连接RPC
false未连接RPC

◆ hasLogined()

bool agvc_interface::RpcClient::hasLogined ( )

判断是否登录

Return values
true已登录
false未登录

◆ login()

int agvc_interface::RpcClient::login ( const std::string & usrname,
const std::string & passwd )

登录

Parameters
usrname用户名
passwd密码
Returns
0

◆ logout()

int agvc_interface::RpcClient::logout ( )

登出

Returns
0

◆ setEventHandler()

int agvc_interface::RpcClient::setEventHandler ( std::function< void(int)> cb)

设置事件处理

Parameters
cb
Returns

◆ setExceptionFree()

int agvc_interface::RpcClient::setExceptionFree ( bool enable)

是否关闭异常抛出

Parameters
enable
Returns

◆ setLogHandler()

void agvc_interface::RpcClient::setLogHandler ( std::function< void(int, const char *, int, const std::string &)> handler)

设置日志处理器

此函数可设置自定义的日志处理函数来处理日志消息。
Agvc SDK 有一套默认的日志系统,按照默认的格式输出到默认的文件。 如果用户不希望采用默认的格式或者不希望输出到默认的文件,那就可以通过这个接口重新自定义格式,或者输出路径。 这个函数可以将用户自定义的日志系统与 Agvc SDK 默认的日志系统合并。

Note
setLogHandler函数要放在即将触发的日志之前, 否则会按照默认的形式输出日志。
Parameters
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 表示日志信息
Returns

◆ setRequestTimeout()

int agvc_interface::RpcClient::setRequestTimeout ( int timeout = 10)

设置RPC请求超时时间

Parameters
timeout请求超时时间,单位 ms
Returns
0

The documentation for this class was generated from the following file:
  • include/agvc_interface/rpc.h