openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
orshowsensors.cpp
Author
Rosen Diankov

Shows how to toggle sensor power and rendering options

showsensors_camera.jpg
Camera Sensor.
showsensors_laser.jpg
Laser Sensor.

Full Example Code:

#include <openrave-core.h>
#include <vector>
#include "orexample.h"
using namespace OpenRAVE;
using namespace std;
namespace cppexamples {
class ShowSensorsExample : public OpenRAVEExample
{
public:
virtual void demothread(int argc, char ** argv) {
penv->Load("data/testwamcamera.env.xml");
size_t ienablesensor = 0;
// get all the sensors, this includes all attached robot sensors
std::vector<SensorBasePtr> sensors;
penv->GetSensors(sensors);
while(IsOk()) {
for(size_t isensor = 0; isensor < sensors.size(); ++isensor) {
sensors[isensor]->Configure(isensor == ienablesensor ? SensorBase::CC_PowerOn : SensorBase::CC_PowerOff);
sensors[isensor]->Configure(isensor == ienablesensor ? SensorBase::CC_RenderDataOn : SensorBase::CC_RenderDataOff);
}
ienablesensor = (ienablesensor+1)%sensors.size();
boost::this_thread::sleep(boost::posix_time::seconds(5));
}
}
};
} // end namespace cppexamples
int main(int argc, char ** argv)
{
return example.main(argc,argv);
}