39#include <visp3/core/vpException.h>
40#include <visp3/robot/vpVirtuose.h>
42#ifdef VISP_HAVE_VIRTUOSE
82 ss << ip <<
"#" << port;
96 if (force.
size() != 6) {
98 "Cannot apply a force feedback (dim %d) to the haptic "
99 "device that is not 6-dimension",
106 for (
unsigned int i = 0; i < 6; i++)
107 virtforce[i] =
static_cast<float>(force[i]);
138 float articular_position_[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
140 if (virtGetArticularPosition(
m_virtContext, articular_position_)) {
146 for (
unsigned int i = 0; i <
m_njoints; i++)
147 articularPosition[i] = articular_position_[i];
149 return articularPosition;
161 float articular_velocity_[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
163 if (virtGetArticularSpeed(
m_virtContext, articular_velocity_)) {
170 for (
unsigned int i = 0; i <
m_njoints; i++)
171 articularVelocity[i] = articular_velocity_[i];
173 return articularVelocity;
199 for (
int i = 0; i < 3; i++)
200 translation[i] = position_[i];
201 for (
int i = 0; i < 4; i++)
202 quaternion[i] = position_[3 + i];
234 for (
int i = 0; i < 3; i++)
235 translation[i] = position_[i];
236 for (
int i = 0; i < 4; i++)
237 quaternion[i] = position_[3 + i];
256 VirtCommandType type;
280 return (deadman ?
true :
false);
299 return (emergencyStop ?
true :
false);
319 for (
unsigned int i = 0; i < 6; i++)
320 force[i] = force_[i];
398 for (
int i = 0; i < 3; i++)
399 translation[i] = position_[i];
400 for (
int i = 0; i < 4; i++)
401 quaternion[i] = position_[3 + i];
432 for (
int i = 0; i < 3; i++)
433 translation[i] = position_[i];
434 for (
int i = 0; i < 4; i++)
435 quaternion[i] = position_[3 + i];
461 virtGetErrorMessage(err)));
463 for (
unsigned int i = 0; i < 6; i++)
489 for (
int i = 0; i < 3; i++)
490 translation[i] = position_[i];
491 for (
int i = 0; i < 4; i++)
492 quaternion[i] = position_[3 + i];
512 return (power ?
true :
false);
533 for (
unsigned int i = 0; i < 6; i++)
551 "Cannot open communication with haptic device using %s: %s. Check ip and port values",
552 m_ip_port.c_str(), virtGetErrorMessage(err)));
558 virtGetErrorMessage(err)));
577 float articular_position_[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
579 if (virtGetArticularPosition(
m_virtContext, articular_position_)) {
586 for (
unsigned int i =
m_njoints; i < 20; i++) {
588 if (std::fabs(articular_position_[i]) <= std::numeric_limits<float>::epsilon()) {
610 "Cannot apply an articular force feedback (dim %d) to "
611 "the haptic device that is not 6-dimension",
612 articularForce.
size()));
615 float *articular_force =
new float[
m_njoints];
616 for (
unsigned int i = 0; i <
m_njoints; i++)
617 articular_force[i] =
static_cast<float>(articularForce[i]);
620 delete[] articular_force;
625 delete[] articular_force;
641 "Cannot send an articular position command (dim %d) to "
642 "the haptic device that is not %d-dimension",
646 float *articular_position =
new float[
m_njoints];
647 for (
unsigned int i = 0; i <
m_njoints; i++)
648 articular_position[i] =
static_cast<float>(articularPosition[i]);
650 if (virtSetArticularPosition(
m_virtContext, articular_position)) {
652 delete[] articular_position;
655 delete[] articular_position;
671 "Cannot send an articular velocity command (dim %d) to "
672 "the haptic device that is not %d-dimension",
676 float *articular_velocity =
new float[
m_njoints];
677 for (
unsigned int i = 0; i <
m_njoints; i++)
678 articular_velocity[i] =
static_cast<float>(articularVelocity[i]);
680 if (virtSetArticularSpeed(
m_virtContext, articular_velocity)) {
682 delete[] articular_velocity;
685 delete[] articular_velocity;
706 for (
int i = 0; i < 3; i++)
707 position_[i] =
static_cast<float>(translation[i]);
708 for (
int i = 0; i < 4; i++)
709 position_[3 + i] =
static_cast<float>(quaternion[i]);
751 if (force.
size() != 6) {
753 "Cannot apply a force feedback (dim %d) to the haptic "
754 "device that is not 6-dimension",
759 for (
unsigned int i = 0; i < 6; i++)
760 virtforce[i] =
static_cast<float>(force[i]);
829 for (
int i = 0; i < 3; i++)
830 position_[i] =
static_cast<float>(translation[i]);
831 for (
int i = 0; i < 4; i++)
832 position_[3 + i] =
static_cast<float>(quaternion[i]);
909 for (
int i = 0; i < 3; i++)
910 position_[i] =
static_cast<float>(translation[i]);
911 for (
int i = 0; i < 4; i++)
912 position_[3 + i] =
static_cast<float>(quaternion[i]);
955 if (virtSaturateTorque(
m_virtContext, forceLimit, torqueLimit)) {
989 if (velocity.
size() != 6) {
995 for (
unsigned int i = 0; i < 6; i++)
996 speed[i] =
static_cast<float>(velocity[i]);
1033 std::cout <<
"Haptic loop open." << std::endl;
1050 std::cout <<
"Haptic loop closed." << std::endl;
1055void dummy_vpVirtuose() { }
unsigned int size() const
Return the number of elements of the 2D array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
Implementation of a pose vector and operations on poses.
void extract(vpRotationMatrix &R) const
vpPoseVector & buildFrom(const double &tx, const double &ty, const double &tz, const double &tux, const double &tuy, const double &tuz)
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.
vpColVector getVelocity() const
vpColVector getArticularPosition() const
VirtCommandType getCommandType() const
void setIpAddressAndPort(const std::string &ip, int port)
void setTimeStep(const float &timeStep)
void setForceFactor(const float &forceFactor)
void setArticularVelocity(const vpColVector &articularVelocity)
void setObservationFrame(const vpPoseVector &position)
void enableForceFeedback(int enable)
vpPoseVector getPosition() const
vpPoseVector getBaseFrame() const
void setForce(const vpColVector &force)
void setIndexingMode(const VirtIndexingType &type)
unsigned int getJointsNumber() const
vpPoseVector getPhysicalPosition() const
void setBaseFrame(const vpPoseVector &position)
VirtContext m_virtContext
vpPoseVector getObservationFrame() const
bool getEmergencyStop() const
void setCommandType(const VirtCommandType &type)
void setPeriodicFunction(VirtPeriodicFunction CallBackVirt)
vpColVector getArticularVelocity() const
void stopPeriodicFunction()
vpPoseVector getAvatarPosition() const
void addForce(vpColVector &force)
void setArticularForce(const vpColVector &articularForce)
void setPosition(vpPoseVector &position)
void setVelocity(vpColVector &velocity)
VirtCommandType m_typeCommand
void startPeriodicFunction()
void setVelocityFactor(const float &velocityFactor)
void setSaturation(const float &forceLimit, const float &torqueLimit)
vpColVector getPhysicalVelocity() const
void setArticularPosition(const vpColVector &articularPosition)
VirtIndexingType m_indexType
vpColVector getForce() const