openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
OpenRAVE::ViewerBase Class Referenceabstract

[interface] Base class for the graphics and gui engine that renders the environment and provides visual sensor information. If not specified, method is not multi-thread safe. See Viewer Concepts. More...

#include <viewer.h>

Inheritance diagram for OpenRAVE::ViewerBase:
Inheritance graph
[legend]
Collaboration diagram for OpenRAVE::ViewerBase:
Collaboration graph
[legend]

Public Types

enum  ViewerEvents { VE_ItemSelection = 1 }
 
typedef boost::function< bool(KinBody::LinkPtr
plink, RaveVector< float >
, RaveVector< float >)> 
ItemSelectionCallbackFn
 callback function for item selection
 
typedef boost::function< void(const
uint8_t *, int, int, int)> 
ViewerImageCallbackFn
 callback function for item selection callback(imagememory,width,height,pixeldepth)
 
typedef boost::function< void()> ViewerThreadCallbackFn
 callback function for viewer thread
 
typedef
ItemSelectionCallbackFn
ViewerCallbackFn 
RAVE_DEPRECATED
 
- Public Types inherited from OpenRAVE::InterfaceBase
typedef std::map< std::string,
XMLReadablePtr,
CaseInsensitiveCompare
READERSMAP
 

Public Member Functions

 ViewerBase (EnvironmentBasePtr penv)
 
virtual ~ViewerBase ()
 
virtual void RemoveKinBody (KinBodyPtr pbody) OPENRAVE_DUMMY_IMPLEMENTATION
 notified when a body has been removed from the environment
 
virtual int main (bool bShow=true)=0
 goes into the main loop
 
virtual void quitmainloop ()=0
 destroys the main loop
 
virtual void Reset () OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual void SetBkgndColor (const RaveVector< float > &color) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual UserDataPtr RegisterItemSelectionCallback (const ItemSelectionCallbackFn &fncallback) OPENRAVE_DUMMY_IMPLEMENTATION
 registers a function with the viewer that gets called everytime mouse button is clicked
 
virtual UserDataPtr RegisterViewerImageCallback (const ViewerImageCallbackFn &fncallback) OPENRAVE_DUMMY_IMPLEMENTATION
 registers a function with the viewer that gets called for every new image rendered.
 
virtual UserDataPtr RegisterViewerThreadCallback (const ViewerThreadCallbackFn &fncallback) OPENRAVE_DUMMY_IMPLEMENTATION
 registers a function with the viewer that gets called in the viewer's GUI thread for every cycle the viewer refreshes at
 
virtual void SetEnvironmentSync (bool bUpdate) OPENRAVE_DUMMY_IMPLEMENTATION
 controls whether the viewer synchronizes with the newest environment automatically
 
virtual void EnvironmentSync () OPENRAVE_DUMMY_IMPLEMENTATION
 forces synchronization with the environment, returns when the environment is fully synchronized.
 
virtual void SetSize (int w, int h) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual void ViewerSetSize (int w, int h) RAVE_DEPRECATED
 
virtual void Move (int x, int y) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual void ViewerMove (int x, int y) RAVE_DEPRECATED
 
virtual void SetName (const std::string &name) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual void ViewerSetTitle (const std::string &ptitle) RAVE_DEPRECATED
 
virtual const std::string & GetName () const OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual void UpdateCameraTransform () RAVE_DEPRECATED OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual UserDataPtr RegisterCallback (int properties, const ItemSelectionCallbackFn &fncallback) RAVE_DEPRECATED
 
virtual void SetCamera (const RaveTransform< float > &trans, float focalDistance=0) OPENRAVE_DUMMY_IMPLEMENTATION
 Set the camera transformation.
 
virtual RaveTransform< float > GetCameraTransform () const OPENRAVE_DUMMY_IMPLEMENTATION
 Return the current camera transform that the viewer is rendering the environment at.
 
virtual
geometry::RaveCameraIntrinsics
< float > 
GetCameraIntrinsics () const OPENRAVE_DUMMY_IMPLEMENTATION
 Return the closest camera intrinsics that the viewer is rendering the environment at.
 
virtual bool GetCameraImage (std::vector< uint8_t > &memory, int width, int height, const RaveTransform< float > &t, const SensorBase::CameraIntrinsics &intrinsics) OPENRAVE_DUMMY_IMPLEMENTATION
 Renders a 24bit RGB image of dimensions width and height from the current scene.
 
- Public Member Functions inherited from OpenRAVE::InterfaceBase
 InterfaceBase (InterfaceType type, EnvironmentBasePtr penv)
 
virtual ~InterfaceBase ()
 
