3 #ifndef _VREP_EIGEN_HPP_ 4 #define _VREP_EIGEN_HPP_ 7 #include <Eigen/Geometry> 20 template<
typename InputIterator>
33 std::array<float,4> qa;
48 std::array<float,3> qv;
56 template<
typename Input>
59 return ax3d.angle()*ax3d.axis();
62 template<
typename Input>
64 Eigen::AngleAxisd ax3d(eigenQuat);
65 return ax3d.angle()*ax3d.axis();
69 template<
typename InputIterator>
72 Eigen::Vector3d vec(vrepVec[0],vrepVec[1],vrepVec[2]);
87 Eigen::Map<const Eigen::Matrix<float,3,4,Eigen::RowMajor>> vmap(vrepTransform.cbegin());
88 Eigen::Affine3d eigenTransform;
89 eigenTransform.translation() = vmap.block<3,1>(0,3).cast<double>();
90 eigenTransform.matrix().block<3,3>(0,0) = vmap.block<3,3>(0,0).cast<
double>();
92 return eigenTransform;
98 std::array<float,3> simTipPosition;
100 std::array<float,4> simTipQuaternion;
103 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"HandEyeCalibrationVrepPlugin: Could not get position"));
105 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"HandEyeCalibrationVrepPlugin: Could not get quaternion"));
112 return std::make_pair(simTipAngleAxis,simTipVec);
120 Eigen::Quaternion<typename T::Scalar> eigenQuat(transform.rotation());
123 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"setObjectTransform: Could not set Quaternion"));
127 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"setObjectTransform: Could not set Quaternion"));
137 std::array<float,4> vrepQuat;
140 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"getObjectTransform: Could not get Quaternion"));
142 std::array<float,3> vrepPos;
144 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"getObjectTransform: Could not get Position"));
147 Eigen::Affine3d transform;
149 transform = eigenQuat;
150 transform.translation() = eigenPos;
162 std::array<float,4> vrepQuat;
164 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"getObjectTransformQuaternionTranslationPair: Could not get Quaternion"));
167 std::array<float,3> vrepPos;
169 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"getObjectTransformQuaternionTranslationPair: Could not get Position"));
172 return std::make_pair(eigenQuat,eigenPos);
182 std::array<float,12> vrepTransform;
184 if(ret==-1) BOOST_THROW_EXCEPTION(std::runtime_error(
"getJointTransform: Could not get Joint Matrix"));
189 static std::string poseString(
const Eigen::Transform<T,3,Eigen::Affine>& pose,
const std::string& pfx =
"")
191 std::stringstream ss;
193 for (
int y=0;
y<4;
y++)
196 for (
int x=0;
x<4;
x++)
198 ss << std::setw(8) << pose(
y,
x) <<
" ";
209 static std::string posString(
const Eigen::Vector3d& pos,
const std::string& pfx =
"(",
const std::string& sfx =
")")
211 std::stringstream ss;
214 for (
int x=0;
x<3;
x++)
218 ss << std::setw(8) << pos(
x);
ptrSimGetJointMatrix simGetJointMatrix
Eigen::Affine3d getObjectTransform(int objectHandle, int relativeToObjectHandle=-1)
Eigen::Vector3d vrepQuatToEigenVector3dAngleAxis(Input vrepQuat)
Eigen::Vector3d vrepToEigenVector3d(InputIterator vrepVec)
ptrSimGetObjectPosition simGetObjectPosition
std::array< float, 3 > EigenToVrepPosition(const P &p)
Eigen::Affine3d vrepToEigenTransform(const std::array< float, 12 > &vrepTransform)
ptrSimSetObjectPosition simSetObjectPosition
Eigen::Vector3d eigenRotToEigenVector3dAngleAxis(Input eigenQuat)
Eigen::Affine3d getJointTransform(int objectHandle)
Eigen version of simGetJointMatrix.
void setObjectTransform(int objectHandle, int relativeToObjectHandle, T &transform)
ptrSimSetObjectQuaternion simSetObjectQuaternion
ptrSimGetObjectQuaternion simGetObjectQuaternion
std::pair< Eigen::Vector3d, Eigen::Vector3d > getAxisAngleAndTranslation(int ObjectHandle, int BaseFrameObjectHandle)
std::array< float, 4 > EigenToVrepQuaternion(const Q &q)
Eigen::Quaterniond vrepToEigenQuaternion(InputIterator vrepQuat)
std::pair< Eigen::Quaterniond, Eigen::Vector3d > getObjectTransformQuaternionTranslationPair(int objectHandle, int relativeToObjectHandle=-1)