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()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
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
Implementation of column vector and the associated operations.
static const vpColor blue
static const vpColor green
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
error that can be emitted by ViSP classes.
const char * what() const
void getIMUData(vpColVector *imu_vel, vpColVector *imu_acc, double *ts=nullptr)
bool open(const ST::CaptureSessionSettings &settings)
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void initGraph(unsigned int graphNum, unsigned int curveNbr)
vpImage< unsigned char > I
void setLegend(unsigned int graphNum, unsigned int curveNum, const std::string &legend)
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
void setColor(unsigned int graphNum, unsigned int curveNum, vpColor color)