This example shows how to retrieve data from a sensor connected to a DAQ board. Here we have 1 single main threads that acquires physical values at 100 Hz (10 ms) and records data in recorded-physical-data-sync.txt file.
#include <iostream>
#include <sstream>
#include <visp3/gui/vpPlot.h>
#include <visp3/sensor/vpComedi.h>
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
#ifdef VISP_HAVE_COMEDI
#ifdef VISP_HAVE_DISPLAY
vpPlot scope(1, 700, 700, 100, 200,
std::string(
"ATI physical sensor data (") + comedi.
getPhyDataUnits() + std::string(
")"));
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
for (
unsigned int i = 0; i < comedi.
getNChannel(); i++) {
scope.
setLegend(0, i,
"G" + ((std::ostringstream() << i)).str());
}
#endif
#endif
std::string file("recorded-physical-data-sync.txt");
std::ofstream f(file.c_str());
#ifdef VISP_HAVE_DISPLAY
#else
std::cout << "Data recording during 20 seconds in progress..." << std::endl;
#endif
{
double timestamp = loop_time - start_time;
f << timestamp <<
" " << phydata.
t() << std::endl;
#ifdef VISP_HAVE_DISPLAY
scope.
plot(0, timestamp, phydata);
#endif
}
f.close();
#else
std::cout << "You should install comedi to enable this test..." << std::endl;
#endif
}
Implementation of column vector and the associated operations.
void setChannelNumbers(const unsigned int &nchannel)
void setDevice(const std::string &device)
Set comedi device name. Default value is /dev/comedi0.
unsigned int getNChannel() const
Get number of channels.
vpColVector getPhyData() const
std::string getPhyDataUnits() const
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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)
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()