45#include <visp3/core/vpCameraParameters.h>
46#include <visp3/core/vpDebug.h>
47#include <visp3/core/vpRotationMatrix.h>
48#include <visp3/core/vpRxyzVector.h>
49#include <visp3/core/vpTranslationVector.h>
50#include <visp3/core/vpVelocityTwistMatrix.h>
51#include <visp3/core/vpXmlParserCamera.h>
52#include <visp3/robot/vpAfma6.h>
53#include <visp3/robot/vpRobotException.h>
60static const char *opt_Afma6[] = {
"JOINT_MAX",
"JOINT_MIN",
"LONG_56",
"COUPL_56",
61 "CAMERA",
"eMc_ROT_XYZ",
"eMc_TRANS_XYZ",
nullptr };
63#ifdef VISP_HAVE_AFMA6_DATA
65std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_Afma6.cnf");
68std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_ccmop_without_distortion_Afma6.cnf");
71std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_ccmop_with_distortion_Afma6.cnf");
74std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_gripper_without_distortion_Afma6.cnf");
77std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_gripper_with_distortion_Afma6.cnf");
80std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_vacuum_without_distortion_Afma6.cnf");
83std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_vacuum_with_distortion_Afma6.cnf");
86std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_generic_without_distortion_Afma6.cnf");
89std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_generic_with_distortion_Afma6.cnf");
92std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_Intel_D435_without_distortion_Afma6.cnf");
95std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_eMc_Intel_D435_with_distortion_Afma6.cnf");
98std::string(VISP_AFMA6_DATA_PATH) + std::string(
"/include/const_camera_Afma6.xml");
173void vpAfma6::init(
const std::string &camera_extrinsic_parameters,
const std::string &camera_intrinsic_parameters)
273#ifdef VISP_HAVE_AFMA6_DATA
275 std::string filename_eMc;
287 "Feature TOOL_CCMOP is not implemented for Kannala-Brandt projection model yet.");
302 "Feature TOOL_GRIPPER is not implemented for Kannala-Brandt projection model yet.");
317 "Feature TOOL_VACUUM is not implemented for Kannala-Brandt projection model yet.");
332 "Feature TOOL_INTEL_D435_CAMERA is not implemented for Kannala-Brandt projection model yet.");
347 "Feature TOOL_GENERIC_CAMERA is not implemented for Kannala-Brandt projection model yet.");
384 "Feature TOOL_CCMOP is not implemented for Kannala-Brandt projection model yet.");
408 "Feature TOOL_GRIPPER is not implemented for Kannala-Brandt projection model yet.");
432 "Feature TOOL_VACUUM is not implemented for Kannala-Brandt projection model yet.");
456 "Feature TOOL_INTEL_D435_CAMERA is not implemented for Kannala-Brandt projection model yet.");
475 "Feature TOOL_GENERIC_CAMERA is not implemented for Kannala-Brandt projection model yet.");
597 const bool &verbose)
const
600 double q_[2][6], d[2], t;
621 fMe = fMc * this->
_eMc.inverse();
624 if (fMe[2][2] >= .99999f) {
626 q_[0][4] = q_[1][4] = M_PI / 2.f;
627 t = atan2(fMe[0][0], fMe[0][1]);
628 q_[1][3] = q_[0][3] = q[3];
629 q_[1][5] = q_[0][5] = t - q_[0][3];
642 else if (fMe[2][2] <= -.99999) {
644 q_[0][4] = q_[1][4] = -M_PI / 2;
645 t = atan2(fMe[1][1], fMe[1][0]);
646 q_[1][3] = q_[0][3] = q[3];
647 q_[1][5] = q_[0][5] = q_[0][3] - t;
660 q_[0][3] = atan2(-fMe[0][2], fMe[1][2]);
662 q_[1][3] = q_[0][3] - M_PI;
664 q_[1][3] = q_[0][3] + M_PI;
666 q_[0][4] = asin(fMe[2][2]);
668 q_[1][4] = M_PI - q_[0][4];
670 q_[1][4] = -M_PI - q_[0][4];
672 q_[0][5] = atan2(-fMe[2][1], fMe[2][0]);
674 q_[1][5] = q_[0][5] - M_PI;
676 q_[1][5] = q_[0][5] + M_PI;
678 q_[0][0] = fMe[0][3] - this->
_long_56 * cos(q_[0][3]);
679 q_[1][0] = fMe[0][3] - this->
_long_56 * cos(q_[1][3]);
680 q_[0][1] = fMe[1][3] - this->
_long_56 * sin(q_[0][3]);
681 q_[1][1] = fMe[1][3] - this->
_long_56 * sin(q_[1][3]);
682 q_[0][2] = q_[1][2] = fMe[2][3];
688 for (
int j = 0; j < 2; j++) {
691 for (
unsigned int i = 0; i < 6; i++) {
695 std::cout <<
"Joint " << i <<
" not in limits: " << this->
_joint_min[i] <<
" < " << q_[j][i] <<
" < "
707 std::cout <<
"No solution..." << std::endl;
711 else if (ok[1] == 1) {
712 for (
unsigned int i = 0; i < 6; i++)
719 for (
unsigned int i = 0; i < 6; i++)
726 for (
int j = 0; j < 2; j++) {
728 for (
unsigned int i = 3; i < 6; i++)
729 d[j] += (q_[j][i] - q[i]) * (q_[j][i] - q[i]);
731 if (nearest ==
true) {
733 for (
unsigned int i = 0; i < 6; i++)
736 for (
unsigned int i = 0; i < 6; i++)
741 for (
unsigned int i = 0; i < 6; i++)
744 for (
unsigned int i = 0; i < 6; i++)
749 for (
unsigned int i = 0; i < 6; i++)
813 fMc = fMe * this->
_eMc;
844 double q5 = q[5] - this->
_coupl_56 * q[4];
846 double c1 = cos(q[3]);
847 double s1 = sin(q[3]);
848 double c2 = cos(q[4]);
849 double s2 = sin(q[4]);
855 fMe[0][0] = s1 * s2 * c3 + c1 * s3;
856 fMe[0][1] = -s1 * s2 * s3 + c1 * c3;
857 fMe[0][2] = -s1 * c2;
858 fMe[0][3] = q0 + this->
_long_56 * c1;
860 fMe[1][0] = -c1 * s2 * c3 + s1 * s3;
861 fMe[1][1] = c1 * s2 * s3 + s1 * c3;
863 fMe[1][3] = q1 + this->
_long_56 * s1;
866 fMe[2][1] = -c2 * s3;
939 double s4, c4, s5, c5, s6, c6;
949 eJe[0][0] = s4 * s5 * c6 + c4 * s6;
950 eJe[0][1] = -c4 * s5 * c6 + s4 * s6;
952 eJe[0][3] = -this->
_long_56 * s5 * c6;
954 eJe[1][0] = -s4 * s5 * s6 + c4 * c6;
955 eJe[1][1] = c4 * s5 * s6 + s4 * c6;
956 eJe[1][2] = -c5 * s6;
957 eJe[1][3] = this->
_long_56 * s5 * s6;
959 eJe[2][0] = -s4 * c5;
967 eJe[4][3] = -c5 * s6;
1010 fJe[0][0] = fJe[1][1] = fJe[2][2] = 1;
1012 double s4 = sin(q[3]);
1013 double c4 = cos(q[3]);
1019 double s5 = sin(q[4]);
1020 double c5 = cos(q[4]);
1023 fJe[3][5] = -s4 * c5;
1025 fJe[4][5] = c4 * c5;
1031 fJe[4][4] += -this->
_coupl_56 * c4 * c5;
1048 for (
unsigned int i = 0; i < 6; i++)
1064 for (
unsigned int i = 0; i < 6; i++)
1100 std::ifstream fdconfig(filename.c_str(), std::ios::in);
1102 if (!fdconfig.is_open()) {
1109 bool get_erc =
false;
1110 bool get_etc =
false;
1113 while (std::getline(fdconfig, line)) {
1115 if ((line.compare(0, 1,
"#") == 0) || line.empty()) {
1118 std::istringstream ss(line);
1122 for (code = 0;
nullptr != opt_Afma6[code]; ++code) {
1123 if (key.compare(opt_Afma6[code]) == 0) {
1151 ss >> erc[0] >> erc[1] >> erc[2];
1154 erc = erc * M_PI / 180.0;
1159 ss >> etc[0] >> etc[1] >> etc[2];
1165 filename.c_str(), lineNum));
1172 if (get_etc && get_erc) {
1195 this->
_erc.buildFrom(R);
1263 const unsigned int &image_height)
const
1265#if defined(VISP_HAVE_AFMA6_DATA) && defined(VISP_HAVE_PUGIXML)
1331 if (image_width == 640 && image_height == 480) {
1336 cam.initPersProjWithoutDistortion(1108.0, 1110.0, 314.5, 243.2);
1339 cam.initPersProjWithDistortion(1090.6, 1090.0, 310.1, 260.8, -0.2114, 0.2217);
1343 "Feature getCameraParameters is not implemented for Kannala-Brandt projection model yet.");
1347 vpTRACE(
"Cannot get default intrinsic camera parameters for this image "
1355 if (image_width == 640 && image_height == 480) {
1360 cam.initPersProjWithoutDistortion(850.9, 853.0, 311.1, 243.6);
1363 cam.initPersProjWithDistortion(837.0, 837.5, 308.7, 251.6, -0.1455, 0.1511);
1367 "Feature getCameraParameters is not implemented for Kannala-Brandt projection model yet.");
1371 vpTRACE(
"Cannot get default intrinsic camera parameters for this image "
1379 if (image_width == 640 && image_height == 480) {
1384 cam.initPersProjWithoutDistortion(853.5, 856.0, 307.8, 236.8);
1387 cam.initPersProjWithDistortion(828.5, 829.0, 322.5, 232.9, -0.1921, 0.2057);
1391 "Feature getCameraParameters is not implemented for Kannala-Brandt projection model yet.");
1395 vpTRACE(
"Cannot get default intrinsic camera parameters for this image "
1403 if (image_width == 640 && image_height == 480) {
1408 cam.initPersProjWithoutDistortion(605.4, 605.6, 328.6, 241.0);
1411 cam.initPersProjWithDistortion(611.8, 612.6, 327.8, 241.7, 0.0436, -0.04265);
1415 "Feature getCameraParameters is not implemented for Kannala-Brandt projection model yet.");
1419 vpTRACE(
"Cannot get default intrinsic camera parameters for this image "
1427 if (image_width == 640 && image_height == 480) {
1432 cam.initPersProjWithoutDistortion(853.5, 856.0, 307.8, 236.8);
1435 cam.initPersProjWithDistortion(828.5, 829.0, 322.5, 232.9, -0.1921, 0.2057);
1439 "Feature getCameraParameters is not implemented for Kannala-Brandt projection model yet.");
1443 vpTRACE(
"Cannot get default intrinsic camera parameters for this image "
1574 os <<
"Joint Max:" << std::endl
1578 <<
"Joint Min: " << std::endl
1582 <<
"Long 5-6: " << std::endl
1583 <<
"\t" << afma6.
_long_56 <<
"\t" << std::endl
1585 <<
"Coupling 5-6:" << std::endl
1586 <<
"\t" << afma6.
_coupl_56 <<
"\t" << std::endl
1588 <<
"eMc: " << std::endl
1589 <<
"\tTranslation (m): " << afma6.
_eMc[0][3] <<
" " << afma6.
_eMc[1][3] <<
" " << afma6.
_eMc[2][3] <<
"\t"
1591 <<
"\tRotation Rxyz (rad) : " << rxyz[0] <<
" " << rxyz[1] <<
" " << rxyz[2] <<
"\t" << std::endl
1593 <<
"\t" << std::endl;
static const std::string CONST_EMC_GENERIC_WITHOUT_DISTORTION_FILENAME
static const char *const CONST_CCMOP_CAMERA_NAME
static const std::string CONST_EMC_CCMOP_WITH_DISTORTION_FILENAME
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpAfma6 &afma6)
virtual void set_eMc(const vpHomogeneousMatrix &eMc)
static const std::string CONST_EMC_CCMOP_WITHOUT_DISTORTION_FILENAME
void get_cVe(vpVelocityTwistMatrix &cVe) const
static const std::string CONST_EMC_INTEL_D435_WITHOUT_DISTORTION_FILENAME
vpColVector getJointMax() const
static const std::string CONST_CAMERA_AFMA6_FILENAME
vpHomogeneousMatrix getForwardKinematics(const vpColVector &q) const
static const unsigned int njoint
Number of joint.
int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &nearest=true, const bool &verbose=false) const
static const char *const CONST_VACUUM_CAMERA_NAME
void get_fMe(const vpColVector &q, vpHomogeneousMatrix &fMe) const
static const std::string CONST_EMC_GRIPPER_WITHOUT_DISTORTION_FILENAME
void get_cMe(vpHomogeneousMatrix &cMe) const
void setToolType(vpAfma6::vpAfma6ToolType tool)
Set the current tool type.
vpAfma6ToolType getToolType() const
Get the current tool type.
static const std::string CONST_EMC_INTEL_D435_WITH_DISTORTION_FILENAME
vpColVector getJointMin() const
static const char *const CONST_INTEL_D435_CAMERA_NAME
double getCoupl56() const
static const vpAfma6ToolType defaultTool
Default tool attached to the robot end effector.
static const char *const CONST_GRIPPER_CAMERA_NAME
static const std::string CONST_EMC_GRIPPER_WITH_DISTORTION_FILENAME
void parseConfigFile(const std::string &filename)
vpHomogeneousMatrix get_eMc() const
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
vpAfma6ToolType tool_current
Current tool in use.
vpHomogeneousMatrix get_fMc(const vpColVector &q) const
static const char *const CONST_GENERIC_CAMERA_NAME
vpCameraParameters::vpCameraParametersProjType projModel
static const std::string CONST_EMC_VACUUM_WITHOUT_DISTORTION_FILENAME
static const std::string CONST_EMC_GENERIC_WITH_DISTORTION_FILENAME
static const std::string CONST_EMC_VACUUM_WITH_DISTORTION_FILENAME
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
static const std::string CONST_AFMA6_FILENAME
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int getRows() const
Generic class defining intrinsic camera parameters.
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with distortion model.
@ ProjWithKannalaBrandtDistortion
Projection with Kannala-Brandt distortion model.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
@ notImplementedError
Not implemented.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpTranslationVector getTranslationVector() const
void extract(vpRotationMatrix &R) const
Definition of the vpImage class member functions.
static double rad(double deg)
static double deg(double rad)
Implementation of a matrix and operations on matrices.
Error that can be emitted by the vpRobot class and its derivatives.
@ readingParametersError
Cannot parse parameters.
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
Class that consider the case of a translation vector.
vpVelocityTwistMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
XML parser to load and save intrinsic camera parameters.