42 #ifndef vpRobotSimulator_HH
43 #define vpRobotSimulator_HH
50 #include <visp/vpConfig.h>
54 #if defined(WIN32) || defined(VISP_HAVE_PTHREAD)
59 #elif defined(VISP_HAVE_PTHREAD)
63 #include <visp/vpWireFrameSimulator.h>
64 #include <visp/vpRobot.h>
65 #include <visp/vpDisplayOpenCV.h>
66 #include <visp/vpDisplayX.h>
67 #include <visp/vpDisplayGTK.h>
68 #include <visp/vpDisplayGDI.h>
69 #include <visp/vpDisplayD3D.h>
132 #elif defined(VISP_HAVE_PTHREAD)
135 pthread_mutex_t mutex_fMi;
136 pthread_mutex_t mutex_artVel;
137 pthread_mutex_t mutex_artCoord;
138 pthread_mutex_t mutex_velocity;
139 pthread_mutex_t mutex_display;
156 #if defined VISP_HAVE_X11
158 #elif defined VISP_HAVE_GDI
160 #elif defined VISP_HAVE_OPENCV
162 #elif defined VISP_HAVE_D3D9
164 #elif defined VISP_HAVE_GTK
204 void initScene(vpSceneObject obj, vpSceneDesiredObject desiredObject);
205 void initScene(
const char* obj,
const char* desiredObject);
268 if( (std::fabs(px_ext-1.) >
vpMath::maximum(px_ext,1.)*std::numeric_limits<double>::epsilon())
269 && (std::fabs(py_ext-1) >
vpMath::maximum(py_ext,1.)*std::numeric_limits<double>::epsilon()))
314 constantSamplingTimeMode = _constantSamplingTimeMode;
329 samplingTime = _samplingTime;
344 #elif defined(VISP_HAVE_PTHREAD)
345 static void* launcher(
void *arg)
356 virtual void updateArticularPosition() = 0;
358 virtual int isInJointLimit () = 0;
360 virtual void computeArticularVelocity() = 0;
364 virtual void initArms() = 0;
368 WaitForSingleObject(mutex_artCoord,INFINITE);
370 artCoordTmp = artCoord;
371 ReleaseMutex(mutex_artCoord);
374 WaitForSingleObject(mutex_artCoord,INFINITE);
376 ReleaseMutex(mutex_artCoord);}
379 WaitForSingleObject(mutex_artVel,INFINITE);
381 ReleaseMutex(mutex_artVel);
384 WaitForSingleObject(mutex_artVel,INFINITE);
386 ReleaseMutex(mutex_artVel);}
389 WaitForSingleObject(mutex_velocity,INFINITE);
391 ReleaseMutex(mutex_velocity);
394 WaitForSingleObject(mutex_velocity,INFINITE);
396 ReleaseMutex(mutex_velocity);}
399 WaitForSingleObject(mutex_display,INFINITE);
400 displayBusy = status;
401 ReleaseMutex(mutex_display);}
403 WaitForSingleObject(mutex_display,INFINITE);
404 bool status = displayBusy;
405 if (!displayBusy) displayBusy =
true;
406 ReleaseMutex(mutex_display);
409 #elif defined(VISP_HAVE_PTHREAD)
411 pthread_mutex_lock (&mutex_artCoord);
413 artCoordTmp = artCoord;
414 pthread_mutex_unlock (&mutex_artCoord);
417 pthread_mutex_lock (&mutex_artCoord);
419 pthread_mutex_unlock (&mutex_artCoord);}
422 pthread_mutex_lock (&mutex_artVel);
424 pthread_mutex_unlock (&mutex_artVel);
427 pthread_mutex_lock (&mutex_artVel);
429 pthread_mutex_unlock (&mutex_artVel);}
432 pthread_mutex_lock (&mutex_velocity);
434 pthread_mutex_unlock (&mutex_velocity);
437 pthread_mutex_lock (&mutex_velocity);
439 pthread_mutex_unlock (&mutex_velocity);}
441 void set_displayBusy (
const bool &status) {
442 pthread_mutex_lock (&mutex_display);
443 displayBusy = status;
444 pthread_mutex_unlock (&mutex_display);}
445 bool get_displayBusy () {
446 pthread_mutex_lock (&mutex_display);
447 bool status = displayBusy;
448 if (!displayBusy) displayBusy =
true;
449 pthread_mutex_unlock (&mutex_display);
unsigned int jointLimitArt
vpCameraParameters getExternalCameraParameters() const
Definition of the vpMatrix class.
vpHomogeneousMatrix * fMi
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get a displacement (frame as to ve specified) between two successive position control.
vpColVector get_velocity()
unsigned int getWidth() const
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void setSamplingTime(const float _samplingTime)
Display for windows using GDI (available on any windows 32 platform).
Class to define colors available for display functionnalities.
void set_artVel(const vpColVector &vel)
void setCurrentViewColor(const vpColor col)
Define the X11 console to display images.
void setCameraColor(const vpColor col)
virtual void get_eJe(vpMatrix &_eJe)=0
Get the robot Jacobian expressed in the end-effector frame.
vpHomogeneousMatrix getExternalCameraPosition() const
void setConstantSamplingTimeMode(const bool _constantSamplingTimeMode)
class that defines a generic virtual robot
void set_artCoord(const vpColVector &coord)
static DWORD WINAPI launcher(LPVOID lpParam)
static Type maximum(const Type &a, const Type &b)
vpColVector get_artCoord()
vpHomogeneousMatrix get_fMo() const
virtual void getArticularDisplacement(vpColVector &qdot)=0
Get a displacement expressed in the joint space between two successive position control.
Display for windows using Direct3D.
void setDesiredViewColor(const vpColor col)
void setExternalCameraPosition(const vpHomogeneousMatrix camMf)
virtual void getCameraDisplacement(vpColVector &v)=0
Get a displacement expressed in the camera frame between two successive position control.
This class aims to be a basis used to create all the simulators of robots.
void setDesiredCameraPosition(const vpHomogeneousMatrix cdMo)
bool constantSamplingTimeMode
Flag used to force the sampling time in the thread computing the robot's displacement to a constant v...
void setSingularityManagement(const bool sm)
The vpDisplayOpenCV allows to display image using the opencv library.
void set_velocity(const vpColVector &vel)
Generic class defining intrinsic camera parameters.
void set_fMo(const vpHomogeneousMatrix &fMo)
virtual void get_fJe(vpMatrix &_fJe)=0
Get the robot Jacobian expressed in the robot reference (or world) frame.
void setExternalCameraPosition(const vpHomogeneousMatrix camMf)
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
bool singularityManagement
void setDesiredCameraPosition(const vpHomogeneousMatrix cdMo)
static Type minimum(const Type &a, const Type &b)
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
bool setVelocityCalled
Flag used to specify to the thread managing the robot displacements that the setVelocity() method has...
vpCameraParameters cameraParam
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpHomogeneousMatrix get_cMo() const
void initScene(vpSceneObject obj, vpSceneDesiredObject desiredObject)
void setDisplayRobotType(const vpDisplayRobotType dispType)
unsigned int getHeight() const
vpDisplayRobotType displayType
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
Set the velocity (frame has to be specified) that will be applied to the velocity controller...
static double minTimeForUsleepCall
vpHomogeneousMatrix getExternalCameraPosition() const
void set_displayBusy(const bool &status)