InterfaceType GetInterfaceType () const
 
const std::string & GetXMLId () const
 
const std::string & GetPluginName () const
 
EnvironmentBasePtr GetEnv () const
 
const READERSMAPGetReadableInterfaces () const
 Returns the raw map reference, this is not multithread safe and the GetInterfaceMutex should be locked before using.
 
virtual XMLReadablePtr GetReadableInterface (const std::string &xmltag) const
 Returns the readable interface. [multi-thread safe]
 
virtual XMLReadablePtr SetReadableInterface (const std::string &xmltag, XMLReadablePtr readable)
 Set a new readable interface and return the previously set interface if it exists. [multi-thread safe]
 
virtual const std::string & GetDescription () const
 Documentation of the interface in reStructuredText format. See Documenting Interfaces. [multi-thread safe]
 
virtual void SetDescription (const std::string &description)
 sets a description [multi-thread safe]
 
virtual void SetUserData (const std::string &key, UserDataPtr data) const
 set user data for a specific key. [multi-thread safe]
 
virtual UserDataPtr GetUserData (const std::string &key=std::string()) const
 return the user custom data [multi-thread safe]
 
virtual bool RemoveUserData (const std::string &key) const
 removes a user data pointer. if user data pointer does not exist, then return 0, otherwise 1. [multi-thread safe]
 
virtual void SetUserData (UserDataPtr data) RAVE_DEPRECATED
 
virtual const std::string & GetURI () const
 the URI used to load the interface (sometimes this is not possible if the definition lies inside an environment file). [multi-thread safe]
 
virtual const std::string & GetXMLFilename () const
 
virtual void Clone (InterfaceBaseConstPtr preference, int cloningoptions)
 Clone the contents of an interface to the current interface.
 
virtual bool SendCommand (std::ostream &os, std::istream &is)
 Used to send special commands to the interface and receive output.
 
virtual void Serialize (BaseXMLWriterPtr writer, int options=0) const
 serializes the interface
 

Static Public Member Functions

static InterfaceType GetInterfaceTypeStatic ()
 return the static interface type this class points to (used for safe casting)
 

Public Attributes

enum
OpenRAVE::ViewerBase::ViewerEvents 
RAVE_DEPRECATED
 

Protected Member Functions

virtual void SetViewerData (KinBodyPtr body, UserDataPtr data) RAVE_DEPRECATED
 
virtual GraphHandlePtr plot3 (const float *ppoints, int numPoints, int stride, float fPointSize, const RaveVector< float > &color, int drawstyle=0) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr plot3 (const float *ppoints, int numPoints, int stride, float fPointSize, const float *colors, int drawstyle=0, bool bhasalpha=false) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawlinestrip (const float *ppoints, int numPoints, int stride, float fwidth, const RaveVector< float > &color) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawlinestrip (const float *ppoints, int numPoints, int stride, float fwidth, const float *colors) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawlinelist (const float *ppoints, int numPoints, int stride, float fwidth, const RaveVector< float > &color) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawlinelist (const float *ppoints, int numPoints, int stride, float fwidth, const float *colors) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawarrow (const RaveVector< float > &p1, const RaveVector< float > &p2, float fwidth, const RaveVector< float > &color) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawbox (const RaveVector< float > &vpos, const RaveVector< float > &vextents) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawplane (const RaveTransform< float > &tplane, const RaveVector< float > &vextents, const boost::multi_array< float, 3 > &vtexture) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawtrimesh (const float *ppoints, int stride, const int *pIndices, int numTriangles, const RaveVector< float > &color) OPENRAVE_DUMMY_IMPLEMENTATION
 
virtual GraphHandlePtr drawtrimesh (const float *ppoints, int stride, const int *pIndices, int numTriangles, const boost::multi_array< float, 2 > &colors) OPENRAVE_DUMMY_IMPLEMENTATION
 
ViewerBasePtr shared_viewer ()
 
ViewerBaseConstPtr shared_viewer_const () const
 
- Protected Member Functions inherited from OpenRAVE::InterfaceBase
virtual void RegisterCommand (const std::string &cmdname, InterfaceCommandFn fncmd, const std::string &strhelp)
 Registers a command and its help string. [multi-thread safe]
 
virtual void UnregisterCommand (const std::string &cmdname)
 Unregisters the command. [multi-thread safe]
 
virtual boost::shared_mutex & GetInterfaceMutex () const
 

Additional Inherited Members

- Protected Types inherited from OpenRAVE::InterfaceBase
typedef boost::function< bool(std::ostream
&, std::istream &)> 
InterfaceCommandFn
 The function to be executed for every command.
 
- Protected Attributes inherited from OpenRAVE::InterfaceBase
std::string __description
 

