47 #include <visp3/core/vpDebug.h>
48 #include <visp3/core/vpVelocityTwistMatrix.h>
49 #include <visp3/robot/vpRobotException.h>
50 #include <visp3/core/vpXmlParserCamera.h>
51 #include <visp3/core/vpCameraParameters.h>
52 #include <visp3/core/vpRxyzVector.h>
53 #include <visp3/core/vpTranslationVector.h>
54 #include <visp3/core/vpRotationMatrix.h>
55 #include <visp3/robot/vpAfma6.h>
61 #ifdef VISP_HAVE_ACCESS_TO_NAS
62 static const char *opt_Afma6[] = {
"JOINT_MAX",
"JOINT_MIN",
"LONG_56",
"COUPL_56",
63 "CAMERA",
"eMc_ROT_XYZ",
"eMc_TRANS_XYZ",
68 =
"Z:/robot/Afma6/current/include/const_Afma6.cnf";
70 =
"/udd/fspindle/robot/Afma6/current/include/const_Afma6.cnf";
75 =
"Z:/robot/Afma6/current/include/const_eMc_ccmop_without_distortion_Afma6.cnf";
77 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_ccmop_without_distortion_Afma6.cnf";
82 =
"Z:/robot/Afma6/current/include/const_eMc_ccmop_with_distortion_Afma6.cnf";
84 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_ccmop_with_distortion_Afma6.cnf";
89 =
"Z:/robot/Afma6/current/include/const_eMc_gripper_without_distortion_Afma6.cnf";
91 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_gripper_without_distortion_Afma6.cnf";
96 =
"Z:/robot/Afma6/current/include/const_eMc_gripper_with_distortion_Afma6.cnf";
98 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_gripper_with_distortion_Afma6.cnf";
103 =
"Z:/robot/Afma6/current/include/const_eMc_vacuum_without_distortion_Afma6.cnf";
105 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_vacuum_without_distortion_Afma6.cnf";
110 =
"Z:/robot/Afma6/current/include/const_eMc_vacuum_with_distortion_Afma6.cnf";
112 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_vacuum_with_distortion_Afma6.cnf";
117 =
"Z:/robot/Afma6/current/include/const_eMc_generic_without_distortion_Afma6.cnf";
119 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_generic_without_distortion_Afma6.cnf";
124 =
"Z:/robot/Afma6/current/include/const_eMc_generic_with_distortion_Afma6.cnf";
126 =
"/udd/fspindle/robot/Afma6/current/include/const_eMc_generic_with_distortion_Afma6.cnf";
131 =
"Z:/robot/Afma6/current/include/const_camera_Afma6.xml";
133 =
"/udd/fspindle/robot/Afma6/current/include/const_camera_Afma6.xml";
136 #endif // VISP_HAVE_ACCESS_TO_NAS
153 : _coupl_56(0), _long_56(0), _etc(), _erc(), _eMc(),
154 tool_current(
vpAfma6::defaultTool),
215 #ifdef VISP_HAVE_ACCESS_TO_NAS
218 const char * paramCamera)
249 #ifdef VISP_HAVE_ACCESS_TO_NAS
251 char filename_eMc [FILENAME_MAX];
256 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
257 snprintf(filename_eMc, FILENAME_MAX,
"%s",
260 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
265 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
266 snprintf(filename_eMc, FILENAME_MAX,
"%s",
269 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
279 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
280 snprintf(filename_eMc, FILENAME_MAX,
"%s",
283 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
288 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
289 snprintf(filename_eMc, FILENAME_MAX,
"%s",
292 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
302 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
303 snprintf(filename_eMc, FILENAME_MAX,
"%s",
306 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
311 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
312 snprintf(filename_eMc, FILENAME_MAX,
"%s",
315 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
325 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
326 snprintf(filename_eMc, FILENAME_MAX,
"%s",
329 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
334 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
335 snprintf(filename_eMc, FILENAME_MAX,
"%s",
338 _snprintf(filename_eMc, FILENAME_MAX,
"%s",
361 #else // VISP_HAVE_ACCESS_TO_NAS
446 #endif // VISP_HAVE_ACCESS_TO_NAS
561 vpColVector & q,
const bool &nearest,
const bool &verbose)
const
564 double q_[2][6],d[2],t;
589 if (fMe[2][2] >= .99999f)
592 q_[0][4] = q_[1][4] = M_PI/2.f;
593 t = atan2(fMe[0][0],fMe[0][1]);
594 q_[1][3] = q_[0][3] = q[3];
595 q_[1][5] = q_[0][5] = t - q_[0][3];
609 else if (fMe[2][2] <= -.99999)
612 q_[0][4] = q_[1][4] = -M_PI/2;
613 t = atan2(fMe[1][1],fMe[1][0]);
614 q_[1][3] = q_[0][3] = q[3];
615 q_[1][5] = q_[0][5] = q_[0][3] - t;
630 q_[0][3] = atan2(-fMe[0][2],fMe[1][2]);
631 if (q_[0][3] >= 0.0) q_[1][3] = q_[0][3] - M_PI;
632 else q_[1][3] = q_[0][3] + M_PI;
634 q_[0][4] = asin(fMe[2][2]);
635 if (q_[0][4] >= 0.0) q_[1][4] = M_PI - q_[0][4];
636 else q_[1][4] = -M_PI - q_[0][4];
638 q_[0][5] = atan2(-fMe[2][1],fMe[2][0]);
639 if (q_[0][5] >= 0.0) q_[1][5] = q_[0][5] - M_PI;
640 else q_[1][5] = q_[0][5] + M_PI;
642 q_[0][0] = fMe[0][3] - this->
_long_56*cos(q_[0][3]);
643 q_[1][0] = fMe[0][3] - this->
_long_56*cos(q_[1][3]);
644 q_[0][1] = fMe[1][3] - this->
_long_56*sin(q_[0][3]);
645 q_[1][1] = fMe[1][3] - this->
_long_56*sin(q_[1][3]);
646 q_[0][2] = q_[1][2] = fMe[2][3];
652 for (
int j=0;j<2;j++)
656 for (
unsigned int i=0;i<6;i++) {
660 std::cout <<
"Joint " << i <<
" not in limits: " << this->
_joint_min[i] <<
" < " << q_[j][i] <<
" < " << this->
_joint_max[i] << std::endl;
671 std::cout <<
"No solution..." << std::endl;
675 else if (ok[1] == 1) {
676 for (
unsigned int i=0;i<6;i++) cord[i] = q_[1][i];
683 for (
unsigned int i=0;i<6;i++) cord[i] = q_[0][i];
690 for (
int j=0;j<2;j++)
693 for (
unsigned int i=3;i<6;i++)
694 d[j] += (q_[j][i] - q[i]) * (q_[j][i] - q[i]);
699 for (
unsigned int i=0;i<6;i++) cord[i] = q_[0][i];
701 for (
unsigned int i=0;i<6;i++) cord[i] = q_[1][i];
706 for (
unsigned int i=0;i<6;i++) cord[i] = q_[1][i];
708 for (
unsigned int i=0;i<6;i++) cord[i] = q_[0][i];
712 for(
unsigned int i=0; i<6; i++)
778 fMc = fMe * this->
_eMc;
810 double q5 = q[5] - this->
_coupl_56 * q[4];
812 double c1 = cos(q[3]);
813 double s1 = sin(q[3]);
814 double c2 = cos(q[4]);
815 double s2 = sin(q[4]);
821 fMe[0][0] = s1*s2*c3 + c1*s3;
822 fMe[0][1] = -s1*s2*s3 + c1*c3;
826 fMe[1][0] = -c1*s2*c3 + s1*s3;
827 fMe[1][1] = c1*s2*s3 + s1*c3;
900 double s4,c4,s5,c5,s6,c6 ;
902 s4=sin(q[3]); c4=cos(q[3]);
903 s5=sin(q[4]); c5=cos(q[4]);
907 eJe[0][0] = s4*s5*c6+c4*s6;
908 eJe[0][1] = -c4*s5*c6+s4*s6;
912 eJe[1][0] = -s4*s5*s6+c4*c6;
913 eJe[1][1] = c4*s5*s6+s4*c6;
970 fJe[0][0] = fJe[1][1] = fJe[2][2] = 1 ;
972 double s4 = sin(q[3]) ;
973 double c4 = cos(q[3]) ;
981 double s5 = sin(q[4]) ;
982 double c5 = cos(q[4]) ;
984 fJe[3][4] = c4 ; fJe[3][5] = -s4*c5 ;
985 fJe[4][4] = s4 ; fJe[4][5] = c4*c5 ;
986 fJe[5][3] = 1 ; fJe[5][5] = s5 ;
1009 for (
unsigned int i=0; i < 6; i ++)
1026 for (
unsigned int i=0; i < 6; i ++)
1068 #ifdef VISP_HAVE_ACCESS_TO_NAS
1074 char Ligne[FILENAME_MAX];
1075 char namoption[100];
1079 double trans_eMc[3];
1080 bool get_rot_eMc =
false;
1081 bool get_trans_eMc =
false;
1084 if ((fdtask = fopen(filename,
"r" )) == NULL)
1089 "Impossible to read the config file.");
1092 while (fgets(Ligne, FILENAME_MAX, fdtask) != NULL) {
1094 if (
'#' == Ligne[0]) {
continue; }
1095 sscanf(Ligne,
"%s", namoption);
1096 dim = strlen(namoption);
1099 NULL != opt_Afma6[code];
1102 if (strncmp(opt_Afma6[code], namoption, dim) == 0)
1111 sscanf(Ligne,
"%s %lf %lf %lf %lf %lf %lf",
1119 sscanf(Ligne,
"%s %lf %lf %lf %lf %lf %lf", namoption,
1126 sscanf(Ligne,
"%s %lf", namoption, &this->
_long_56);
1130 sscanf(Ligne,
"%s %lf", namoption, &this->
_coupl_56);
1137 sscanf(Ligne,
"%s %lf %lf %lf", namoption,
1143 rot_eMc[0] *= M_PI / 180.0;
1144 rot_eMc[1] *= M_PI / 180.0;
1145 rot_eMc[2] *= M_PI / 180.0;
1150 sscanf(Ligne,
"%s %lf %lf %lf", namoption,
1154 get_trans_eMc =
true;
1159 "ligne #%d.", filename, numLn);
1166 if (get_rot_eMc && get_trans_eMc) {
1167 for (
unsigned int i=0; i < 3; i ++) {
1168 _erc[i] = rot_eMc[i];
1169 _etc[i] = trans_eMc[i];
1245 const unsigned int &image_width,
1246 const unsigned int &image_height)
const
1248 #if defined(VISP_HAVE_XML2) && defined (VISP_HAVE_ACCESS_TO_NAS)
1252 std::cout <<
"Get camera parameters for camera \""
1254 <<
"from the XML file: \""
1256 if (parser.
parse(cam,
1262 "Impossible to read the camera parameters.");
1267 std::cout <<
"Get camera parameters for camera \""
1269 <<
"from the XML file: \""
1271 if (parser.
parse(cam,
1277 "Impossible to read the camera parameters.");
1282 std::cout <<
"Get camera parameters for camera \""
1284 <<
"from the XML file: \""
1286 if (parser.
parse(cam,
1292 "Impossible to read the camera parameters.");
1297 std::cout <<
"Get camera parameters for camera \""
1299 <<
"from the XML file: \""
1301 if (parser.
parse(cam,
1307 "Impossible to read the camera parameters.");
1322 "Impossible to read the camera parameters.");
1331 if (image_width == 640 && image_height == 480) {
1332 std::cout <<
"Get default camera parameters for camera \""
1344 vpTRACE(
"Cannot get default intrinsic camera parameters for this image resolution");
1346 "Impossible to read the camera parameters.");
1352 if (image_width == 640 && image_height == 480) {
1353 std::cout <<
"Get default camera parameters for camera \""
1365 vpTRACE(
"Cannot get default intrinsic camera parameters for this image resolution");
1367 "Impossible to read the camera parameters.");
1373 if (image_width == 640 && image_height == 480) {
1374 std::cout <<
"Get default camera parameters for camera \""
1386 vpTRACE(
"Cannot get default intrinsic camera parameters for this image resolution");
1388 "Impossible to read the camera parameters.");
1394 if (image_width == 640 && image_height == 480) {
1395 std::cout <<
"Get default camera parameters for camera \""
1407 vpTRACE(
"Cannot get default intrinsic camera parameters for this image resolution");
1409 "Impossible to read the camera parameters.");
1536 <<
"Joint Max:" << std::endl
1543 <<
"\t" << std::endl
1545 <<
"Joint Min: " << std::endl
1552 <<
"\t" << std::endl
1554 <<
"Long 5-6: " << std::endl
1556 <<
"\t" << std::endl
1558 <<
"Coupling 5-6:" << std::endl
1560 <<
"\t" << std::endl
1562 <<
"eMc: "<< std::endl
1563 <<
"\tTranslation (m): "
1564 << afma6.
_eMc[0][3] <<
" "
1565 << afma6.
_eMc[1][3] <<
" "
1567 <<
"\t" << std::endl
1568 <<
"\tRotation Rxyz (rad) : "
1572 <<
"\t" << std::endl
1573 <<
"\tRotation Rxyz (deg) : "
1577 <<
"\t" << std::endl;
Modelisation of Irisa's gantry robot named Afma6.
Implementation of a matrix and operations on matrices.
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
static const unsigned int njoint
Number of joint.
void get_cVe(vpVelocityTwistMatrix &cVe) const
Error that can be emited by the vpRobot class and its derivates.
static const char *const CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME
Perspective projection without distortion model.
static const char *const CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME
unsigned int getWidth() const
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
vpHomogeneousMatrix getForwardKinematics(const vpColVector &q) const
int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &nearest=true, const bool &verbose=false) const
vpAfma6ToolType getToolType() const
Get the current tool type.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
vpCameraParameters::vpCameraParametersProjType projModel
static const char *const CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME
XML parser to load and save intrinsic camera parameters.
void get_fMe(const vpColVector &q, vpHomogeneousMatrix &fMe) const
void setToolType(vpAfma6::vpAfma6ToolType tool)
Set the current tool type.
static const char *const CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME
static const char *const CONST_GRIPPER_CAMERA_NAME
Implementation of a rotation matrix and operations on such kind of matrices.
void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0)
static const vpAfma6ToolType defaultTool
Default tool attached to the robot end effector.
static const char *const CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME
static const char *const CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME
vpColVector getJointMin() const
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static const char *const CONST_CAMERA_AFMA6_FILENAME
vpCameraParametersProjType
void get_cMe(vpHomogeneousMatrix &cMe) const
static const char *const CONST_AFMA6_FILENAME
Generic class defining intrinsic camera parameters.
void parseConfigFile(const char *filename)
vpColVector getJointMax() const
void extract(vpRotationMatrix &R) const
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Implementation of a velocity twist matrix and operations on such kind of matrices.
unsigned int getRows() const
Return the number of rows of the 2D array.
Perspective projection with distortion model.
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static double rad(double deg)
static double deg(double rad)
Implementation of column vector and the associated operations.
static const char *const CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME
vpHomogeneousMatrix inverse() const
unsigned int getHeight() const
Implementation of a rotation vector as Euler angle minimal representation.
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, const unsigned int image_width=0, const unsigned int image_height=0)
static const char *const CONST_CCMOP_CAMERA_NAME
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
static const char *const CONST_VACUUM_CAMERA_NAME
void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud, const double kdu)
static const char *const CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME
void resize(const unsigned int i, const bool flagNullify=true)
static const char *const CONST_GENERIC_CAMERA_NAME
double getCoupl56() const