50 #include <visp3/core/vpCameraParameters.h> 51 #include <visp3/core/vpDebug.h> 52 #include <visp3/core/vpRotationMatrix.h> 53 #include <visp3/core/vpRxyzVector.h> 54 #include <visp3/core/vpTranslationVector.h> 55 #include <visp3/core/vpVelocityTwistMatrix.h> 56 #include <visp3/core/vpXmlParserCamera.h> 57 #include <visp3/robot/vpAfma6.h> 58 #include <visp3/robot/vpRobotException.h> 64 static const char *opt_Afma6[] = {
"JOINT_MAX",
"JOINT_MIN",
"LONG_56",
"COUPL_56",
65 "CAMERA",
"eMc_ROT_XYZ",
"eMc_TRANS_XYZ", NULL};
67 #ifdef VISP_HAVE_AFMA6_DATA 69 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_Afma6.cnf");
72 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_ccmop_without_distortion_Afma6.cnf");
75 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_ccmop_with_distortion_Afma6.cnf");
78 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_gripper_without_distortion_Afma6.cnf");
81 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_gripper_with_distortion_Afma6.cnf");
84 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_vacuum_without_distortion_Afma6.cnf");
87 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_vacuum_with_distortion_Afma6.cnf");
90 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_generic_without_distortion_Afma6.cnf");
93 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_generic_with_distortion_Afma6.cnf");
96 std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_camera_Afma6.xml");
98 #endif // VISP_HAVE_AFMA6_DATA 115 : _coupl_56(0), _long_56(0), _etc(), _erc(), _eMc(), tool_current(
vpAfma6::defaultTool),
171 void vpAfma6::init(
const std::string &camera_extrinsic_parameters,
const std::string &camera_intrinsic_parameters)
271 #ifdef VISP_HAVE_AFMA6_DATA 273 std::string filename_eMc;
335 #else // VISP_HAVE_AFMA6_DATA 421 #endif // VISP_HAVE_AFMA6_DATA 532 const bool &verbose)
const 535 double q_[2][6], d[2], t;
559 if (fMe[2][2] >= .99999f) {
561 q_[0][4] = q_[1][4] = M_PI / 2.f;
562 t = atan2(fMe[0][0], fMe[0][1]);
563 q_[1][3] = q_[0][3] = q[3];
564 q_[1][5] = q_[0][5] = t - q_[0][3];
576 }
else if (fMe[2][2] <= -.99999) {
578 q_[0][4] = q_[1][4] = -M_PI / 2;
579 t = atan2(fMe[1][1], fMe[1][0]);
580 q_[1][3] = q_[0][3] = q[3];
581 q_[1][5] = q_[0][5] = q_[0][3] - t;
593 q_[0][3] = atan2(-fMe[0][2], fMe[1][2]);
595 q_[1][3] = q_[0][3] - M_PI;
597 q_[1][3] = q_[0][3] + M_PI;
599 q_[0][4] = asin(fMe[2][2]);
601 q_[1][4] = M_PI - q_[0][4];
603 q_[1][4] = -M_PI - q_[0][4];
605 q_[0][5] = atan2(-fMe[2][1], fMe[2][0]);
607 q_[1][5] = q_[0][5] - M_PI;
609 q_[1][5] = q_[0][5] + M_PI;
611 q_[0][0] = fMe[0][3] - this->
_long_56 * cos(q_[0][3]);
612 q_[1][0] = fMe[0][3] - this->
_long_56 * cos(q_[1][3]);
613 q_[0][1] = fMe[1][3] - this->
_long_56 * sin(q_[0][3]);
614 q_[1][1] = fMe[1][3] - this->
_long_56 * sin(q_[1][3]);
615 q_[0][2] = q_[1][2] = fMe[2][3];
621 for (
int j = 0; j < 2; j++) {
624 for (
unsigned int i = 0; i < 6; i++) {
628 std::cout <<
"Joint " << i <<
" not in limits: " << this->
_joint_min[i] <<
" < " << q_[j][i] <<
" < " 640 std::cout <<
"No solution..." << std::endl;
643 }
else if (ok[1] == 1) {
644 for (
unsigned int i = 0; i < 6; i++)
650 for (
unsigned int i = 0; i < 6; i++)
656 for (
int j = 0; j < 2; j++) {
658 for (
unsigned int i = 3; i < 6; i++)
659 d[j] += (q_[j][i] - q[i]) * (q_[j][i] - q[i]);
661 if (nearest ==
true) {
663 for (
unsigned int i = 0; i < 6; i++)
666 for (
unsigned int i = 0; i < 6; i++)
670 for (
unsigned int i = 0; i < 6; i++)
673 for (
unsigned int i = 0; i < 6; i++)
678 for (
unsigned int i = 0; i < 6; i++)
742 fMc = fMe * this->
_eMc;
773 double q5 = q[5] - this->
_coupl_56 * q[4];
775 double c1 = cos(q[3]);
776 double s1 = sin(q[3]);
777 double c2 = cos(q[4]);
778 double s2 = sin(q[4]);
784 fMe[0][0] = s1 * s2 * c3 + c1 * s3;
785 fMe[0][1] = -s1 * s2 * s3 + c1 * c3;
786 fMe[0][2] = -s1 * c2;
787 fMe[0][3] = q0 + this->
_long_56 * c1;
789 fMe[1][0] = -c1 * s2 * c3 + s1 * s3;
790 fMe[1][1] = c1 * s2 * s3 + s1 * c3;
792 fMe[1][3] = q1 + this->
_long_56 * s1;
795 fMe[2][1] = -c2 * s3;
868 double s4, c4, s5, c5, s6, c6;
878 eJe[0][0] = s4 * s5 * c6 + c4 * s6;
879 eJe[0][1] = -c4 * s5 * c6 + s4 * s6;
881 eJe[0][3] = -this->
_long_56 * s5 * c6;
883 eJe[1][0] = -s4 * s5 * s6 + c4 * c6;
884 eJe[1][1] = c4 * s5 * s6 + s4 * c6;
885 eJe[1][2] = -c5 * s6;
886 eJe[1][3] = this->
_long_56 * s5 * s6;
888 eJe[2][0] = -s4 * c5;
896 eJe[4][3] = -c5 * s6;
939 fJe[0][0] = fJe[1][1] = fJe[2][2] = 1;
941 double s4 = sin(q[3]);
942 double c4 = cos(q[3]);
948 double s5 = sin(q[4]);
949 double c5 = cos(q[4]);
952 fJe[3][5] = -s4 * c5;
977 for (
unsigned int i = 0; i < 6; i++)
993 for (
unsigned int i = 0; i < 6; i++)
1029 std::ifstream fdconfig(filename.c_str(), std::ios::in);
1031 if (!fdconfig.is_open()) {
1038 bool get_erc =
false;
1039 bool get_etc =
false;
1042 while (std::getline(fdconfig, line)) {
1044 if ((line.compare(0, 1,
"#") == 0) || line.empty()) {
1047 std::istringstream ss(line);
1051 for (code = 0; NULL != opt_Afma6[code]; ++code) {
1052 if (key.compare(opt_Afma6[code]) == 0) {
1080 ss >> erc[0] >> erc[1] >> erc[2];
1083 erc = erc * M_PI / 180.0;
1088 ss >> etc[0] >> etc[1] >> etc[2];
1094 filename.c_str(), lineNum));
1101 if (get_etc && get_erc) {
1190 const unsigned int &image_height)
const 1192 #if defined(VISP_HAVE_PUGIXML) && defined(VISP_HAVE_AFMA6_DATA) 1249 if (image_width == 640 && image_height == 480) {
1261 vpTRACE(
"Cannot get default intrinsic camera parameters for this image " 1269 if (image_width == 640 && image_height == 480) {
1281 vpTRACE(
"Cannot get default intrinsic camera parameters for this image " 1289 if (image_width == 640 && image_height == 480) {
1301 vpTRACE(
"Cannot get default intrinsic camera parameters for this image " 1309 if (image_width == 640 && image_height == 480) {
1321 vpTRACE(
"Cannot get default intrinsic camera parameters for this image " 1444 os <<
"Joint Max:" << std::endl
1448 <<
"Joint Min: " << std::endl
1452 <<
"Long 5-6: " << std::endl
1453 <<
"\t" << afma6.
_long_56 <<
"\t" << std::endl
1455 <<
"Coupling 5-6:" << std::endl
1456 <<
"\t" << afma6.
_coupl_56 <<
"\t" << std::endl
1458 <<
"eMc: " << std::endl
1459 <<
"\tTranslation (m): " << afma6.
_eMc[0][3] <<
" " << afma6.
_eMc[1][3] <<
" " << afma6.
_eMc[2][3] <<
"\t" 1461 <<
"\tRotation Rxyz (rad) : " << rxyz[0] <<
" " << rxyz[1] <<
" " << rxyz[2] <<
"\t" << std::endl
1463 <<
"\t" << std::endl;
static const std::string CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME
Modelisation of Irisa's gantry robot named Afma6.
Implementation of a matrix and operations on matrices.
vpRxyzVector buildFrom(const vpRotationMatrix &R)
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
static const unsigned int njoint
Number of joint.
static const std::string CONST_AFMA6_FILENAME
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Error that can be emited by the vpRobot class and its derivates.
static const std::string CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpColVector getJointMax() const
void parseConfigFile(const std::string &filename)
static const std::string CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME
int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &nearest=true, const bool &verbose=false) const
static const std::string CONST_CAMERA_AFMA6_FILENAME
void get_cVe(vpVelocityTwistMatrix &cVe) const
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
unsigned int getRows() const
vpHomogeneousMatrix inverse() const
vpCameraParameters::vpCameraParametersProjType projModel
vpAfma6ToolType getToolType() const
Get the current tool type.
void extract(vpRotationMatrix &R) const
XML parser to load and save intrinsic camera parameters.
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpAfma6 &afma6)
void setToolType(vpAfma6::vpAfma6ToolType tool)
Set the current tool type.
static const std::string CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME
static const char *const CONST_GRIPPER_CAMERA_NAME
Implementation of a rotation matrix and operations on such kind of matrices.
static const vpAfma6ToolType defaultTool
Default tool attached to the robot end effector.
vpHomogeneousMatrix get_eMc() const
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
static const std::string CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME
static const std::string CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME
vpCameraParametersProjType
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Generic class defining intrinsic camera parameters.
vpColVector getJointMin() const
vpHomogeneousMatrix getForwardKinematics(const vpColVector &q) const
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
static double rad(double deg)
static const std::string CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME
int parse(vpCameraParameters &cam, const std::string &filename, const std::string &camera_name, const vpCameraParameters::vpCameraParametersProjType &projModel, unsigned int image_width=0, unsigned int image_height=0)
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
void get_fMe(const vpColVector &q, vpHomogeneousMatrix &fMe) const
virtual void set_eMc(const vpHomogeneousMatrix &eMc)
void resize(unsigned int i, bool flagNullify=true)
vpTranslationVector getTranslationVector() const
static double deg(double rad)
unsigned int getHeight() const
Implementation of column vector and the associated operations.
void get_cMe(vpHomogeneousMatrix &cMe) const
Implementation of a rotation vector as Euler angle minimal representation.
static const char *const CONST_CCMOP_CAMERA_NAME
unsigned int getWidth() const
static const std::string CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME
static const char *const CONST_VACUUM_CAMERA_NAME
Class that consider the case of a translation vector.
double getCoupl56() const
static const char *const CONST_GENERIC_CAMERA_NAME