This document introduces the demo project of "robot_health", including how to get and clear the error status information of robot. |
Content
Sample Code:
Higher version of Visual Studio will cause errors. Sometime you will need to upgrade SP1 package to make your VS compatable with .Net Framework. |
(Either one of following)
Right click on "robot_health", then " Properties",configure "include" and "lib" directories to the corresponding folder path of Slamware SDK.
It's not necessary to copy files to the project directory, user will only need to configure the path of SDK. |
Print the error status information and clear it
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; } } } } |