This example shows how to retrieve IMU data from a Occipital Structure Core sensor with libStructure.
#include <iostream>
#include <visp3/core/vpConfig.h>
#if defined( VISP_HAVE_OCCIPITAL_STRUCTURE ) && ( VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11 )
#include <visp3/gui/vpPlot.h>
#include <visp3/sensor/vpOccipitalStructure.h>
int
main()
{
try
{
double initial_ts, ts;
ST::CaptureSessionSettings settings;
settings.source = ST::CaptureSessionSourceId::StructureCore;
settings.structureCore.depthEnabled = true;
settings.structureCore.visibleEnabled = true;
settings.structureCore.accelerometerEnabled = true;
settings.structureCore.gyroscopeEnabled = true;
settings.structureCore.imuUpdateRate = ST::StructureCoreIMUUpdateRate::AccelAndGyro_1000Hz;
vpPlot acceleration_plotter( 1, 400, 800, 10, 10,
"Accelerations" );
vpPlot rotationRate_plotter( 1, 400, 800, 10, 450,
"Rotation rates" );
acceleration_plotter.
plot( 0, 0, 0, 0 );
acceleration_plotter.
plot( 0, 1, 0, 0 );
acceleration_plotter.
plot( 0, 2, 0, 0 );
rotationRate_plotter.
plot( 0, 0, 0, 0 );
rotationRate_plotter.
plot( 0, 1, 0, 0 );
rotationRate_plotter.
plot( 0, 2, 0, 0 );
acceleration_plotter.
setLegend( 0, 0,
"X axis" );
acceleration_plotter.
setLegend( 0, 1,
"Y axis" );
acceleration_plotter.
setLegend( 0, 2,
"Z axis" );
rotationRate_plotter.
setLegend( 0, 0,
"X axis" );
rotationRate_plotter.
setLegend( 0, 1,
"Y axis" );
rotationRate_plotter.
setLegend( 0, 2,
"Z axis" );
bool quit = false;
while ( !quit )
{
acceleration_plotter.
plot( 0, ts - initial_ts, imu_acc );
rotationRate_plotter.
plot( 0, ts - initial_ts, imu_vel );
{
quit = true;
}
}
}
{
std::cerr <<
"Structure SDK error " << e.
what() << std::endl;
}
catch ( const std::exception &e )
{
std::cerr << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
#else
int
main()
{
#if !defined( VISP_HAVE_OCCIPITAL_STRUCTURE )
std::cout << "You do not have Occipital Structure SDK functionality enabled..." << std::endl;
std::cout << "Tip:" << std::endl;
std::cout << "- Install libStructure, configure again ViSP using cmake and build again this example" << std::endl;
return EXIT_SUCCESS;
#elif ( VISP_CXX_STANDARD < VISP_CXX_STANDARD_11 )
std::cout << "You do not build ViSP with c++11 or higher compiler flag" << std::endl;
std::cout << "Tip:" << std::endl;
std::cout << "- Configure ViSP again using cmake -DUSE_CXX_STANDARD=11, and build again this example" << std::endl;
#endif
return EXIT_SUCCESS;
}
#endif