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
IDE Preperation
Software
- Visual Studio 2010 SP1
- Slamware Windows SDK:Slamware Windows SDK
- RoboStudio(for map display):Robostudio installer
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.
Hardware
(Either one of following)
- Slamware SDP mini
- Slamware SDP
- Slamware Kit
- Zeus/Apollo robot base
Download
Compiling
- Right click on "get_sensor_value" project, set as StartUp project.
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.
- Right click on "get_sensor_value", then "properties",set "Command Arguments" as follows:
Syntax :get_sensor_value <IP address>> - Click " F5" to execute.
- The output from console will be as follows(0, 1 is used to indicate the trigger state of the bumper. If it's triggered, the value is 0.):
Code
Get the data of the sensors
Get the data of the sensorsSlamwareCorePlatform 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; } }