44 #include <visp3/core/vpException.h> 45 #include <visp3/robot/vpVirtuose.h> 47 #ifdef VISP_HAVE_VIRTUOSE 55 : m_virtContext(NULL), m_ip(
"localhost#5000"), m_verbose(false), m_apiMajorVersion(0), m_apiMinorVersion(0),
56 m_ctrlMajorVersion(0), m_ctrlMinorVersion(0), m_typeCommand(COMMAND_TYPE_IMPEDANCE), m_indexType(INDEXING_ALL),
57 m_is_init(false), m_period(0.001f)
83 if (force.
size() != 6) {
85 "Cannot apply a force feedback (dim %d) to the haptic " 86 "device that is not 6-dimension",
93 for (
unsigned int i = 0; i < 6; i++)
94 virtforce[i] = (
float)force[i];
127 float articular_position_[6];
128 if (virtGetArticularPosition(
m_virtContext, articular_position_)) {
133 for (
unsigned int i = 0; i < 6; i++)
134 articularPosition[i] = articular_position_[i];
136 return articularPosition;
149 float articular_velocity_[6];
150 if (virtGetArticularSpeed(
m_virtContext, articular_velocity_)) {
155 for (
unsigned int i = 0; i < 6; i++)
156 articularVelocity[i] = articular_velocity_[i];
158 return articularVelocity;
183 for (
int i = 0; i < 3; i++)
184 translation[i] = position_[i];
185 for (
int i = 0; i < 4; i++)
186 quaternion[i] = position_[3 + i];
217 for (
int i = 0; i < 3; i++)
218 translation[i] = position_[i];
219 for (
int i = 0; i < 4; i++)
220 quaternion[i] = position_[3 + i];
239 VirtCommandType type;
263 return (deadman ?
true :
false);
282 return (emergencyStop ?
true :
false);
302 for (
unsigned int i = 0; i < 6; i++)
303 force[i] = force_[i];
362 for (
int i = 0; i < 3; i++)
363 translation[i] = position_[i];
364 for (
int i = 0; i < 4; i++)
365 quaternion[i] = position_[3 + i];
394 for (
int i = 0; i < 3; i++)
395 translation[i] = position_[i];
396 for (
int i = 0; i < 4; i++)
397 quaternion[i] = position_[3 + i];
423 virtGetErrorMessage(err)));
425 for (
unsigned int i = 0; i < 6; i++)
450 for (
int i = 0; i < 3; i++)
451 translation[i] = position_[i];
452 for (
int i = 0; i < 4; i++)
453 quaternion[i] = position_[3 + i];
473 return (power ?
true :
false);
494 for (
unsigned int i = 0; i < 6; i++)
517 virtGetErrorMessage(err)));
549 if (articularForce.
size() != 6) {
551 "Cannot apply an articular force feedback (dim %d) to " 552 "the haptic device that is not 6-dimension",
553 articularForce.
size()));
556 float articular_force[6];
557 for (
unsigned int i = 0; i < 6; i++)
558 articular_force[i] = (
float)articularForce[i];
576 if (articularPosition.
size() != 6) {
578 "Cannot send an articular position command (dim %d) to " 579 "the haptic device that is not 6-dimension",
580 articularPosition.
size()));
583 float articular_position[6];
584 for (
unsigned int i = 0; i < 6; i++)
585 articular_position[i] = (
float)articularPosition[i];
587 if (virtSetArticularPosition(
m_virtContext, articular_position)) {
603 if (articularVelocity.
size() != 6) {
605 "Cannot send an articular velocity command (dim %d) to " 606 "the haptic device that is not 6-dimension",
607 articularVelocity.
size()));
610 float articular_velocity[6];
611 for (
unsigned int i = 0; i < 6; i++)
612 articular_velocity[i] = (
float)articularVelocity[i];
614 if (virtSetArticularSpeed(
m_virtContext, articular_velocity)) {
638 for (
int i = 0; i < 3; i++)
639 position_[i] = (
float)translation[i];
640 for (
int i = 0; i < 4; i++)
641 position_[3 + i] = (
float)quaternion[i];
683 if (force.
size() != 6) {
685 "Cannot apply a force feedback (dim %d) to the haptic " 686 "device that is not 6-dimension",
691 for (
unsigned int i = 0; i < 6; i++)
692 virtforce[i] = (
float)force[i];
761 for (
int i = 0; i < 3; i++)
762 position_[i] = (
float)translation[i];
763 for (
int i = 0; i < 4; i++)
764 position_[3 + i] = (
float)quaternion[i];
837 for (
int i = 0; i < 3; i++)
838 position_[i] = (
float)translation[i];
839 for (
int i = 0; i < 4; i++)
840 position_[3 + i] = (
float)quaternion[i];
883 if (virtSaturateTorque(
m_virtContext, forceLimit, torqueLimit)) {
917 if (velocity.
size() != 6) {
923 for (
unsigned int i = 0; i < 6; i++)
924 speed[i] = (
float)velocity[i];
960 std::cout <<
"Haptic loop open." << std::endl;
976 std::cout <<
"Haptic loop closed." << std::endl;
981 void dummy_vpVirtuose(){};
void setSaturation(const float &forceLimit, const float &torqueLimit)
void startPeriodicFunction()
vpColVector getForce() const
VirtCommandType m_typeCommand
VirtCommandType getCommandType() const
void setVelocityFactor(const float &velocityFactor)
void extract(vpRotationMatrix &R) const
vpPoseVector getPhysicalPosition() const
vpColVector getArticularPosition() const
vpColVector getArticularVelocity() const
error that can be emited by ViSP classes.
void setPeriodicFunction(VirtPeriodicFunction CallBackVirt)
unsigned int size() const
Return the number of elements of the 2D array.
void setForce(const vpColVector &force)
void setForceFactor(const float &forceFactor)
VirtContext m_virtContext
VirtIndexingType m_indexType
void setArticularVelocity(const vpColVector &articularVelocity)
void setVelocity(vpColVector &velocity)
vpPoseVector getBaseFrame() const
void enableForceFeedback(int enable)
void setCommandType(const VirtCommandType &type)
void setBaseFrame(const vpPoseVector &position)
vpPoseVector getAvatarPosition() const
Implementation of a rotation vector as quaternion angle minimal representation.
vpPoseVector getPosition() const
void setPosition(vpPoseVector &position)
void setArticularForce(const vpColVector &articularForce)
void setArticularPosition(const vpColVector &articularPosition)
void stopPeriodicFunction()
void setIndexingMode(const VirtIndexingType &type)
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
vpColVector getPhysicalVelocity() const
void setObservationFrame(const vpPoseVector &position)
vpColVector getVelocity() const
bool getEmergencyStop() const
vpPoseVector buildFrom(const double tx, const double ty, const double tz, const double tux, const double tuy, const double tuz)
void addForce(vpColVector &force)
void setTimeStep(const float &timeStep)
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.
vpPoseVector getObservationFrame() const