Visual Servoing Platform
version 3.4.0
|
#include <vpVirtuose.h>
Public Member Functions | |
vpVirtuose () | |
virtual | ~vpVirtuose () |
void | addForce (vpColVector &force) |
void | close () |
void | enableForceFeedback (int enable) |
vpColVector | getArticularPosition () const |
vpColVector | getArticularVelocity () const |
vpPoseVector | getAvatarPosition () const |
vpPoseVector | getBaseFrame () const |
VirtCommandType | getCommandType () const |
bool | getDeadMan () const |
bool | getEmergencyStop () const |
unsigned int | getJointsNumber () const |
vpColVector | getForce () const |
VirtContext | getHandler () |
vpPoseVector | getObservationFrame () const |
vpPoseVector | getPhysicalPosition () const |
vpColVector | getPhysicalVelocity () const |
vpPoseVector | getPosition () const |
bool | getPower () const |
vpColVector | getVelocity () const |
void | init () |
void | setArticularForce (const vpColVector &articularForce) |
void | setArticularPosition (const vpColVector &articularPosition) |
void | setArticularVelocity (const vpColVector &articularVelocity) |
void | setBaseFrame (const vpPoseVector &position) |
void | setCommandType (const VirtCommandType &type) |
void | setForce (const vpColVector &force) |
void | setForceFactor (const float &forceFactor) |
void | setIndexingMode (const VirtIndexingType &type) |
void | setIpAddressAndPort (const std::string &ip, int port) |
void | setObservationFrame (const vpPoseVector &position) |
void | setPeriodicFunction (VirtPeriodicFunction CallBackVirt) |
void | setPosition (vpPoseVector &position) |
void | setPowerOff () |
void | setPowerOn () |
void | setSaturation (const float &forceLimit, const float &torqueLimit) |
void | setTimeStep (const float &timeStep) |
void | setVelocity (vpColVector &velocity) |
void | setVelocityFactor (const float &velocityFactor) |
void | setVerbose (bool mode) |
void | startPeriodicFunction () |
void | stopPeriodicFunction () |
Deprecated functions | |
vp_deprecated void | setIpAddress (const std::string &ip_port) |
Protected Attributes | |
VirtContext | m_virtContext |
std::string | m_ip_port |
bool | m_verbose |
int | m_apiMajorVersion |
int | m_apiMinorVersion |
int | m_ctrlMajorVersion |
int | m_ctrlMinorVersion |
VirtCommandType | m_typeCommand |
VirtIndexingType | m_indexType |
bool | m_is_init |
float | m_period |
unsigned int | m_njoints |
This class was tested with Haption (http://www.haption.com) Virtuose 6D haptic device.
The class vpVirtuose allows to work with the original Virtuose API inside ViSP. The Virtuose API supports the following devices:
Not all Virtuose API function are implemented in the class. Original Virtuose API functions need to be called with a VirtContext object, provided by the function getHandler().
The Virtuose library implements different control modes that could be set using setCommandType(). The choice of the control mode depends on the application. The following is the description of the main control modes as described in the Virtuose API documentation.
The Virtuose library defines the following reference frames:
The position of the following frames can be defined only once using the API: base frame (with respect to the observation frame) thanks to setBaseFrame() and end-effector frame (with respect to the tool frame).
The position of the observation frame (with respect to the environment frame) can be modified dynamically using setObservationFrame().
The position of the tool frame (with respect to the environment frame) cannot be modified.
All values used in the Virtuose API are expressed in physical units using metric conventions:
The following sample code shows how to connect to the haptic device to get its current joint position:
Definition at line 143 of file vpVirtuose.h.
vpVirtuose::vpVirtuose | ( | ) |
Default constructor. Set command type to virtual mechanism by default (impedance mode). Authorize indexing on all movements by default.
Definition at line 54 of file vpVirtuose.cpp.
References m_apiMajorVersion, and m_apiMinorVersion.
|
virtual |
Default destructor that delete the VirtContext object.
Definition at line 77 of file vpVirtuose.cpp.
References close().
void vpVirtuose::addForce | ( | vpColVector & | force | ) |
Add a force to be applied to the virtuose (impedance effort). This function works in every mode.
force | : Is 6 component dynamic tensor (three forces and three torques) wrt virtuose end-effector and is expressed in the coordinates of the base frame. |
Definition at line 102 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::close | ( | ) |
Delete the VirtContext object.
Definition at line 66 of file vpVirtuose.cpp.
References m_virtContext.
Referenced by ~vpVirtuose().
void vpVirtuose::enableForceFeedback | ( | int | enable | ) |
Activate or desactivate force feedback.
enable | : 1 to activate (system's default value), 0 to desactivate. |
Definition at line 127 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
vpColVector vpVirtuose::getArticularPosition | ( | ) | const |
Return the 6 joint values of the virtuose.
Definition at line 140 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, m_njoints, and m_virtContext.
vpColVector vpVirtuose::getArticularVelocity | ( | ) | const |
Return the 6 joint velocities of the virtuose.
Definition at line 164 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, m_njoints, and m_virtContext.
vpPoseVector vpVirtuose::getAvatarPosition | ( | ) | const |
Return the indexed position of the end-effector, expressed in the coordinates of the environment reference frame. With respect to the function getPosition(), getAvatarPosition() takes into account current offsets (indexing) and motor scale factors.
Definition at line 192 of file vpVirtuose.cpp.
References vpPoseVector::buildFrom(), vpException::fatalError, m_is_init, and m_virtContext.
vpPoseVector vpVirtuose::getBaseFrame | ( | ) | const |
Return the current position of the base frame with respect to the observation reference frame.
Definition at line 226 of file vpVirtuose.cpp.
References vpPoseVector::buildFrom(), vpException::fatalError, m_is_init, and m_virtContext.
VirtCommandType vpVirtuose::getCommandType | ( | ) | const |
Return the current command type.
Definition at line 257 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
bool vpVirtuose::getDeadMan | ( | ) | const |
Return the status of DeadMan sensor : true if the sensor is ON (a user is holding the handle) and false if the sensor is OFF (no user detected).
Definition at line 276 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
bool vpVirtuose::getEmergencyStop | ( | ) | const |
Return the status of the emergency stop button : true if the system is operational (button correctly plugged and not triggered) and false if the system is not operational (button not plugged or triggered).
Definition at line 295 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
vpColVector vpVirtuose::getForce | ( | ) | const |
Return the 6-dimension force tensor to be applied to the object attached to the Virtuose, allowing the dynamic simulation of the scene.
Definition at line 313 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
VirtContext vpVirtuose::getHandler | ( | ) |
Return the handler used to communicate with the device. This function could be used to access to a functionality that is not implemented in vpVirtuose class.
The following sample code shows how to use this function to get the device joint positions. This functionality is already implemented in getArticularPosition().
Definition at line 363 of file vpVirtuose.cpp.
References m_virtContext.
unsigned int vpVirtuose::getJointsNumber | ( | ) | const |
Get device number of joints.
Definition at line 370 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_njoints.
vpPoseVector vpVirtuose::getObservationFrame | ( | ) | const |
Return the cartesian current position of the observation reference frame with respect to the environment reference frame.
Definition at line 386 of file vpVirtuose.cpp.
References vpPoseVector::buildFrom(), vpException::fatalError, m_is_init, and m_virtContext.
vpPoseVector vpVirtuose::getPhysicalPosition | ( | ) | const |
Return the cartesian physical position of the Virtuose expressed in the coordinates of the base reference frame.
Definition at line 419 of file vpVirtuose.cpp.
References vpPoseVector::buildFrom(), vpException::fatalError, m_is_init, and m_virtContext.
vpColVector vpVirtuose::getPhysicalVelocity | ( | ) | const |
Return the physical cartesian velocity twist of the Virtuose expressed in the coordinates of the base reference frame.
Definition at line 452 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
vpPoseVector vpVirtuose::getPosition | ( | ) | const |
Return the cartesian position of the virtuose (or the object attached to it, if any) expressed in the coordinates of the environment reference frame.
Definition at line 475 of file vpVirtuose.cpp.
References vpPoseVector::buildFrom(), vpException::fatalError, m_is_init, and m_virtContext.
bool vpVirtuose::getPower | ( | ) | const |
Return status of the motors : true if motors are ON, false otherwise.
Definition at line 505 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
vpColVector vpVirtuose::getVelocity | ( | ) | const |
Return the cartesian velocity twist of the virtuose (or the object attached to it, if any) expressed in the coordinates of the environment reference frame.
Definition at line 522 of file vpVirtuose.cpp.
References vpException::fatalError, m_is_init, and m_virtContext.
void vpVirtuose::init | ( | void | ) |
Initialize virtuose device opening the connection to the device and setting the default command type. If the device is already initialized, a call to init() does nothing.
Definition at line 544 of file vpVirtuose.cpp.
References vpException::fatalError, m_ctrlMajorVersion, m_ctrlMinorVersion, m_ip_port, m_is_init, m_njoints, m_period, m_typeCommand, m_verbose, and m_virtContext.
Referenced by addForce(), enableForceFeedback(), setArticularForce(), setArticularPosition(), setArticularVelocity(), setBaseFrame(), setCommandType(), setForce(), setForceFactor(), setIndexingMode(), setObservationFrame(), setPeriodicFunction(), setPosition(), setPowerOff(), setPowerOn(), setSaturation(), setTimeStep(), setVelocity(), setVelocityFactor(), startPeriodicFunction(), and stopPeriodicFunction().
void vpVirtuose::setArticularForce | ( | const vpColVector & | articularForce | ) |
Send a command of articular force to the Virtuose. setArticularForce() only works in mode COMMAND_TYPE_ARTICULAR_IMPEDANCE, to be set with setCommandType().
articularForce | : Six dimension torque vector. |
Definition at line 603 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_njoints, m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::setArticularPosition | ( | const vpColVector & | articularPosition | ) |
Send a command of articular (joint) position to the virtuose. This function works only in COMMAND_TYPE_ARTICULAR mode, to be set with setCommandType().
articularPosition | : Six dimension joint position vector. |
Definition at line 634 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_njoints, m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::setArticularVelocity | ( | const vpColVector & | articularVelocity | ) |
Send a command of articular (joint) velocity to the virtuose. This function works only in COMMAND_TYPE_ARTICULAR mode, to be set with setCommandType().
articularVelocity | : Six dimension joint velocity vector. |
Definition at line 664 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_njoints, m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::setBaseFrame | ( | const vpPoseVector & | position | ) |
Move the base frame with respect to the observation reference frame. It can be called at any time.
position | : Position of the base frame. |
Definition at line 694 of file vpVirtuose.cpp.
References vpPoseVector::extract(), vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setCommandType | ( | const VirtCommandType & | type | ) |
Set the command type.
type | : Possible values:
|
Definition at line 726 of file vpVirtuose.cpp.
References vpException::fatalError, init(), m_typeCommand, and m_virtContext.
void vpVirtuose::setForce | ( | const vpColVector & | force | ) |
Set the force to be applied by the Virtuose. setForce() only works in COMMAND_TYPE_IMPEDANCE mode, to be set with setCommandType().
force | : Force vector that represents a dynamic tensor with 6 components. |
Definition at line 746 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::setForceFactor | ( | const float & | forceFactor | ) |
Set the force scale factor.
forceFactor | : Force scale factor applied to the force torque tensor set by setForce(). |
Definition at line 772 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setIndexingMode | ( | const VirtIndexingType & | type | ) |
Set indexing (offset) mode.
type | : Possible choices are:
|
Definition at line 796 of file vpVirtuose.cpp.
References vpException::fatalError, init(), m_indexType, and m_virtContext.
|
inline |
Set haptic device ip address and port. Default value is "localhost#5000".
Definition at line 213 of file vpVirtuose.h.
void vpVirtuose::setIpAddressAndPort | ( | const std::string & | ip, |
int | port | ||
) |
Set haptic device ip address and communication port.
[in] | ip | Host IP address. Default value set in constructor is "localhost". |
[in] | port | Host communication port. Default value set in constructor is 5000. |
Definition at line 87 of file vpVirtuose.cpp.
References m_ip_port.
void vpVirtuose::setObservationFrame | ( | const vpPoseVector & | position | ) |
Move the observation frame with respect to the environment reference frame. It can be called at any time.
position | : Position of the observation frame. |
Definition at line 817 of file vpVirtuose.cpp.
References vpPoseVector::extract(), vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setPeriodicFunction | ( | VirtPeriodicFunction | CallBackVirt | ) |
Register the periodic function. setPeriodicFunction() defines a callback function to be called at a fixed period of time, as timing for the simulation. The callback function is synchronized with the Virtuose controller (messages arrive at very constant time intervals from it) and generates hardware interrupts to be taken into account by the operating system. In practice, this function is much more efficient for timing the simulation than common software timers. This function is started using startPeriodicFunction() and stopped using stopPeriodicFunction().
CallBackVirt | : Callback function. |
Example of the use of the periodic function:
Definition at line 878 of file vpVirtuose.cpp.
References vpException::fatalError, init(), m_period, and m_virtContext.
void vpVirtuose::setPosition | ( | vpPoseVector & | position | ) |
Modify the current value of the control position and send it to the Virtuose.
position | : Position of the end-effector (or the attached object, if any). |
Definition at line 893 of file vpVirtuose.cpp.
References vpPoseVector::extract(), vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setPowerOff | ( | ) |
Turn the motor power OFF.
Definition at line 918 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setPowerOn | ( | ) |
Turn the motor power ON.
Definition at line 931 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setSaturation | ( | const float & | forceLimit, |
const float & | torqueLimit | ||
) |
Set saturation values of the force feedback
forceLimit | : Value expressed in N. |
torqueLimit | : Value expressed in Nm. |
Definition at line 946 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setTimeStep | ( | const float & | timeStep | ) |
Set the the simulation time step. The function must be called before the selection of the type of control mode.
timeStep | : Simulation time step (seconds). |
Definition at line 961 of file vpVirtuose.cpp.
References vpException::fatalError, init(), m_period, and m_virtContext.
void vpVirtuose::setVelocity | ( | vpColVector & | velocity | ) |
Modify the current value of the control velocity and send it to the Virtuose.
velocity | : Velocity twist vector, where translations velocities are expressed in m/s and rotation velocities in rad/s. |
Definition at line 980 of file vpVirtuose.cpp.
References vpException::dimensionError, vpException::fatalError, init(), m_virtContext, and vpArray2D< Type >::size().
void vpVirtuose::setVelocityFactor | ( | const float & | velocityFactor | ) |
Set the speed factor.
velocityFactor | : Scale factor applied to the velocities set using setVelocity(). |
Definition at line 1004 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
|
inline |
Enable/disable verbose mode.
mode | : true to enable, false to disable verbose. |
Definition at line 195 of file vpVirtuose.h.
void vpVirtuose::startPeriodicFunction | ( | ) |
Start the callback function set with setPeriodicFunction().
Definition at line 1019 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::stopPeriodicFunction | ( | ) |
Stop the callback function set with setPeriodicFunction().
Definition at line 1035 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
|
protected |
Definition at line 221 of file vpVirtuose.h.
Referenced by vpVirtuose().
|
protected |
Definition at line 222 of file vpVirtuose.h.
Referenced by vpVirtuose().
|
protected |
Definition at line 223 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 224 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 226 of file vpVirtuose.h.
Referenced by setIndexingMode().
|
protected |
Definition at line 219 of file vpVirtuose.h.
Referenced by init(), and setIpAddressAndPort().
|
protected |
Definition at line 227 of file vpVirtuose.h.
Referenced by getArticularPosition(), getArticularVelocity(), getAvatarPosition(), getBaseFrame(), getCommandType(), getDeadMan(), getEmergencyStop(), getForce(), getJointsNumber(), getObservationFrame(), getPhysicalPosition(), getPhysicalVelocity(), getPosition(), getPower(), getVelocity(), and init().
|
protected |
Definition at line 229 of file vpVirtuose.h.
Referenced by getArticularPosition(), getArticularVelocity(), getJointsNumber(), init(), setArticularForce(), setArticularPosition(), and setArticularVelocity().
|
protected |
Definition at line 228 of file vpVirtuose.h.
Referenced by init(), setPeriodicFunction(), and setTimeStep().
|
protected |
Definition at line 225 of file vpVirtuose.h.
Referenced by init(), and setCommandType().
|
protected |
Definition at line 220 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 218 of file vpVirtuose.h.
Referenced by addForce(), close(), enableForceFeedback(), getArticularPosition(), getArticularVelocity(), getAvatarPosition(), getBaseFrame(), getCommandType(), getDeadMan(), getEmergencyStop(), getForce(), getHandler(), getObservationFrame(), getPhysicalPosition(), getPhysicalVelocity(), getPosition(), getPower(), getVelocity(), init(), setArticularForce(), setArticularPosition(), setArticularVelocity(), setBaseFrame(), setCommandType(), setForce(), setForceFactor(), setIndexingMode(), setObservationFrame(), setPeriodicFunction(), setPosition(), setPowerOff(), setPowerOn(), setSaturation(), setTimeStep(), setVelocity(), setVelocityFactor(), startPeriodicFunction(), and stopPeriodicFunction().