SpaceVecAlg.hpp
Go to the documentation of this file.
1 #ifndef _VREP_SPACEVECALG_HPP_
2 #define _VREP_SPACEVECALG_HPP_
3 
4 // SpaceVecAlg
5 #include <SpaceVecAlg/SpaceVecAlg>
6 
7 // Vrep Eigen conversions
8 #include "grl/vrep/Eigen.hpp"
9 
10 /// Get the plucker transform from the object to the base.
11 ///
12 /// @param objectHandle The V-Rep object handle for which the transform is needed
13 /// @param relativeToObjectHandle The frame of reference in which to get the object handle, -1 (the default) gets the absolute position aka world frame
14 /// for constructor see: https://github.com/jrl-umi3218/SpaceVecAlg/blob/master/src/PTransform.h
15 sva::PTransform<double> getObjectPTransform(int objectHandle, int relativeToObjectHandle = -1)
16 {
17  std::pair<Eigen::Quaterniond,Eigen::Vector3d> baseQuatTransformPair = getObjectTransformQuaternionTranslationPair(objectHandle, relativeToObjectHandle);
18  sva::PTransform<double> ptransform(baseQuatTransformPair.first.inverse(),baseQuatTransformPair.second);
19  return ptransform;
20 }
21 
22 sva::PTransform<double> eigenAffineToPtransform(const Eigen::Affine3d& eigenTransform)
23 {
24  return sva::PTransform<double>(Eigen::Quaterniond(eigenTransform.rotation()).inverse(),eigenTransform.translation());
25 }
26 
27 Eigen::Affine3d PTranformToEigenAffine(sva::PTransform<double> & ptransform)
28 {
29  Eigen::Affine3d eigenTransform;
30  eigenTransform = Eigen::Quaterniond(ptransform.rotation()).inverse();
31  eigenTransform.translation() = ptransform.translation();
32  return eigenTransform;
33 }
34 
35 sva::PTransform<double> getJointPTransform(int objectHandle)
36 {
37  return eigenAffineToPtransform(getJointTransform(objectHandle));
38 }
39 
40 #endif // _VREP_SPACEVECALG_HPP_
Eigen::Affine3d PTranformToEigenAffine(sva::PTransform< double > &ptransform)
Definition: SpaceVecAlg.hpp:27
sva::PTransform< double > getJointPTransform(int objectHandle)
Definition: SpaceVecAlg.hpp:35
Eigen::Affine3d getJointTransform(int objectHandle)
Eigen version of simGetJointMatrix.
Definition: Eigen.hpp:176
sva::PTransform< double > eigenAffineToPtransform(const Eigen::Affine3d &eigenTransform)
Definition: SpaceVecAlg.hpp:22
sva::PTransform< double > getObjectPTransform(int objectHandle, int relativeToObjectHandle=-1)
Definition: SpaceVecAlg.hpp:15
std::pair< Eigen::Quaterniond, Eigen::Vector3d > getObjectTransformQuaternionTranslationPair(int objectHandle, int relativeToObjectHandle=-1)
Definition: Eigen.hpp:160