Commit 7b2262a1 authored by Gabriele Buondonno's avatar Gabriele Buondonno
Browse files

[bindings] [joints] Properly expose JointPrismaticUnaligned and JointRevoluteUnaligned

parent 865721db
......@@ -16,17 +16,37 @@ namespace pinocchio
namespace bp = boost::python;
// generic expose_constructor : do nothing special
// generic expose_model : do nothing special
template <class T>
inline bp::class_<T>& expose_constructors(bp::class_<T>& cl)
inline bp::class_<T>& expose_model(bp::class_<T>& cl)
{
return cl;
}
template<>
inline bp::class_<JointModelRevoluteUnaligned>& expose_constructors<JointModelRevoluteUnaligned> (bp::class_<JointModelRevoluteUnaligned> & cl)
inline bp::class_<JointModelRevoluteUnaligned>& expose_model<JointModelRevoluteUnaligned> (bp::class_<JointModelRevoluteUnaligned> & cl)
{
return cl.def(bp::init<double, double, double> ((bp::args("x"), bp::args("y"), bp::args("z")), "Init JointRevoluteUnaligned from the components x, y, z of the axis"));
return cl
.def(bp::init<double, double, double> (bp::args("x", "y", "z"), "Init JointModelRevoluteUnaligned from the components x, y, z of the axis"))
.def(bp::init<Eigen::Vector3d> (bp::args("axis"), "Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
.add_property("axis",
make_getter(&JointModelRevoluteUnaligned::axis, bp::return_value_policy<bp::return_by_value>()),
make_setter(&JointModelRevoluteUnaligned::axis, bp::return_value_policy<bp::return_by_value>()),
"Rotation axis of the JointModelRevoluteUnaligned.")
;
}
template<>
inline bp::class_<JointModelPrismaticUnaligned>& expose_model<JointModelPrismaticUnaligned> (bp::class_<JointModelPrismaticUnaligned> & cl)
{
return cl
.def(bp::init<double, double, double> (bp::args("x", "y", "z"), "Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
.def(bp::init<Eigen::Vector3d> (bp::args("axis"), "Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
.add_property("axis",
make_getter(&JointModelPrismaticUnaligned::axis, bp::return_value_policy<bp::return_by_value>()),
make_setter(&JointModelPrismaticUnaligned::axis, bp::return_value_policy<bp::return_by_value>()),
"Translation axis of the JointModelPrismaticUnaligned.")
;
}
} // namespace python
} // namespace pinocchio
......
......@@ -35,7 +35,7 @@ namespace pinocchio
template<class T>
void operator()(T)
{
expose_constructors<T>(bp::class_<T>(T::classname().c_str(),bp::init<>()).def(JointPythonVisitor<T>()));
expose_model<T>(bp::class_<T>(T::classname().c_str(),bp::init<>()).def(JointPythonVisitor<T>()));
bp::implicitly_convertible<T,pinocchio::JointModelVariant>();
}
};
......
......@@ -273,7 +273,7 @@ namespace pinocchio
updateJointIndexes();
}
static std::string classname() { return std::string("JointModelCompositeTpl"); }
static std::string classname() { return std::string("JointModelComposite"); }
std::string shortname() const { return classname(); }
JointModelCompositeTpl & operator=(const JointModelCompositeTpl & other)
......
......@@ -439,16 +439,17 @@ namespace pinocchio
typedef Eigen::Matrix<Scalar,3,1,_Options> Vector3;
JointModelPrismaticUnalignedTpl() : axis(Vector3::Constant(NAN)) {}
JointModelPrismaticUnalignedTpl() {}
JointModelPrismaticUnalignedTpl(Scalar x, Scalar y, Scalar z)
: axis(x,y,z)
{
axis << x, y, z ;
axis.normalize();
assert(axis.isUnitary() && "Translation axis is not unitary");
}
template<typename Vector3Like>
JointModelPrismaticUnalignedTpl(const Eigen::MatrixBase<Vector3Like> & axis) : axis(axis)
JointModelPrismaticUnalignedTpl(const Eigen::MatrixBase<Vector3Like> & axis)
: axis(axis)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Vector3Like);
assert(axis.isUnitary() && "Translation axis is not unitary");
......@@ -501,7 +502,7 @@ namespace pinocchio
return sqrt(Eigen::NumTraits<Scalar>::epsilon());
}
static std::string classname() { return std::string("JointModelPrismaticUnalignedTpl"); }
static std::string classname() { return std::string("JointModelPrismaticUnaligned"); }
std::string shortname() const { return classname(); }
/// \returns An expression of *this with the Scalar type casted to NewScalar.
......
......@@ -468,6 +468,7 @@ namespace pinocchio
JointModelRevoluteUnalignedTpl(const Eigen::MatrixBase<Vector3Like> & axis)
: axis(axis)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Vector3Like);
assert(axis.isUnitary() && "Rotation axis is not unitary");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment