25 typedef Eigen::Matrix<Scalar, 7, 1, Options>
Vector7s;
26 typedef Eigen::Map<SE3::Quaternion>
QuatMap;
32 res.head<3>() =
M.translation();
40 return bp::make_tuple(
41 M.translation()(0),
M.translation()(1),
M.translation()(2),
q.x(),
q.y(),
q.z(),
q.w());
44 template<
typename TupleOrList>
48 bp::ssize_t
size = bp::len(
v);
51 throw std::invalid_argument(
52 "Wrong size: v(" + std::to_string(
size) +
") should have 7 elements");
56 const Scalar &
v0 = bp::extract<Scalar>(
v[0]);
57 const Scalar & v1 = bp::extract<Scalar>(
v[1]);
58 const Scalar & v2 = bp::extract<Scalar>(
v[2]);
59 const Scalar & v3 = bp::extract<Scalar>(
v[3]);
60 const Scalar & v4 = bp::extract<Scalar>(
v[4]);
61 const Scalar & v5 = bp::extract<Scalar>(
v[5]);
62 const Scalar & v6 = bp::extract<Scalar>(
v[6]);
66 return SE3(
q.matrix(),
t);
69 template<
typename Vector7Like>
72 if (
v.rows() != 7 ||
v.cols() != 1)
74 std::ostringstream shape;
75 shape <<
"(" <<
v.rows() <<
", " <<
v.cols() <<
")";
76 throw std::invalid_argument(
77 "Wrong size: v" + shape.str() +
" but should have the following shape (7, 1)");
80 return SE3(
q.matrix(),
v.template head<3>());
83 template<
typename Vector7Like>
86 if (
v.rows() != 7 ||
v.cols() != 1)
88 std::ostringstream shape;
89 shape <<
"(" <<
v.rows() <<
", " <<
v.cols() <<
")";
90 throw std::invalid_argument(
91 "Wrong size: v" + shape.str() +
" but should have the following shape (7, 1)");
96 return SE3(
q.matrix(),
v.template head<3>());
102 const char * doc1 =
"Convert the input SE3 object to a numpy array.";
103 bp::def(
"SE3ToXYZQUAT",
fromSE3,
"M", doc1);
104 const char * doc1_tuple =
105 "Convert the input SE3 object to a 7D tuple of floats [X,Y,Z,x,y,z,w].";
106 bp::def(
"SE3ToXYZQUATtuple",
fromSE3tuple,
"M", doc1_tuple);
109 "Reverse function of SE3ToXYZQUAT: convert [X,Y,Z,x,y,z,w] to an SE3 element.";
111 "XYZQUATToSE3",
static_cast<SE3 (*)(
const bp::tuple &)
>(toSE3fromTupleOrList<bp::tuple>),
112 bp::arg(
"tuple"), doc2);
114 "XYZQUATToSE3",
static_cast<SE3 (*)(
const bp::list &)
>(toSE3fromTupleOrList<bp::list>),
115 bp::arg(
"list"), doc2);
117 "XYZQUATToSE3",
static_cast<SE3 (*)(
const VectorXs &)
>(toSE3<VectorXs>), bp::arg(
"array"),