Visual Servoing Platform
version 3.5.1 under development (2023-09-22)
|
#include <visp3/ar/vpSimulator.h>
Public Types | |
enum | vpImageType { grayImage , colorImage } |
enum | vpSimulatorViewType { INTERNAL , EXTERNAL } |
Public Member Functions | |
vpSimulator () | |
virtual | ~vpSimulator () |
virtual void | mainLoop () |
virtual void | initInternalViewer (unsigned int nlig, unsigned int ncol) |
void | initExternalViewer (unsigned int nlig, unsigned int ncol) |
void | initApplication (void *(*start_routine)(void *)) |
void | initApplication (void *(*start_routine)(void *), void *data) |
void | initMainApplication () |
void | closeMainApplication () |
unsigned int | getInternalWidth () const |
unsigned int | getInternalHeight () const |
void | addObject (SoSeparator *newObject, const vpHomogeneousMatrix &fMo) |
void | redraw () |
void | load (const char *file_name) |
void | load (const char *iv_filename, const vpHomogeneousMatrix &fMo) |
void | save (const char *name, bool binary=false) |
void | addAbsoluteFrame (float zoom=1) |
void | addFrame (const vpHomogeneousMatrix &fMo, float zoom=1) |
void | setZoomFactor (float zoom) |
void | setCameraPosition (vpHomogeneousMatrix &cMf) |
void | getCameraPosition (vpHomogeneousMatrix &_cMf) |
void | moveInternalCamera (vpHomogeneousMatrix &cMf) |
void | setInternalCameraParameters (vpCameraParameters &cam) |
void | setExternalCameraParameters (vpCameraParameters &cam) |
void | getExternalCameraPosition (vpHomogeneousMatrix &cMf) |
void | getInternalImage (vpImage< unsigned char > &I) |
void | getInternalImage (vpImage< vpRGBa > &I) |
void | changeZoomFactor (float zoom, int index) |
void | write (const char *fileName) |
unsigned char * | getBufferedOffScreenRenderer () |
void | getSizeInternalView (int &width, int &height) |
void | getCameraParameters (vpCameraParameters &cam) |
Public Attributes | |
vpImageType | typeImage |
GLubyte * | image_background |
unsigned char * | bufferView |
int | get |
Protected Member Functions | |
void | init () |
void | kill () |
void | initSoApplication () |
void | initSceneGraph () |
void | addObject (SoSeparator *object, const vpHomogeneousMatrix &fMo, SoSeparator *root) |
void | offScreenRendering (vpSimulatorViewType view=vpSimulator::EXTERNAL, int *width=NULL, int *height=NULL) |
Protected Attributes | |
HWND | mainWindow |
bool | mainWindowInitialized |
vpViewer * | internalView |
vpViewer * | externalView |
SbThread * | mainThread |
unsigned int | internal_width |
unsigned int | internal_height |
unsigned int | external_width |
unsigned int | external_height |
SoSeparator * | scene |
SoSeparator * | internalRoot |
SoSeparator * | externalRoot |
SoPerspectiveCamera * | internalCamera |
SoPerspectiveCamera * | externalCamera |
SoTransform * | internalCameraPosition |
SoTransform * | extrenalCameraPosition |
SoSeparator * | internalCameraObject |
float | zoomFactor |
bool | cameraPositionInitialized |
vpHomogeneousMatrix | cMf |
vpCameraParameters | internalCameraParameters |
vpCameraParameters | externalCameraParameters |
SbTime * | realtime |
SoOffscreenRenderer * | offScreenRenderer |
Implementation of a simulator based on Coin3d (www.coin3d.org).
The simulator uses the vpViewer class.
Definition at line 98 of file vpSimulator.h.
Enumerator | |
---|---|
grayImage | |
colorImage |
Definition at line 127 of file vpSimulator.h.
Enumerator | |
---|---|
INTERNAL | |
EXTERNAL |
Definition at line 267 of file vpSimulator.h.
vpSimulator::vpSimulator | ( | ) |
|
virtual |
Definition at line 344 of file vpSimulator.cpp.
References kill().
void vpSimulator::addAbsoluteFrame | ( | float | zoom = 1 | ) |
Add the representation of the absolute frame.
zoom | : Zoom factor. |
Definition at line 726 of file vpSimulator.cpp.
References scene.
void vpSimulator::addFrame | ( | const vpHomogeneousMatrix & | fMo, |
float | zoom = 1 |
||
) |
Add the representation of a frame.
Add the representation of a frame.
fMo | : desired position of the frame |
zoom | : Zoom factor. |
Definition at line 707 of file vpSimulator.cpp.
References addObject(), and externalRoot.
void vpSimulator::addObject | ( | SoSeparator * | newObject, |
const vpHomogeneousMatrix & | fMo | ||
) |
Add a new object in the scene graph ad a given location.
Add a new object in the scene graph.
newObject | : pointer toward the new object |
fMo | : position of the object wrt the reference frame |
Definition at line 764 of file vpSimulator.cpp.
References addObject(), scene, and vpERROR_TRACE.
|
protected |
Add a new object in the scene graph ad a given location.
Add an object in a sub scene graph.
object | : pointer toward the new object |
fMo | : position of the object wrt the reference frame |
root | : pointer toward the subscene graph |
Definition at line 781 of file vpSimulator.cpp.
Referenced by addFrame(), addObject(), and load().
void vpSimulator::changeZoomFactor | ( | float | zoomFactor, |
int | index | ||
) |
Change the zoom factor associated to the child given by index. In order to create multiple zoom factor for multiple object to display, objects loaded the load() function, you have to know the index of the scale object associated to.
Usually, if you define the main zoom factor (for example for the frames) and then load two differents objects, You can change the zoom factor of all the objects using: changeZoomFactor(newZoom, 0)
If you want to change the zoom factor of the first object, use changeZoomFactor(newZoom, 1)
And for the second object, use changeZoomFactor(newZoom, 3)
zoomFactor | : the new zoom use to specify the apparent size of the object |
index | : the index of the Scale object to modify (see comments) |
Definition at line 442 of file vpSimulator.cpp.
References scene, and zoomFactor.
void vpSimulator::closeMainApplication | ( | ) |
performed some thread destruction in the main program thread should be locate at the end of the main program
Definition at line 852 of file vpSimulator.cpp.
|
inline |
get the image corresponding to the internal view
Definition at line 286 of file vpSimulator.h.
|
inline |
get the intrinsic parameters of the camera
Definition at line 292 of file vpSimulator.h.
|
inline |
get the camera position (from an homogeneous matrix)
Definition at line 248 of file vpSimulator.h.
void vpSimulator::getExternalCameraPosition | ( | vpHomogeneousMatrix & | cMf | ) |
get the external camera position
Definition at line 545 of file vpSimulator.cpp.
References cMf, externalCamera, and vpHomogeneousMatrix::inverse().
|
inline |
Return the height of the internal view.
Definition at line 179 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw().
void vpSimulator::getInternalImage | ( | vpImage< unsigned char > & | I | ) |
get an Image of the internal view
Make a copy of the current internal view
I | : destination image |
Definition at line 989 of file vpSimulator.cpp.
References vpImage< Type >::bitmap, bufferView, get, internal_height, internal_width, vpImage< Type >::resize(), and vpImageConvert::RGBToGrey().
get an Image of the internal view
Make a copy of the current internal view
I | : destination image |
Definition at line 976 of file vpSimulator.cpp.
References vpImage< Type >::bitmap, bufferView, get, internal_height, internal_width, vpImage< Type >::resize(), and vpImageConvert::RGBToRGBa().
|
inline |
Return the width of the internal view.
Definition at line 173 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw().
void vpSimulator::getSizeInternalView | ( | int & | width, |
int & | height | ||
) |
get the size of the internal view
Definition at line 964 of file vpSimulator.cpp.
References internalView.
|
protected |
perform some initialization
Definition at line 267 of file vpSimulator.cpp.
References bufferView, cameraPositionInitialized, external_height, external_width, externalCamera, externalRoot, externalView, extrenalCameraPosition, get, grayImage, image_background, internal_height, internal_width, internalCamera, internalCameraObject, internalCameraPosition, internalRoot, internalView, mainThread, mainWindow, mainWindowInitialized, offScreenRenderer, realtime, scene, typeImage, and zoomFactor.
Referenced by vpSimulator().
void vpSimulator::initApplication | ( | void *(*)(void *) | start_routine | ) |
begin the main program
init the main program thread
Definition at line 822 of file vpSimulator.cpp.
References mainThread.
void vpSimulator::initApplication | ( | void *(*)(void *) | start_routine, |
void * | data | ||
) |
Set the function used for the simulation loop and the data to pass to this function. As the data are represented using a generic pointer, care should be taken to ensure there is no memory corruption.
start_routine | : A pointer to the function used as a main simulation loop for the simulation. |
data | : The data to pass to the main loop. |
Definition at line 837 of file vpSimulator.cpp.
References mainThread.
void vpSimulator::initExternalViewer | ( | unsigned int | nlig, |
unsigned int | ncol | ||
) |
initialize the external view
Definition at line 483 of file vpSimulator.cpp.
References external_height, external_width, externalRoot, externalView, vpViewer::externalView, initSceneGraph(), initSoApplication(), mainWindow, mainWindowInitialized, and vpViewer::resize().
|
virtual |
initialize the camera view
Definition at line 449 of file vpSimulator.cpp.
References bufferView, initSceneGraph(), initSoApplication(), internal_height, internal_width, internalRoot, internalView, vpViewer::internalView, mainWindow, mainWindowInitialized, and vpViewer::resize().
Referenced by vpAR::initInternalViewer().
void vpSimulator::initMainApplication | ( | ) |
perform some initialization in the main program thread
performed some initialization in the main program thread should be locate at the beginning of the main program
Definition at line 844 of file vpSimulator.cpp.
References vpTime::wait().
|
protected |
initialize the scene graph
Definition at line 352 of file vpSimulator.cpp.
References externalCamera, externalRoot, internalCamera, internalCameraObject, internalCameraPosition, internalRoot, realtime, scene, and zoomFactor.
Referenced by initExternalViewer(), and initInternalViewer().
|
protected |
open the SoGui application
Definition at line 346 of file vpSimulator.cpp.
References mainWindow, and mainWindowInitialized.
Referenced by initExternalViewer(), and initInternalViewer().
|
protected |
perform some destruction
Definition at line 305 of file vpSimulator.cpp.
References bufferView, externalView, image_background, and internalView.
Referenced by vpAR::~vpAR(), and ~vpSimulator().
void vpSimulator::load | ( | const char * | file_name | ) |
load an iv file
loading the virtual scene
Definition at line 661 of file vpSimulator.cpp.
References scene, vpERROR_TRACE, and zoomFactor.
void vpSimulator::load | ( | const char * | iv_filename, |
const vpHomogeneousMatrix & | fMo | ||
) |
load an iv file, set the location of this scene
Add a new object in the scene graph.
iv_filename | : name of.iv file to load |
fMo | : position of the object wrt the reference frame |
Definition at line 736 of file vpSimulator.cpp.
References addObject(), and vpERROR_TRACE.
|
virtual |
activate the mainloop
Definition at line 641 of file vpSimulator.cpp.
References mainWindowInitialized, vpERROR_TRACE, and vpTime::wait().
void vpSimulator::moveInternalCamera | ( | vpHomogeneousMatrix & | cMf | ) |
modify the position of the camera in the scene graph
Definition at line 584 of file vpSimulator.cpp.
References cMf, internalCamera, internalCameraPosition, and vpHomogeneousMatrix::inverse().
Referenced by redraw().
|
protected |
Definition at line 868 of file vpSimulator.cpp.
References externalView, INTERNAL, internalView, offScreenRenderer, and vpERROR_TRACE.
void vpSimulator::redraw | ( | ) |
display the scene (handle with care)
this function MUST NOT be called from a thread where the vpSimulator and its mainloop are not
Definition at line 616 of file vpSimulator.cpp.
References cMf, externalView, internalView, and moveInternalCamera().
void vpSimulator::save | ( | const char * | name, |
bool | binary = false |
||
) |
void vpSimulator::setCameraPosition | ( | vpHomogeneousMatrix & | cMf | ) |
set the camera position (from an homogeneous matrix)
Definition at line 579 of file vpSimulator.cpp.
References cameraPositionInitialized, and cMf.
void vpSimulator::setExternalCameraParameters | ( | vpCameraParameters & | cam | ) |
set external camera parameters
Definition at line 527 of file vpSimulator.cpp.
References external_height, external_width, externalCamera, externalCameraParameters, vpCameraParameters::get_px(), and vpCameraParameters::get_py().
void vpSimulator::setInternalCameraParameters | ( | vpCameraParameters & | cam | ) |
set internal camera parameters
Definition at line 510 of file vpSimulator.cpp.
References vpCameraParameters::get_px(), vpCameraParameters::get_py(), internal_height, internal_width, internalCamera, and internalCameraParameters.
void vpSimulator::setZoomFactor | ( | float | zoom | ) |
set the size of the camera/frame
Define the zoom factor used to define the size of the objects (frame, camera, ...)
zoom | zoom factor of the objects. By default, 1. |
Definition at line 409 of file vpSimulator.cpp.
References scene, and zoomFactor.
void vpSimulator::write | ( | const char * | fileName | ) |
Definition at line 934 of file vpSimulator.cpp.
References bufferView, get, internal_height, internal_width, vpTRACE, and vpImageIo::write().
unsigned char* vpSimulator::bufferView |
image of the internal view
Definition at line 278 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw(), getInternalImage(), init(), initInternalViewer(), kill(), and write().
|
protected |
Definition at line 236 of file vpSimulator.h.
Referenced by init(), and setCameraPosition().
|
protected |
internal camera position
Definition at line 238 of file vpSimulator.h.
Referenced by getExternalCameraPosition(), moveInternalCamera(), redraw(), and setCameraPosition().
|
protected |
Definition at line 165 of file vpSimulator.h.
Referenced by init(), initExternalViewer(), and setExternalCameraParameters().
|
protected |
Definition at line 164 of file vpSimulator.h.
Referenced by init(), initExternalViewer(), and setExternalCameraParameters().
|
protected |
external camera
Definition at line 193 of file vpSimulator.h.
Referenced by getExternalCameraPosition(), init(), initSceneGraph(), and setExternalCameraParameters().
|
protected |
internal camera parameters
Definition at line 242 of file vpSimulator.h.
Referenced by setExternalCameraParameters().
|
protected |
root node of the external view
Definition at line 188 of file vpSimulator.h.
Referenced by addFrame(), init(), initExternalViewer(), and initSceneGraph().
|
protected |
view from an external camera
Definition at line 138 of file vpSimulator.h.
Referenced by init(), initExternalViewer(), kill(), offScreenRendering(), and redraw().
|
protected |
int vpSimulator::get |
Flag to protect the read and write of the framebuffer (between the simulator and the viewer).
Definition at line 282 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw(), getInternalImage(), init(), and write().
GLubyte* vpSimulator::image_background |
Definition at line 130 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw(), init(), vpAR::initInternalViewer(), kill(), and vpAR::setImage().
|
protected |
Definition at line 163 of file vpSimulator.h.
Referenced by getInternalImage(), init(), initInternalViewer(), vpAR::initInternalViewer(), vpAR::setImage(), setInternalCameraParameters(), and write().
|
protected |
Definition at line 162 of file vpSimulator.h.
Referenced by getInternalImage(), init(), initInternalViewer(), vpAR::initInternalViewer(), vpAR::setImage(), setInternalCameraParameters(), and write().
|
protected |
internal camera
Definition at line 191 of file vpSimulator.h.
Referenced by init(), initSceneGraph(), moveInternalCamera(), and setInternalCameraParameters().
|
protected |
representation of the camera in the external view
Definition at line 202 of file vpSimulator.h.
Referenced by init(), and initSceneGraph().
|
protected |
internal camera parameters
Definition at line 240 of file vpSimulator.h.
Referenced by setInternalCameraParameters().
|
protected |
internal camera position
Definition at line 196 of file vpSimulator.h.
Referenced by init(), initSceneGraph(), and moveInternalCamera().
|
protected |
root node of the internal view
Definition at line 186 of file vpSimulator.h.
Referenced by init(), initInternalViewer(), and initSceneGraph().
|
protected |
view from the camera
Definition at line 136 of file vpSimulator.h.
Referenced by getSizeInternalView(), init(), initInternalViewer(), kill(), offScreenRendering(), and redraw().
|
protected |
thread with the main program
Definition at line 148 of file vpSimulator.h.
Referenced by init(), and initApplication().
|
protected |
main Widget
Definition at line 114 of file vpSimulator.h.
Referenced by init(), initExternalViewer(), initInternalViewer(), and initSoApplication().
|
protected |
Definition at line 121 of file vpSimulator.h.
Referenced by init(), initExternalViewer(), initInternalViewer(), initSoApplication(), and mainLoop().
|
protected |
Definition at line 273 of file vpSimulator.h.
Referenced by init(), and offScreenRendering().
|
protected |
Definition at line 272 of file vpSimulator.h.
Referenced by init(), and initSceneGraph().
|
protected |
root node of the scene : contains everything except stuff specific to each view
Definition at line 184 of file vpSimulator.h.
Referenced by addAbsoluteFrame(), addObject(), changeZoomFactor(), init(), initSceneGraph(), load(), save(), and setZoomFactor().
vpImageType vpSimulator::typeImage |
Definition at line 128 of file vpSimulator.h.
Referenced by vpViewer::actualRedraw(), init(), and vpAR::initInternalViewer().
|
protected |
Definition at line 232 of file vpSimulator.h.
Referenced by changeZoomFactor(), init(), initSceneGraph(), load(), and setZoomFactor().