48 #include <visp3/core/vpIoTools.h> 49 #include <visp3/core/vpMutex.h> 50 #include <visp3/core/vpTime.h> 51 #include <visp3/core/vpThread.h> 52 #include <visp3/sensor/vpForceTorqueAtiSensor.h> 53 #include <visp3/gui/vpPlot.h> 55 #if defined(VISP_HAVE_PTHREAD) 66 #ifndef DOXYGEN_SHOULD_SKIP_THIS 74 t_shared_data s_shared_data;
77 bool s_state_stop =
false;
83 #ifdef VISP_HAVE_DISPLAY 84 vpPlot scope(2, 700, 700, 100, 200,
"ATI F/T sensor data");
87 scope.setTitle(0,
"Forces (N)");
88 scope.setTitle(1,
"Torques (Nm)");
89 scope.setLegend(0, 0,
"x");
90 scope.setLegend(0, 1,
"y");
91 scope.setLegend(0, 2,
"z");
92 scope.setLegend(1, 0,
"x");
93 scope.setLegend(1, 1,
"y");
94 scope.setLegend(1, 2,
"z");
97 t_shared_data shared_data;
98 #ifdef VISP_HAVE_DISPLAY 105 #ifdef VISP_HAVE_DISPLAY 108 shared_data.ft = s_shared_data.ft;
109 shared_data.timestamp = s_shared_data.timestamp;
110 shared_data.bias_state = s_shared_data.bias_state;
115 scope.plot(0, shared_data.timestamp, force);
116 scope.plot(1, shared_data.timestamp, torque);
120 if (shared_data.bias_state == BIAS_DONE)
122 else if (shared_data.bias_state == UNBIAS_DONE)
124 else if (shared_data.bias_state == TO_BIAS)
126 else if (shared_data.bias_state == TO_UNBIAS)
131 if (shared_data.bias_state == BIAS_DONE) shared_data.bias_state = TO_UNBIAS;
132 else if (shared_data.bias_state == UNBIAS_DONE) shared_data.bias_state = TO_BIAS;
135 s_shared_data.bias_state = shared_data.bias_state;
141 #ifdef VISP_HAVE_DISPLAY 152 std::cout <<
"End of scope thread" << std::endl;
156 int main(
int argc,
char** argv)
158 #if defined(VISP_HAVE_ATIDAQ) && defined(VISP_HAVE_COMEDI) 160 #ifdef VISP_HAVE_VIPER850_DATA 163 std::string calibfile = std::string(VISP_VIPER850_DATA_PATH) + std::string(
"/ati/FT17824.cal");
165 std::cout <<
"ATI F/T calib file \"" << calibfile <<
"\" doesn't exist";
170 std::cout <<
"Usage: " << argv[0] <<
" <ATI calibration file FT*.cal]>" << std::endl;
173 std::string calibfile(argv[1]);
179 std::cout <<
"ATI F/T sensor characteristics: \n" << ati << std::endl;
182 std::cout <<
"Data recording in progress..." << std::endl;
185 vpThread thread_scope(scopeFunction);
187 std::string file(
"recorded-ft-sync.txt");
188 std::ofstream f(file.c_str());
190 t_shared_data shared_data;
197 double timestamp = loop_time - start_time;
201 shared_data.bias_state = s_shared_data.bias_state;
203 if (shared_data.bias_state == TO_BIAS) {
204 std::cout <<
"Bias sensor" << std::endl;
206 std::cout <<
"Unbias sensor" << std::endl;
207 shared_data.bias_state = BIAS_DONE;
209 else if (shared_data.bias_state == TO_UNBIAS) {
211 shared_data.bias_state = UNBIAS_DONE;
216 s_shared_data.ft = ft;
217 s_shared_data.timestamp = timestamp;
218 s_shared_data.bias_state = shared_data.bias_state;
222 state_stop = s_state_stop;
225 f << timestamp <<
" " << ft.
t() << std::endl;
235 std::cout <<
"Data recorded in " << file << std::endl;
239 std::cout <<
"You should install comedi and build atidaq to enable this test..." << std::endl;
246 std::cout <<
"You should build this test with threading capabilities..." << std::endl;
Class that allows protection by mutex.
VISP_EXPORT int wait(double t0, double t)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
vpColVector getForceTorque() const
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
vpColVector extract(unsigned int r, unsigned int colsize) const
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
Implementation of column vector and the associated operations.
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void setCalibrationFile(const std::string &calibfile, unsigned short index=1)
static const vpColor blue