39 #include <visp3/core/vpConfig.h> 41 #ifdef VISP_HAVE_VIPER650 45 #include <sys/types.h> 48 #include <visp3/core/vpDebug.h> 49 #include <visp3/core/vpExponentialMap.h> 50 #include <visp3/core/vpIoTools.h> 51 #include <visp3/core/vpThetaUVector.h> 52 #include <visp3/core/vpVelocityTwistMatrix.h> 53 #include <visp3/robot/vpRobot.h> 54 #include <visp3/robot/vpRobotException.h> 55 #include <visp3/robot/vpRobotViper650.h> 61 bool vpRobotViper650::robotAlreadyCreated =
false;
83 void emergencyStopViper650(
int signo)
85 std::cout <<
"Stop the Viper650 application by signal (" << signo <<
"): " << (char)7;
88 std::cout <<
"SIGINT (stop by ^C) " << std::endl;
91 std::cout <<
"SIGBUS (stop due to a bus error) " << std::endl;
94 std::cout <<
"SIGSEGV (stop due to a segmentation fault) " << std::endl;
97 std::cout <<
"SIGKILL (stop by CTRL \\) " << std::endl;
100 std::cout <<
"SIGQUIT " << std::endl;
103 std::cout << signo << std::endl;
107 PrimitiveSTOP_Viper650();
108 std::cout <<
"Robot was stopped\n";
113 fprintf(stdout,
"Application ");
115 kill(getpid(), SIGKILL);
199 signal(SIGINT, emergencyStopViper650);
200 signal(SIGBUS, emergencyStopViper650);
201 signal(SIGSEGV, emergencyStopViper650);
202 signal(SIGKILL, emergencyStopViper650);
203 signal(SIGQUIT, emergencyStopViper650);
207 std::cout <<
"Open communication with MotionBlox.\n";
219 vpRobotViper650::robotAlreadyCreated =
true;
257 time_prev_getvel = 0;
258 first_time_getvel =
true;
263 first_time_getdis =
true;
266 Try(InitializeConnection(
verbose_));
269 Try(InitializeNode_Viper650());
271 Try(PrimitiveRESET_Viper650());
274 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(0));
280 UInt32 HIPowerStatus;
282 Try(PrimitiveSTATUS_Viper650(NULL, NULL, &EStopStatus, NULL, NULL, NULL, &HIPowerStatus));
287 std::cout <<
"Robot status: ";
288 switch (EStopStatus) {
291 if (HIPowerStatus == 0)
292 std::cout <<
"Power is OFF" << std::endl;
294 std::cout <<
"Power is ON" << std::endl;
299 if (HIPowerStatus == 0)
300 std::cout <<
"Power is OFF" << std::endl;
302 std::cout <<
"Power is ON" << std::endl;
304 case ESTOP_ACTIVATED:
306 std::cout <<
"Emergency stop is activated" << std::endl;
309 std::cout <<
"Sorry there is an error on the emergency chain." << std::endl;
310 std::cout <<
"You have to call Adept for maintenance..." << std::endl;
313 std::cout << std::endl;
331 if (TryStt == -20001)
332 printf(
"No connection detected. Check if the robot is powered on \n" 333 "and if the firewire link exist between the MotionBlox and this " 335 else if (TryStt == -675)
336 printf(
" Timeout enabling power...\n");
340 PrimitivePOWEROFF_Viper650();
342 ShutDownConnection();
344 std::cout <<
"Cannot open connection with the motionblox..." << std::endl;
428 for (
unsigned int i = 0; i < 3; i++) {
429 eMc_pose[i] =
etc[i];
430 eMc_pose[i + 3] =
erc[i];
433 Try(PrimitiveCONST_Viper650(eMc_pose));
508 for (
unsigned int i = 0; i < 3; i++) {
509 eMc_pose[i] =
etc[i];
510 eMc_pose[i + 3] =
erc[i];
513 Try(PrimitiveCONST_Viper650(eMc_pose));
574 for (
unsigned int i = 0; i < 3; i++) {
575 eMc_pose[i] =
etc[i];
576 eMc_pose[i + 3] =
erc[i];
579 Try(PrimitiveCONST_Viper650(eMc_pose));
604 for (
unsigned int i = 0; i < 3; i++) {
605 eMc_pose[i] =
etc[i];
606 eMc_pose[i + 3] =
erc[i];
609 Try(PrimitiveCONST_Viper650(eMc_pose));
636 for (
unsigned int i = 0; i < 3; i++) {
637 eMc_pose[i] =
etc[i];
638 eMc_pose[i + 3] =
erc[i];
641 Try(PrimitiveCONST_Viper650(eMc_pose));
665 UInt32 HIPowerStatus;
666 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
677 ShutDownConnection();
679 vpRobotViper650::robotAlreadyCreated =
false;
699 Try(PrimitiveSTOP_Viper650());
706 std::cout <<
"Change the control mode from velocity to position control.\n";
707 Try(PrimitiveSTOP_Viper650());
717 std::cout <<
"Change the control mode from stop to velocity control.\n";
748 Try(PrimitiveSTOP_Viper650());
772 UInt32 HIPowerStatus;
774 bool firsttime =
true;
775 unsigned int nitermax = 10;
777 for (
unsigned int i = 0; i < nitermax; i++) {
778 Try(PrimitiveSTATUS_Viper650(NULL, NULL, &EStopStatus, NULL, NULL, NULL, &HIPowerStatus));
779 if (EStopStatus == ESTOP_AUTO) {
782 }
else if (EStopStatus == ESTOP_MANUAL) {
785 }
else if (EStopStatus == ESTOP_ACTIVATED) {
788 std::cout <<
"Emergency stop is activated! \n" 789 <<
"Check the emergency stop button and push the yellow " 790 "button before continuing." 794 fprintf(stdout,
"Remaining time %us \r", nitermax - i);
798 std::cout <<
"Sorry there is an error on the emergency chain." << std::endl;
799 std::cout <<
"You have to call Adept for maintenance..." << std::endl;
801 ShutDownConnection();
806 if (EStopStatus == ESTOP_ACTIVATED)
807 std::cout << std::endl;
809 if (EStopStatus == ESTOP_ACTIVATED) {
810 std::cout <<
"Sorry, cannot power on the robot." << std::endl;
814 if (HIPowerStatus == 0) {
815 fprintf(stdout,
"Power ON the Viper650 robot\n");
818 Try(PrimitivePOWERON_Viper650());
842 UInt32 HIPowerStatus;
843 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
846 if (HIPowerStatus == 1) {
847 fprintf(stdout,
"Power OFF the Viper650 robot\n");
850 Try(PrimitivePOWEROFF_Viper650());
876 UInt32 HIPowerStatus;
877 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
880 if (HIPowerStatus == 1) {
940 Try(PrimitiveACQ_POS_J_Viper650(position, ×tamp));
944 for (
unsigned int i = 0; i <
njoint; i++)
973 Try(PrimitiveACQ_POS_Viper650(position, ×tamp));
977 for (
unsigned int i = 0; i <
njoint; i++)
1115 "Modification of the robot state");
1127 Try(PrimitiveACQ_POS_Viper650(q.
data, ×tamp));
1139 for (
unsigned int i = 0; i < 3; i++) {
1140 txyz[i] = position[i];
1141 rxyz[i] = position[i + 3];
1157 Try(PrimitiveMOVE_J_Viper650(destination.
data, positioningVelocity));
1158 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1167 destination = position;
1173 Try(PrimitiveMOVE_J_Viper650(destination.
data, positioningVelocity));
1174 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1179 vpRxyzVector rxyz(position[3], position[4], position[5]);
1183 for (
unsigned int i = 0; i < 3; i++) {
1184 destination[i] = position[i];
1187 int configuration = 0;
1191 Try(PrimitiveMOVE_C_Viper650(destination.
data, configuration, positioningVelocity));
1192 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1198 "Mixt frame not implemented.");
1202 "Mixt frame not implemented.");
1207 if (TryStt == InvalidPosition || TryStt == -1023)
1208 std::cout <<
" : Position out of range.\n";
1210 else if (TryStt == -3019) {
1212 std::cout <<
" : Joint position out of range.\n";
1214 std::cout <<
" : Cartesian position leads to a joint position out of " 1216 }
else if (TryStt < 0)
1217 std::cout <<
" : Unknown error (see Fabien).\n";
1218 else if (error == -1)
1219 std::cout <<
"Position out of range.\n";
1221 if (TryStt < 0 || error < 0) {
1294 double pos3,
double pos4,
double pos5,
double pos6)
1445 Try(PrimitiveACQ_POS_J_Viper650(position.
data, ×tamp));
1453 Try(PrimitiveACQ_POS_J_Viper650(q.
data, ×tamp));
1464 for (
unsigned int i = 0; i < 3; i++) {
1465 position[i] = fMc[i][3];
1466 position[i + 3] = rxyz[i];
1525 for (
unsigned int j = 0; j < 3; j++)
1526 RxyzVect[j] = posRxyz[j + 3];
1531 for (
unsigned int j = 0; j < 3; j++) {
1532 position[j] = posRxyz[j];
1533 position[j + 3] = RtuVect[j];
1560 PrimitiveACQ_TIME_Viper650(×tamp);
1645 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
1647 "Cannot send a velocity to the robot " 1648 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
1662 for (
unsigned int i = 0; i < 3; i++)
1664 for (
unsigned int i = 3; i < 6; i++)
1677 for (
unsigned int i = 0; i < 6; i++)
1680 for (
unsigned int i = 0; i < 5; i++)
1695 Try(PrimitiveMOVESPEED_CART_Viper650(vel_sat.
data, REPCAM_VIPER650));
1705 Try(PrimitiveMOVESPEED_CART_Viper650(v_c.
data, REPCAM_VIPER650));
1713 Try(PrimitiveMOVESPEED_Viper650(vel_sat.
data));
1719 Try(PrimitiveMOVESPEED_CART_Viper650(vel_sat.
data, REPFIX_VIPER650));
1728 "Case not taken in account.");
1735 if (TryStt == VelStopOnJoint) {
1736 UInt32 axisInJoint[
njoint];
1737 PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, axisInJoint, NULL);
1738 for (
unsigned int i = 0; i <
njoint; i++) {
1740 std::cout <<
"\nWarning: Velocity control stopped: axis " << i + 1 <<
" on joint limit!" << std::endl;
1743 printf(
"\n%s(%d): Error %d", __FUNCTION__, TryLine, TryStt);
1744 if (TryString != NULL) {
1746 printf(
" Error sentence %s\n", TryString);
1829 Try(PrimitiveACQ_POS_J_Viper650(q_cur.
data, ×tamp));
1830 time_cur = timestamp;
1836 if (!first_time_getvel) {
1841 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1850 velocity = (q_cur - q_prev_getvel) / (time_cur - time_prev_getvel);
1856 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1871 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1879 for (
unsigned int i = 0; i < 3; i++) {
1881 velocity[i] = fMc_prev_getvel[i][3] - fMc_cur[i][3];
1883 velocity[i + 3] = thetaU[i];
1887 velocity /= (time_cur - time_prev_getvel);
1892 "vpRobotViper650::getVelocity() not implemented in end-effector"));
1896 first_time_getvel =
false;
1900 fMc_prev_getvel = fMc_cur;
1903 q_prev_getvel = q_cur;
1906 time_prev_getvel = time_cur;
2070 std::ifstream fd(filename.c_str(), std::ios::in);
2072 if (!fd.is_open()) {
2077 std::string key(
"R:");
2078 std::string id(
"#Viper650 - Position");
2079 bool pos_found =
false;
2084 while (std::getline(fd, line)) {
2087 if (!(line.compare(0,
id.size(), id) == 0)) {
2088 std::cout <<
"Error: this position file " << filename <<
" is not for Viper650 robot" << std::endl;
2092 if ((line.compare(0, 1,
"#") == 0)) {
2095 if ((line.compare(0, key.size(), key) == 0)) {
2098 if (chain.size() <
njoint + 1)
2100 if (chain.size() <
njoint + 1)
2103 std::istringstream ss(line);
2106 for (
unsigned int i = 0; i <
njoint; i++)
2119 std::cout <<
"Error: unable to find a position for Viper650 robot in " << filename << std::endl;
2153 fd = fopen(filename.c_str(),
"w");
2158 #Viper650 - Position - Version 1.00\n\ 2161 # Joint position in degrees\n\ 2227 Try(PrimitiveACQ_POS_Viper650(q, ×tamp));
2228 for (
unsigned int i = 0; i <
njoint; i++) {
2232 if (!first_time_getdis) {
2235 std::cout <<
"getDisplacement() CAMERA_FRAME not implemented\n";
2240 displacement = q_cur - q_prev_getdis;
2245 std::cout <<
"getDisplacement() REFERENCE_FRAME not implemented\n";
2250 std::cout <<
"getDisplacement() MIXT_FRAME not implemented\n";
2254 std::cout <<
"getDisplacement() END_EFFECTOR_FRAME not implemented\n";
2259 first_time_getdis =
false;
2263 q_prev_getdis = q_cur;
2289 Try(PrimitiveTFS_BIAS_Viper650());
2346 Try(PrimitiveTFS_ACQ_Viper650(H.
data));
2398 Try(PrimitiveTFS_ACQ_Viper650(H.
data));
2418 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(0));
2419 std::cout <<
"Enable joint limits on axis 6..." << std::endl;
2440 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(1));
2441 std::cout <<
"Warning: Disable joint limits on axis 6..." << std::endl;
2486 maxRotationVelocity_joint6 = w6_max;
2508 Try(PrimitivePneumaticGripper_Viper650(1));
2509 std::cout <<
"Open the pneumatic gripper..." << std::endl;
2526 Try(PrimitivePneumaticGripper_Viper650(0));
2527 std::cout <<
"Close the pneumatic gripper..." << std::endl;
2534 #elif !defined(VISP_BUILD_SHARED_LIBS) 2537 void dummy_vpRobotViper650(){};
static const double defaultPositioningVelocity
static vpColVector inverse(const vpHomogeneousMatrix &M)
Implementation of a matrix and operations on matrices.
vpRxyzVector buildFrom(const vpRotationMatrix &R)
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
VISP_EXPORT int wait(double t0, double t)
Error that can be emited by the vpRobot class and its derivates.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity)
void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &velocity)
virtual ~vpRobotViper650(void)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setVerbose(bool verbose)
vpColVector getForceTorque() const
vpCameraParameters::vpCameraParametersProjType projModel
double maxRotationVelocity
double getMaxTranslationVelocity(void) const
void setMaxRotationVelocityJoint6(double w6_max)
Initialize the position controller.
error that can be emited by ViSP classes.
Class that defines a generic virtual robot.
Automatic control mode (default).
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
void get_cVe(vpVelocityTwistMatrix &cVe) const
Type * data
Address of the first element of the data array.
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &position)
void closeGripper() const
double getMaxRotationVelocity(void) const
static bool savePosFile(const std::string &filename, const vpColVector &q)
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
void setMaxRotationVelocity(double maxVr)
Implementation of a rotation matrix and operations on such kind of matrices.
static const vpToolType defaultTool
Default tool attached to the robot end effector.
void setPositioningVelocity(double velocity)
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
Initialize the velocity controller.
Emergency stop activated.
virtual void set_eMc(const vpHomogeneousMatrix &eMc_)
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpCameraParametersProjType
VISP_EXPORT void sleepMs(double t)
Modelisation of the ADEPT Viper 650 robot.
void enableJoint6Limits() const
void extract(vpRotationMatrix &R) const
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
double getPositioningVelocity(void) const
vpToolType
List of possible tools that can be attached to the robot end-effector.
unsigned int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &verbose=false) const
static double rad(double deg)
void get_fJe(vpMatrix &fJe)
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Stops robot motion especially in velocity and acceleration control.
void get_cMe(vpHomogeneousMatrix &cMe) const
void resize(unsigned int i, bool flagNullify=true)
static double deg(double rad)
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
void biasForceTorqueSensor() const
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
vpHomogeneousMatrix inverse() const
void move(const std::string &filename)
virtual vpRobotStateType getRobotState(void) const
void disableJoint6Limits() const
double getMaxRotationVelocityJoint6() const
Implementation of a rotation vector as Euler angle minimal representation.
void setMaxRotationVelocity(double w_max)
static bool readPosFile(const std::string &filename, vpColVector &q)
Implementation of a rotation vector as Euler angle minimal representation.
void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &displacement)
Function not implemented.
void get_cMe(vpHomogeneousMatrix &cMe) const
vpMatrix fJe
robot Jacobian expressed in the robot reference frame available
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.
static const unsigned int njoint
Number of joint.
void get_eJe(vpMatrix &eJe)
bool getPowerState() const
void set_eMc(const vpHomogeneousMatrix &eMc_)
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position)