Detailed Description

[interface] Base class for the graphics and gui engine that renders the environment and provides visual sensor information. If not specified, method is not multi-thread safe. See Viewer Concepts.

Definition at line 53 of file viewer.h.

Member Typedef Documentation

typedef boost::function<bool (KinBody::LinkPtr plink,RaveVector<float>,RaveVector<float>)> OpenRAVE::ViewerBase::ItemSelectionCallbackFn

callback function for item selection

If the function returns true, then the object will be selected. Otherwise, the object remains unselected. callback(target link,offset,direction)

Definition at line 117 of file viewer.h.

Deprecated:
(11/06/10)

Definition at line 179 of file viewer.h.

typedef boost::function<void (const uint8_t*,int,int,int)> OpenRAVE::ViewerBase::ViewerImageCallbackFn

callback function for item selection callback(imagememory,width,height,pixeldepth)

Parameters
imagememorywidth x height x pixeldepth RGB image

Definition at line 128 of file viewer.h.

typedef boost::function<void ()> OpenRAVE::ViewerBase::ViewerThreadCallbackFn

callback function for viewer thread

Definition at line 136 of file viewer.h.

Member Enumeration Documentation

Enumerator:
VE_ItemSelection 

Definition at line 56 of file viewer.h.

Constructor & Destructor Documentation

OpenRAVE::ViewerBase::ViewerBase ( EnvironmentBasePtr  penv)
inline

Definition at line 61 of file viewer.h.

virtual OpenRAVE::ViewerBase::~ViewerBase ( )
inlinevirtual

Definition at line 63 of file viewer.h.

Member Function Documentation

