Visual Servoing Platform
version 3.6.1 under development (2024-11-15)
|
#include <visp3/robot/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 () |
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 144 of file vpVirtuose.h.
BEGIN_VISP_NAMESPACE vpVirtuose::vpVirtuose | ( | ) |
Default constructor. Set command type to virtual mechanism by default (impedance mode). Authorize indexing on all movements by default.
Definition at line 51 of file vpVirtuose.cpp.
References m_apiMajorVersion, and m_apiMinorVersion.
|
virtual |
Default destructor that delete the VirtContext object.
Definition at line 74 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 96 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 63 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 121 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 134 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 157 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 185 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 220 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 252 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 271 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 290 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 308 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 362 of file vpVirtuose.cpp.
References m_virtContext.
unsigned int vpVirtuose::getJointsNumber | ( | ) | const |
Get device number of joints.
Definition at line 369 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 384 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 418 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 506 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 523 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 545 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 606 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 637 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 667 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 697 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 729 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 749 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 775 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 799 of file vpVirtuose.cpp.
References vpException::fatalError, init(), m_indexType, and m_virtContext.
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 81 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 820 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 885 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 900 of file vpVirtuose.cpp.
References vpPoseVector::extract(), vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setPowerOff | ( | ) |
Turn the motor power OFF.
Definition at line 925 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::setPowerOn | ( | ) |
Turn the motor power ON.
Definition at line 938 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 953 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 968 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 987 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 1011 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 196 of file vpVirtuose.h.
void vpVirtuose::startPeriodicFunction | ( | ) |
Start the callback function set with setPeriodicFunction().
Definition at line 1026 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
void vpVirtuose::stopPeriodicFunction | ( | ) |
Stop the callback function set with setPeriodicFunction().
Definition at line 1043 of file vpVirtuose.cpp.
References vpException::fatalError, init(), and m_virtContext.
|
protected |
Definition at line 222 of file vpVirtuose.h.
Referenced by vpVirtuose().
|
protected |
Definition at line 223 of file vpVirtuose.h.
Referenced by vpVirtuose().
|
protected |
Definition at line 224 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 225 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 227 of file vpVirtuose.h.
Referenced by setIndexingMode().
|
protected |
Definition at line 220 of file vpVirtuose.h.
Referenced by init(), and setIpAddressAndPort().
|
protected |
Definition at line 228 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 230 of file vpVirtuose.h.
Referenced by getArticularPosition(), getArticularVelocity(), getJointsNumber(), init(), setArticularForce(), setArticularPosition(), and setArticularVelocity().
|
protected |
Definition at line 229 of file vpVirtuose.h.
Referenced by init(), setPeriodicFunction(), and setTimeStep().
|
protected |
Definition at line 226 of file vpVirtuose.h.
Referenced by init(), and setCommandType().
|
protected |
Definition at line 221 of file vpVirtuose.h.
Referenced by init().
|
protected |
Definition at line 219 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().