36 #include <visp3/core/vpConfig.h>
38 #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS)
39 #include <visp3/robot/vpRobotWireFrameSimulator.h>
40 #include <visp3/robot/vpSimulatorViper850.h>
42 #include "../wireframe-simulator/vpBound.h"
43 #include "../wireframe-simulator/vpScene.h"
44 #include "../wireframe-simulator/vpVwstack.h"
50 vpRobotWireFrameSimulator::vpRobotWireFrameSimulator()
52 artCoord(), artVel(), velocity(), m_thread(), m_mutex_fMi(), m_mutex_eMc(), m_mutex_artVel(), m_mutex_artCoord(),
53 m_mutex_velocity(), m_mutex_display(), m_mutex_robotStop(), m_mutex_frame(), m_mutex_setVelocityCalled(),
54 m_mutex_scene(), displayBusy(false), robotStop(false), jointLimit(false), jointLimitArt(false),
55 singularityManagement(true), cameraParam(),
56 #if defined(VISP_HAVE_DISPLAY)
59 displayType(MODEL_3D), displayAllowed(true), constantSamplingTimeMode(false), setVelocityCalled(false),
62 setSamplingTime(0.010);
66 #if defined(VISP_HAVE_DISPLAY)
67 display.init(I, 0, 0,
"The External view");
75 vpRobotWireFrameSimulator::vpRobotWireFrameSimulator(
bool do_display)
77 artCoord(), artVel(), velocity(), m_thread(), m_mutex_fMi(), m_mutex_eMc(), m_mutex_artVel(), m_mutex_artCoord(),
78 m_mutex_velocity(), m_mutex_display(), m_mutex_robotStop(), m_mutex_frame(), m_mutex_setVelocityCalled(), m_mutex_scene(),
79 displayBusy(false), robotStop(false), jointLimit(false), jointLimitArt(false), singularityManagement(true),
81 #if defined(VISP_HAVE_DISPLAY)
84 displayType(MODEL_3D), displayAllowed(do_display), constantSamplingTimeMode(false), setVelocityCalled(false),
87 setSamplingTime(0.010);
92 #if defined(VISP_HAVE_DISPLAY)
94 this->display.init(I, 0, 0,
"The External view");
112 void vpRobotWireFrameSimulator::initScene(
const vpSceneObject &obj,
const vpSceneDesiredObject &desired_object)
114 m_mutex_scene.lock();
116 free_Bound_scene(&(this->camera));
120 free_Bound_scene(&(this->camera));
122 displayCamera =
false;
123 m_mutex_scene.unlock();
137 void vpRobotWireFrameSimulator::initScene(
const char *obj,
const char *desired_object)
140 free_Bound_scene(&(this->camera));
144 free_Bound_scene(&(this->camera));
146 displayCamera =
false;
161 void vpRobotWireFrameSimulator::initScene(
const vpSceneObject &obj)
164 free_Bound_scene(&(this->camera));
168 free_Bound_scene(&(this->camera));
170 displayCamera =
false;
183 void vpRobotWireFrameSimulator::initScene(
const char *obj)
186 free_Bound_scene(&(this->camera));
190 free_Bound_scene(&(this->camera));
192 displayCamera =
false;
209 if (!sceneInitialized)
216 if ((std::fabs(px_int - 1.) >
vpMath::maximum(px_int, 1.) * std::numeric_limits<double>::epsilon()) &&
217 (std::fabs(py_int - 1) >
vpMath::maximum(py_int, 1.) * std::numeric_limits<double>::epsilon())) {
218 u = (double)I_.
getWidth() / (2 * px_int);
219 v = (double)I_.
getHeight() / (2 * py_int);
226 float o44c[4][4], o44cd[4][4], x, y, z;
227 Matrix
id = IDENTITY_MATRIX;
231 this->cMo = fMit[size_fMi - 1].
inverse() * fMo;
232 this->cMo = rotz * cMo;
234 vp2jlc_matrix(cMo.inverse(), o44c);
235 vp2jlc_matrix(cdMo.inverse(), o44cd);
237 while (get_displayBusy())
240 add_vwstack(
"start",
"cop", o44c[3][0], o44c[3][1], o44c[3][2]);
241 x = o44c[2][0] + o44c[3][0];
242 y = o44c[2][1] + o44c[3][1];
243 z = o44c[2][2] + o44c[3][2];
244 add_vwstack(
"start",
"vrp", x, y, z);
245 add_vwstack(
"start",
"vpn", o44c[2][0], o44c[2][1], o44c[2][2]);
246 add_vwstack(
"start",
"vup", o44c[1][0], o44c[1][1], o44c[1][2]);
247 add_vwstack(
"start",
"window", -u, u, -v, v);
249 display_scene(
id, this->scene, I_, curColor);
251 add_vwstack(
"start",
"cop", o44cd[3][0], o44cd[3][1], o44cd[3][2]);
252 x = o44cd[2][0] + o44cd[3][0];
253 y = o44cd[2][1] + o44cd[3][1];
254 z = o44cd[2][2] + o44cd[3][2];
255 add_vwstack(
"start",
"vrp", x, y, z);
256 add_vwstack(
"start",
"vpn", o44cd[2][0], o44cd[2][1], o44cd[2][2]);
257 add_vwstack(
"start",
"vup", o44cd[1][0], o44cd[1][1], o44cd[1][2]);
258 add_vwstack(
"start",
"window", -u, u, -v, v);
259 if (displayDesiredObject) {
260 if (desiredObject == D_TOOL)
263 display_scene(
id, desiredScene, I_, desColor);
266 set_displayBusy(
false);
283 if (!sceneInitialized)
290 if ((std::fabs(px_int - 1.) >
vpMath::maximum(px_int, 1.) * std::numeric_limits<double>::epsilon()) &&
291 (std::fabs(py_int - 1) >
vpMath::maximum(py_int, 1.) * std::numeric_limits<double>::epsilon())) {
292 u = (double)I.
getWidth() / (2 * px_int);
293 v = (double)I.
getHeight() / (2 * py_int);
300 float o44c[4][4], o44cd[4][4], x, y, z;
301 Matrix
id = IDENTITY_MATRIX;
305 this->cMo = fMit[size_fMi - 1].
inverse() * fMo;
306 this->cMo = rotz * cMo;
308 vp2jlc_matrix(cMo.inverse(), o44c);
309 vp2jlc_matrix(cdMo.inverse(), o44cd);
311 while (get_displayBusy())
314 add_vwstack(
"start",
"cop", o44c[3][0], o44c[3][1], o44c[3][2]);
315 x = o44c[2][0] + o44c[3][0];
316 y = o44c[2][1] + o44c[3][1];
317 z = o44c[2][2] + o44c[3][2];
318 add_vwstack(
"start",
"vrp", x, y, z);
319 add_vwstack(
"start",
"vpn", o44c[2][0], o44c[2][1], o44c[2][2]);
320 add_vwstack(
"start",
"vup", o44c[1][0], o44c[1][1], o44c[1][2]);
321 add_vwstack(
"start",
"window", -u, u, -v, v);
323 display_scene(
id, this->scene, I_, curColor);
326 add_vwstack(
"start",
"cop", o44cd[3][0], o44cd[3][1], o44cd[3][2]);
327 x = o44cd[2][0] + o44cd[3][0];
328 y = o44cd[2][1] + o44cd[3][1];
329 z = o44cd[2][2] + o44cd[3][2];
330 add_vwstack(
"start",
"vrp", x, y, z);
331 add_vwstack(
"start",
"vpn", o44cd[2][0], o44cd[2][1], o44cd[2][2]);
332 add_vwstack(
"start",
"vup", o44cd[1][0], o44cd[1][1], o44cd[1][2]);
333 add_vwstack(
"start",
"window", -u, u, -v, v);
334 if (displayDesiredObject) {
335 if (desiredObject == D_TOOL)
338 display_scene(
id, desiredScene, I_, desColor);
341 set_displayBusy(
false);
354 cMoTemp = fMit[size_fMi - 1].
inverse() * fMo;
359 #elif !defined(VISP_BUILD_SHARED_LIBS)
362 void dummy_vpRobotWireFrameSimulator() { };
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getHeight() const
static Type maximum(const Type &a, const Type &b)
static Type minimum(const Type &a, const Type &b)
This class aims to be a basis used to create all the robot simulators.
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
VISP_EXPORT int wait(double t0, double t)