Page tree
Skip to end of metadata
Go to start of metadata


本页介绍了robot_health的用法, 包含机器人安全状态的输出和清除


本页内容


运行环境准备

  • 软件平台

    • Visual Studio 2010  SP1
    • Slamware Windows SDK:Slamware Windows SDK
    • RoboStudio(用于显示地图):Robostudio installer
    • Sample Code: 

      使用更高版本的Visual Studio可能会带来编译异常。

      使用Visual Studio 2010(无SP1)可能会因为无法与.Net Framework兼容而报编译错误,此时增加SP1更新包即可解决问题

  • 硬件平台

          (以下任选其一)

      • Slamware SDP mini 
      • Slamware SDP
      • Slamware 套装 (基于Slamware导航方案的用户机器人系统)
      • Zeus/Apollo等底盘系统

例程下载

Win32-例程下载


编译运行

  1. 打开samples工程,右键robot_health, 将此工程设置成StartUp project
  2. 右键robot_health, 打开属性选项,将Slamware SDK 的include目录和lib目录添加到工程

    Slamware SDK的include和lib目录无需复制到参考例程目录,只需在Visual Studio里指定路径即可。


  3. 右键robot_health, 在Debugging页面中command Arguments处输入 192.168.11.1 
    格式说明: robot_health <IP address> 


  4. 按下机器人急停按钮(以急停为例),点击F5运行
  5. 查看robostudio的显示

  6. console输出


代码描述

  • 输出机器人的异常状态,并清除

    导航到目标点
            SlamwareCorePlatform sdp = SlamwareCorePlatform::connect(ip_address, 1445);
    		std::cout <<"SDK Version: " << sdp.getSDKVersion() << std::endl;
    		std::cout <<"SDP Version: " << sdp.getSDPVersion() << std::endl;
    
    		while(true){
    			BaseHealthInfo robot_health = sdp.getRobotHealth();
    			if(robot_health.hasError)
    				std::cout << "Error" << std::endl;
    			if(robot_health.hasFatal)
    				std::cout << "Fatal" << std::endl;
    			if(robot_health.hasWarning)
    				std::cout << "Warning" << std::endl;
    			if(*robot_health.hasLidarDisconnected)
    				std::cout << "LidarDisconnected" << std::endl;
    			if(*robot_health.hasSdpDisconnected)
    				std::cout << "SdpDisconnected" << std::endl;
    			if(*robot_health.hasSystemEmergencyStop)
    				std::cout << "SystemEmergencyStop" << std::endl;
    			for (auto it = robot_health.errors.begin();it != robot_health.errors.end(); ++ it) {
    				std::cout << "Message: " << it->message << std::endl;
    				std::cout << "Level: " << it->level << std::endl;
    				std::cout << "ErrorType: "<< it->componentErrorType <<std::endl;
    				std::cout << "ErrorCode: " << it->errorCode << std::endl;
    			}
    
    			int errors_size = robot_health.errors.size();
    			if(errors_size > 0){
    				std::cout << "Press 'y' to clear errors, press any other key to continue..." << std::endl;
    				char is_error_clear;
    				std::cin >> is_error_clear;
    				if(is_error_clear == 'y' || is_error_clear == 'Y') {
    					for (auto it = robot_health.errors.begin();it != robot_health.errors.end(); ++ it) {
    						sdp.clearRobotHealth(it->errorCode);
    						std::cout << "Error: " << it->message << " cleared!" << std::endl;
    					}			
    				}				
    			}
    		}