This document introduces the demo project of "go_sensor_value", including how to get the data of sersors like type,installation position and value. |
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 "get_sensor_value", 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. |
Get the data of the sensors
SlamwareCorePlatform sdp = SlamwareCorePlatform::connect(argv[1], 1445); std::cout <<"SDK Version: " << sdp.getSDKVersion() << std::endl; std::cout <<"SDP Version: " << sdp.getSDPVersion() << std::endl; std::vector<ImpactSensorInfo> sensors; bool result = sdp.getSensors(sensors); if (result) { for (std::vector<ImpactSensorInfo>::iterator it = sensors.begin(); it != sensors.end(); ++it) { std::cout << "Sensor id : " << it->id << std::endl; if (it->kind == ImpactSensorKindBumper) std::cout << "Sensor Kind: Bumper" << std::endl; else if (it->kind == ImpactSensorKindCliff) std::cout << "Sensor Kind: Cliff" << std::endl; else if (it->kind == ImpactSensorKindSonar) std::cout << "Sensor Kind: Sonar" << std::endl; else return 1; if (it->type == ImpactSensorTypeAnalog) std::cout << "Sensor Type: Analog" << std::endl; else if (it->type == ImpactSensorTypeDigital) std::cout << "Sensor Type: Digital" << std::endl; else return 1; std::cout << "Sensor Position: ( " << it->pose.x() << " , " << it->pose.y() << " , " << \ it->pose.z() << " ) ; Yaw = " << it->pose.yaw() << std::endl; ImpactSensorValue value; sdp.getSensorValue(it->id, value); std::cout << "Sensor Value : " << value.value<< std::endl; } } |