Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 代码功能说明: 获取电量/充电状态

    Code Block
    languagecpp
    firstline1
    title获取传感器数据
    linenumberstrue
    	
    		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; 
    			}		
    		}