virtual GraphHandlePtr OpenRAVE::ViewerBase::drawarrow ( const RaveVector< float > &  p1,
const RaveVector< float > &  p2,
float  fwidth,
const RaveVector< float > &  color 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawbox ( const RaveVector< float > &  vpos,
const RaveVector< float > &  vextents 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawlinelist ( const float *  ppoints,
int  numPoints,
int  stride,
float  fwidth,
const RaveVector< float > &  color 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawlinelist ( const float *  ppoints,
int  numPoints,
int  stride,
float  fwidth,
const float *  colors 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawlinestrip ( const float *  ppoints,
int  numPoints,
int  stride,
float  fwidth,
const RaveVector< float > &  color 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawlinestrip ( const float *  ppoints,
int  numPoints,
int  stride,
float  fwidth,
const float *  colors 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawplane ( const RaveTransform< float > &  tplane,
const RaveVector< float > &  vextents,
const boost::multi_array< float, 3 > &  vtexture 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawtrimesh ( const float *  ppoints,
int  stride,
const int *  pIndices,
int  numTriangles,
const RaveVector< float > &  color 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::drawtrimesh ( const float *  ppoints,
int  stride,
const int *  pIndices,
int  numTriangles,
const boost::multi_array< float, 2 > &  colors 
)
protectedvirtual
virtual void OpenRAVE::ViewerBase::EnvironmentSync ( )
virtual

forces synchronization with the environment, returns when the environment is fully synchronized.

Note that this method might not work if environment is locked in current thread

virtual bool OpenRAVE::ViewerBase::GetCameraImage ( std::vector< uint8_t > &  memory,
int  width,
int  height,
const RaveTransform< float > &  t,
const SensorBase::CameraIntrinsics intrinsics 
)
virtual

Renders a 24bit RGB image of dimensions width and height from the current scene.

The camera is meant to show the underlying OpenRAVE world as a robot would see it, so all graphs rendered with the plotX and drawX functions are hidden by default. Some viewers support the SetFiguresInCamera command to allow graphs to be also displayed.

Parameters
memorythe memory where the image will be stored at, has to store 3*width*height
widthwidth of the image, if 0 the width of the viewer is used
heightheight of the image, if 0 the width of the viewer is used
tthe rotation and translation of the camera. Note that +z is treated as the camera direction axis! So all points in front of the camera have a positive dot product with its +z direction.
intrinsicsthe intrinsic parameters of the camera defining FOV, distortion, principal point, and focal length. The focal length is used to define the near plane for culling.
virtual geometry::RaveCameraIntrinsics<float> OpenRAVE::ViewerBase::GetCameraIntrinsics ( ) const
virtual

Return the closest camera intrinsics that the viewer is rendering the environment at.

virtual RaveTransform<float> OpenRAVE::ViewerBase::GetCameraTransform ( ) const
virtual

Return the current camera transform that the viewer is rendering the environment at.

static InterfaceType OpenRAVE::ViewerBase::GetInterfaceTypeStatic ( )
inlinestatic

return the static interface type this class points to (used for safe casting)

Definition at line 67 of file viewer.h.

virtual const std::string& OpenRAVE::ViewerBase::GetName ( ) const
virtual
virtual int OpenRAVE::ViewerBase::main ( bool  bShow = true)
pure virtual

goes into the main loop

Parameters
bShowif true will show the window
virtual void OpenRAVE::ViewerBase::Move ( int  x,
int  y 
)
virtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::plot3 ( const float *  ppoints,
int  numPoints,
int  stride,
float  fPointSize,
const RaveVector< float > &  color,
int  drawstyle = 0 
)
protectedvirtual
virtual GraphHandlePtr OpenRAVE::ViewerBase::plot3 ( const float *  ppoints,
int  numPoints,
int  stride,
float  fPointSize,
const float *  colors,
int  drawstyle = 0,
bool  bhasalpha = false 
)
protectedvirtual
virtual void OpenRAVE::ViewerBase::quitmainloop ( )
pure virtual

destroys the main loop

virtual UserDataPtr OpenRAVE::ViewerBase::RegisterCallback ( int  properties,
const ItemSelectionCallbackFn fncallback 
)
inlinevirtual
Deprecated:
(11/06/10)

Definition at line 181 of file viewer.h.

virtual UserDataPtr OpenRAVE::ViewerBase::RegisterItemSelectionCallback ( const ItemSelectionCallbackFn fncallback)
virtual

registers a function with the viewer that gets called everytime mouse button is clicked

Returns
a handle to the callback. If this handle is deleted, the callback will be unregistered.
virtual UserDataPtr OpenRAVE::ViewerBase::RegisterViewerImageCallback ( const ViewerImageCallbackFn fncallback)
virtual

registers a function with the viewer that gets called for every new image rendered.

Returns
a handle to the callback. If this handle is deleted, the callback will be unregistered.
virtual UserDataPtr OpenRAVE::ViewerBase::RegisterViewerThreadCallback ( const ViewerThreadCallbackFn fncallback)
virtual

registers a function with the viewer that gets called in the viewer's GUI thread for every cycle the viewer refreshes at

The environment will not be locked when the thread is called

Returns
a handle to the callback. If this handle is deleted, the callback will be unregistered.
virtual void OpenRAVE::ViewerBase::RemoveKinBody ( KinBodyPtr  pbody)
virtual

notified when a body has been removed from the environment

virtual void OpenRAVE::ViewerBase::Reset ( )
virtual
virtual void OpenRAVE::ViewerBase::SetBkgndColor ( const RaveVector< float > &  color)
virtual
virtual void OpenRAVE::ViewerBase::SetCamera ( const RaveTransform< float > &  trans,
float  focalDistance = 0 
)
virtual

Set the camera transformation.

Parameters
transnew camera transformation in the world coordinate system
focalDistanceThe new focal distance of the camera (higher values is higher zoom). If 0, then the previous focal distance is preserved.
virtual void OpenRAVE::ViewerBase::SetEnvironmentSync ( bool  bUpdate)
virtual

controls whether the viewer synchronizes with the newest environment automatically

virtual void OpenRAVE::ViewerBase::SetName ( const std::string &  name)
virtual
virtual void OpenRAVE::ViewerBase::SetSize ( int  w,
int  h 
)
virtual
virtual void OpenRAVE::ViewerBase::SetViewerData ( KinBodyPtr  body,
UserDataPtr  data 
)
inlineprotectedvirtual
Deprecated:
(12/12/11)

Definition at line 188 of file viewer.h.

ViewerBasePtr OpenRAVE::ViewerBase::shared_viewer ( )
inlineprotected

Definition at line 209 of file viewer.h.

ViewerBaseConstPtr OpenRAVE::ViewerBase::shared_viewer_const ( ) const
inlineprotected

Definition at line 212 of file viewer.h.

virtual void OpenRAVE::ViewerBase::UpdateCameraTransform ( )
virtual
Deprecated:
(11/06/10)
virtual void OpenRAVE::ViewerBase::ViewerMove ( int  x,
int  y 
)
inlinevirtual
Deprecated:
(11/06/13)

Definition at line 163 of file viewer.h.

virtual void OpenRAVE::ViewerBase::ViewerSetSize ( int  w,
int  h 
)
inlinevirtual
Deprecated:
(11/06/13)

Definition at line 156 of file viewer.h.

virtual void OpenRAVE::ViewerBase::ViewerSetTitle ( const std::string &  ptitle)
inlinevirtual
Deprecated:
(11/06/13)

Definition at line 170 of file viewer.h.

Member Data Documentation


The documentation for this class was generated from the following file: