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);
200 signal(SIGINT, emergencyStopViper650);
201 signal(SIGBUS, emergencyStopViper650);
202 signal(SIGSEGV, emergencyStopViper650);
203 signal(SIGKILL, emergencyStopViper650);
204 signal(SIGQUIT, emergencyStopViper650);
208 std::cout <<
"Open communication with MotionBlox.\n";
220 vpRobotViper650::robotAlreadyCreated =
true;
258 time_prev_getvel = 0;
259 first_time_getvel =
true;
264 first_time_getdis =
true;
267 Try(InitializeConnection(
verbose_));
270 Try(InitializeNode_Viper650());
272 Try(PrimitiveRESET_Viper650());
275 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(0));
281 UInt32 HIPowerStatus;
283 Try(PrimitiveSTATUS_Viper650(NULL, NULL, &EStopStatus, NULL, NULL, NULL, &HIPowerStatus));
288 std::cout <<
"Robot status: ";
289 switch (EStopStatus) {
292 if (HIPowerStatus == 0)
293 std::cout <<
"Power is OFF" << std::endl;
295 std::cout <<
"Power is ON" << std::endl;
300 if (HIPowerStatus == 0)
301 std::cout <<
"Power is OFF" << std::endl;
303 std::cout <<
"Power is ON" << std::endl;
305 case ESTOP_ACTIVATED:
307 std::cout <<
"Emergency stop is activated" << std::endl;
310 std::cout <<
"Sorry there is an error on the emergency chain." << std::endl;
311 std::cout <<
"You have to call Adept for maintenance..." << std::endl;
314 std::cout << std::endl;
332 if (TryStt == -20001)
333 printf(
"No connection detected. Check if the robot is powered on \n" 334 "and if the firewire link exist between the MotionBlox and this " 336 else if (TryStt == -675)
337 printf(
" Timeout enabling power...\n");
341 PrimitivePOWEROFF_Viper650();
343 ShutDownConnection();
345 std::cout <<
"Cannot open connection with the motionblox..." << std::endl;
430 for (
unsigned int i = 0; i < 3; i++) {
431 eMc_pose[i] =
etc[i];
432 eMc_pose[i + 3] =
erc[i];
435 Try(PrimitiveCONST_Viper650(eMc_pose));
510 for (
unsigned int i = 0; i < 3; i++) {
511 eMc_pose[i] =
etc[i];
512 eMc_pose[i + 3] =
erc[i];
515 Try(PrimitiveCONST_Viper650(eMc_pose));
576 for (
unsigned int i = 0; i < 3; i++) {
577 eMc_pose[i] =
etc[i];
578 eMc_pose[i + 3] =
erc[i];
581 Try(PrimitiveCONST_Viper650(eMc_pose));
606 for (
unsigned int i = 0; i < 3; i++) {
607 eMc_pose[i] =
etc[i];
608 eMc_pose[i + 3] =
erc[i];
611 Try(PrimitiveCONST_Viper650(eMc_pose));
638 for (
unsigned int i = 0; i < 3; i++) {
639 eMc_pose[i] =
etc[i];
640 eMc_pose[i + 3] =
erc[i];
643 Try(PrimitiveCONST_Viper650(eMc_pose));
667 UInt32 HIPowerStatus;
668 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
679 ShutDownConnection();
681 vpRobotViper650::robotAlreadyCreated =
false;
701 Try(PrimitiveSTOP_Viper650());
708 std::cout <<
"Change the control mode from velocity to position control.\n";
709 Try(PrimitiveSTOP_Viper650());
719 std::cout <<
"Change the control mode from stop to velocity control.\n";
750 Try(PrimitiveSTOP_Viper650());
774 UInt32 HIPowerStatus;
776 bool firsttime =
true;
777 unsigned int nitermax = 10;
779 for (
unsigned int i = 0; i < nitermax; i++) {
780 Try(PrimitiveSTATUS_Viper650(NULL, NULL, &EStopStatus, NULL, NULL, NULL, &HIPowerStatus));
781 if (EStopStatus == ESTOP_AUTO) {
784 }
else if (EStopStatus == ESTOP_MANUAL) {
787 }
else if (EStopStatus == ESTOP_ACTIVATED) {
790 std::cout <<
"Emergency stop is activated! \n" 791 <<
"Check the emergency stop button and push the yellow " 792 "button before continuing." 796 fprintf(stdout,
"Remaining time %us \r", nitermax - i);
800 std::cout <<
"Sorry there is an error on the emergency chain." << std::endl;
801 std::cout <<
"You have to call Adept for maintenance..." << std::endl;
803 ShutDownConnection();
808 if (EStopStatus == ESTOP_ACTIVATED)
809 std::cout << std::endl;
811 if (EStopStatus == ESTOP_ACTIVATED) {
812 std::cout <<
"Sorry, cannot power on the robot." << std::endl;
816 if (HIPowerStatus == 0) {
817 fprintf(stdout,
"Power ON the Viper650 robot\n");
820 Try(PrimitivePOWERON_Viper650());
844 UInt32 HIPowerStatus;
845 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
848 if (HIPowerStatus == 1) {
849 fprintf(stdout,
"Power OFF the Viper650 robot\n");
852 Try(PrimitivePOWEROFF_Viper650());
878 UInt32 HIPowerStatus;
879 Try(PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, NULL, &HIPowerStatus));
882 if (HIPowerStatus == 1) {
942 Try(PrimitiveACQ_POS_J_Viper650(position, ×tamp));
946 for (
unsigned int i = 0; i <
njoint; i++)
975 Try(PrimitiveACQ_POS_Viper650(position, ×tamp));
979 for (
unsigned int i = 0; i <
njoint; i++)
1119 "Modification of the robot state");
1131 Try(PrimitiveACQ_POS_Viper650(q.
data, ×tamp));
1143 for (
unsigned int i = 0; i < 3; i++) {
1144 txyz[i] = position[i];
1145 rxyz[i] = position[i + 3];
1161 Try(PrimitiveMOVE_J_Viper650(destination.
data, positioningVelocity));
1162 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1171 destination = position;
1177 Try(PrimitiveMOVE_J_Viper650(destination.
data, positioningVelocity));
1178 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1183 vpRxyzVector rxyz(position[3], position[4], position[5]);
1187 for (
unsigned int i = 0; i < 3; i++) {
1188 destination[i] = position[i];
1191 int configuration = 0;
1195 Try(PrimitiveMOVE_C_Viper650(destination.
data, configuration, positioningVelocity));
1196 Try(WaitState_Viper650(ETAT_ATTENTE_VIPER650, 1000));
1201 vpERROR_TRACE(
"Positionning error. Mixt frame not implemented");
1203 "Mixt frame not implemented.");
1208 if (TryStt == InvalidPosition || TryStt == -1023)
1209 std::cout <<
" : Position out of range.\n";
1211 else if (TryStt == -3019) {
1213 std::cout <<
" : Joint position out of range.\n";
1215 std::cout <<
" : Cartesian position leads to a joint position out of " 1217 }
else if (TryStt < 0)
1218 std::cout <<
" : Unknown error (see Fabien).\n";
1219 else if (error == -1)
1220 std::cout <<
"Position out of range.\n";
1222 if (TryStt < 0 || error < 0) {
1296 const double pos3,
const double pos4,
const double pos5,
const double pos6)
1449 Try(PrimitiveACQ_POS_J_Viper650(position.
data, ×tamp));
1456 Try(PrimitiveACQ_POS_C_Viper650(position.
data, ×tamp));
1460 for (
unsigned int i = 3; i < 6; i++)
1463 vpRzyzVector rzyz(position[3], position[4], position[5]);
1468 for (
unsigned int i = 0; i < 3; i++)
1469 position[i + 3] = rxyz[i];
1479 vpERROR_TRACE(
"Cannot get position in mixt frame: not implemented");
1529 for (
unsigned int j = 0; j < 3; j++)
1530 RxyzVect[j] = posRxyz[j + 3];
1535 for (
unsigned int j = 0; j < 3; j++) {
1536 position[j] = posRxyz[j];
1537 position[j + 3] = RtuVect[j];
1564 PrimitiveACQ_TIME_Viper650(×tamp);
1650 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
1652 "Cannot send a velocity to the robot " 1653 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
1666 for (
unsigned int i = 0; i < 3; i++)
1668 for (
unsigned int i = 3; i < 6; i++)
1681 for (
unsigned int i = 0; i < 6; i++)
1684 for (
unsigned int i = 0; i < 5; i++)
1699 Try(PrimitiveMOVESPEED_CART_Viper650(vel_sat.
data, REPCAM_VIPER650));
1707 Try(PrimitiveMOVESPEED_Viper650(vel_sat.
data));
1712 std::cout <<
"Vitesse ref appliquee: " << vel_sat.
t();
1713 Try(PrimitiveMOVESPEED_CART_Viper650(vel_sat.
data, REPFIX_VIPER650));
1722 "Case not taken in account.");
1729 if (TryStt == VelStopOnJoint) {
1730 UInt32 axisInJoint[
njoint];
1731 PrimitiveSTATUS_Viper650(NULL, NULL, NULL, NULL, NULL, axisInJoint, NULL);
1732 for (
unsigned int i = 0; i <
njoint; i++) {
1734 std::cout <<
"\nWarning: Velocity control stopped: axis " << i + 1 <<
" on joint limit!" << std::endl;
1737 printf(
"\n%s(%d): Error %d", __FUNCTION__, TryLine, TryStt);
1738 if (TryString != NULL) {
1740 printf(
" Error sentence %s\n", TryString);
1824 Try(PrimitiveACQ_POS_J_Viper650(q_cur.
data, ×tamp));
1825 time_cur = timestamp;
1831 if (!first_time_getvel) {
1836 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1845 velocity = (q_cur - q_prev_getvel) / (time_cur - time_prev_getvel);
1851 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1866 cMc = fMc_prev_getvel.
inverse() * fMc_cur;
1874 for (
unsigned int i = 0; i < 3; i++) {
1876 velocity[i] = fMc_prev_getvel[i][3] - fMc_cur[i][3];
1878 velocity[i + 3] = thetaU[i];
1882 velocity /= (time_cur - time_prev_getvel);
1887 first_time_getvel =
false;
1891 fMc_prev_getvel = fMc_cur;
1894 q_prev_getvel = q_cur;
1897 time_prev_getvel = time_cur;
2063 std::ifstream fd(filename.c_str(), std::ios::in);
2065 if (!fd.is_open()) {
2070 std::string key(
"R:");
2071 std::string id(
"#Viper650 - Position");
2072 bool pos_found =
false;
2077 while (std::getline(fd, line)) {
2080 if (!(line.compare(0,
id.size(), id) == 0)) {
2081 std::cout <<
"Error: this position file " << filename <<
" is not for Viper650 robot" << std::endl;
2085 if ((line.compare(0, 1,
"#") == 0)) {
2088 if ((line.compare(0, key.size(), key) == 0)) {
2091 if (chain.size() <
njoint + 1)
2093 if (chain.size() <
njoint + 1)
2096 std::istringstream ss(line);
2099 for (
unsigned int i = 0; i <
njoint; i++)
2112 std::cout <<
"Error: unable to find a position for Viper650 robot in " << filename << std::endl;
2146 fd = fopen(filename.c_str(),
"w");
2151 #Viper650 - Position - Version 1.00\n\ 2154 # Joint position in degrees\n\ 2220 Try(PrimitiveACQ_POS_Viper650(q, ×tamp));
2221 for (
unsigned int i = 0; i <
njoint; i++) {
2225 if (!first_time_getdis) {
2228 std::cout <<
"getDisplacement() CAMERA_FRAME not implemented\n";
2233 displacement = q_cur - q_prev_getdis;
2238 std::cout <<
"getDisplacement() REFERENCE_FRAME not implemented\n";
2243 std::cout <<
"getDisplacement() MIXT_FRAME not implemented\n";
2248 first_time_getdis =
false;
2252 q_prev_getdis = q_cur;
2278 Try(PrimitiveTFS_BIAS_Viper650());
2336 Try(PrimitiveTFS_ACQ_Viper650(H.
data));
2389 Try(PrimitiveTFS_ACQ_Viper650(H.
data));
2409 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(0));
2410 std::cout <<
"Enable joint limits on axis 6..." << std::endl;
2431 Try(PrimitiveREMOVE_JOINT6_LIMITS_Viper650(1));
2432 std::cout <<
"Warning: Disable joint limits on axis 6..." << std::endl;
2477 maxRotationVelocity_joint6 = w6_max;
2499 Try(PrimitivePneumaticGripper_Viper650(1));
2500 std::cout <<
"Open the pneumatic gripper..." << std::endl;
2517 Try(PrimitivePneumaticGripper_Viper650(0));
2518 std::cout <<
"Close the pneumatic gripper..." << std::endl;
2525 #elif !defined(VISP_BUILD_SHARED_LIBS) 2528 void dummy_vpRobotViper650(){};
static const double defaultPositioningVelocity
static vpColVector inverse(const vpHomogeneousMatrix &M)
Implementation of a matrix and operations on matrices.
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 get_fJe(const vpColVector &q, vpMatrix &fJe) const
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)
void setPositioningVelocity(const double velocity)
double getMaxTranslationVelocity(void) const
vpCameraParameters::vpCameraParametersProjType projModel
double maxRotationVelocity
void setMaxRotationVelocityJoint6(double w6_max)
Initialize the position controller.
vpHomogeneousMatrix inverse() const
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)
Type * data
Address of the first element of the data array.
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &position)
double getMaxRotationVelocity(void) const
void extract(vpRotationMatrix &R) const
static bool savePosFile(const std::string &filename, const vpColVector &q)
vpThetaUVector buildFrom(const vpHomogeneousMatrix &M)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Implementation of a rotation matrix and operations on such kind of matrices.
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
void biasForceTorqueSensor() const
static const vpToolType defaultTool
Default tool attached to the robot end effector.
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
Initialize the velocity controller.
Emergency stop activated.
virtual vpRobotStateType getRobotState(void) const
bool getPowerState() const
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.
unsigned int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &verbose=false) const
void get_cMe(vpHomogeneousMatrix &cMe) const
vpToolType
List of possible tools that can be attached to the robot end-effector.
static double rad(double deg)
void enableJoint6Limits() const
void get_fJe(vpMatrix &fJe)
void setMaxRotationVelocity(const double maxVr)
double getPositioningVelocity(void) const
static double deg(double rad)
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
vpColVector getForceTorque() const
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
void move(const std::string &filename)
Implementation of a rotation vector as Euler angle minimal representation.
void disableJoint6Limits() const
void setMaxRotationVelocity(double w_max)
static bool readPosFile(const std::string &filename, vpColVector &q)
void get_cMe(vpHomogeneousMatrix &cMe) const
Implementation of a rotation vector as Euler angle minimal representation.
void get_cVe(vpVelocityTwistMatrix &cVe) const
double getMaxRotationVelocityJoint6() const
void closeGripper() const
void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &displacement)
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(const vpColVector &q, vpMatrix &eJe) const
void get_eJe(vpMatrix &eJe)
void set_eMc(const vpHomogeneousMatrix &eMc_)
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position)
void resize(const unsigned int i, const bool flagNullify=true)