50 #include <visp3/core/vpIoTools.h> 51 #include <visp3/core/vpMutex.h> 52 #include <visp3/core/vpThread.h> 53 #include <visp3/core/vpTime.h> 54 #include <visp3/gui/vpPlot.h> 55 #include <visp3/sensor/vpForceTorqueAtiSensor.h> 57 #if defined(VISP_HAVE_PTHREAD) 59 typedef enum { BIAS_DONE, UNBIAS_DONE, TO_BIAS, TO_UNBIAS } BiasState;
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS 71 t_shared_data s_shared_data;
74 bool s_state_stop =
false;
80 #ifdef VISP_HAVE_DISPLAY 81 vpPlot scope(2, 700, 700, 100, 200,
"ATI F/T sensor data");
82 scope.initGraph(0, 3);
83 scope.initGraph(1, 3);
84 scope.setTitle(0,
"Forces (N)");
85 scope.setTitle(1,
"Torques (Nm)");
86 scope.setLegend(0, 0,
"x");
87 scope.setLegend(0, 1,
"y");
88 scope.setLegend(0, 2,
"z");
89 scope.setLegend(1, 0,
"x");
90 scope.setLegend(1, 1,
"y");
91 scope.setLegend(1, 2,
"z");
94 t_shared_data shared_data;
95 #ifdef VISP_HAVE_DISPLAY 102 #ifdef VISP_HAVE_DISPLAY 105 shared_data.ft = s_shared_data.ft;
106 shared_data.timestamp = s_shared_data.timestamp;
107 shared_data.bias_state = s_shared_data.bias_state;
112 scope.plot(0, shared_data.timestamp, force);
113 scope.plot(1, shared_data.timestamp, torque);
117 if (shared_data.bias_state == BIAS_DONE)
119 else if (shared_data.bias_state == UNBIAS_DONE)
121 else if (shared_data.bias_state == TO_BIAS)
123 else if (shared_data.bias_state == TO_UNBIAS)
128 if (shared_data.bias_state == BIAS_DONE)
129 shared_data.bias_state = TO_UNBIAS;
130 else if (shared_data.bias_state == UNBIAS_DONE)
131 shared_data.bias_state = TO_BIAS;
134 s_shared_data.bias_state = shared_data.bias_state;
140 #ifdef VISP_HAVE_DISPLAY 151 std::cout <<
"End of scope thread" << std::endl;
155 int main(
int argc,
char **argv)
157 #if defined(VISP_HAVE_ATIDAQ) && defined(VISP_HAVE_COMEDI) 159 #ifdef VISP_HAVE_VIPER850_DATA 162 std::string calibfile = std::string(VISP_VIPER850_DATA_PATH) + std::string(
"/ati/FT17824.cal");
164 std::cout <<
"ATI F/T calib file \"" << calibfile <<
"\" doesn't exist";
169 std::cout <<
"Usage: " << argv[0] <<
" <ATI calibration file FT*.cal]>" << std::endl;
172 std::string calibfile(argv[1]);
178 std::cout <<
"ATI F/T sensor characteristics: \n" << ati << std::endl;
181 std::cout <<
"Data recording in progress..." << std::endl;
184 vpThread thread_scope(scopeFunction);
186 std::string file(
"recorded-ft-sync.txt");
187 std::ofstream f(file.c_str());
189 t_shared_data shared_data;
196 double timestamp = loop_time - start_time;
200 shared_data.bias_state = s_shared_data.bias_state;
202 if (shared_data.bias_state == TO_BIAS) {
203 std::cout <<
"Bias sensor" << std::endl;
205 std::cout <<
"Unbias sensor" << std::endl;
206 shared_data.bias_state = BIAS_DONE;
207 }
else if (shared_data.bias_state == TO_UNBIAS) {
209 shared_data.bias_state = UNBIAS_DONE;
214 s_shared_data.ft = ft;
215 s_shared_data.timestamp = timestamp;
216 s_shared_data.bias_state = shared_data.bias_state;
220 state_stop = s_state_stop;
223 f << timestamp <<
" " << ft.
t() << std::endl;
225 }
while (!state_stop);
232 std::cout <<
"Data recorded in " << file << std::endl;
236 std::cout <<
"You should install comedi and build atidaq to enable this test..." << std::endl;
241 int main() { 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)
vpColVector extract(unsigned int r, unsigned int colsize) const
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)
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