Verified Commit 3e5604fe authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python: fix expose of JointComposite

parent a006cfd4
Pipeline #14052 passed with stage
in 278 minutes
//
// Copyright (c) 2015-2020 CNRS INRIA
// Copyright (c) 2015-2021 CNRS INRIA
//
#ifndef __pinocchio_python_joints_models_hpp__
......@@ -9,6 +9,7 @@
#include "pinocchio/multibody/joint/joint-collection.hpp"
#include "pinocchio/multibody/joint/joint-composite.hpp"
#include "pinocchio/multibody/joint/joint-generic.hpp"
#include <eigenpy/eigen-to-python.hpp>
......@@ -31,8 +32,9 @@ namespace pinocchio
inline bp::class_<JointModelRevoluteUnaligned>& expose_joint_model<JointModelRevoluteUnaligned> (bp::class_<JointModelRevoluteUnaligned> & cl)
{
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"),
.def(bp::init<double, double, double> (bp::args("self","x", "y", "z"),
"Init JointModelRevoluteUnaligned from the components x, y, z of the axis"))
.def(bp::init<Eigen::Vector3d> (bp::args("self","axis"),
"Init JointModelRevoluteUnaligned from an axis with x-y-z components"))
.def_readwrite("axis",&JointModelRevoluteUnaligned::axis,
"Rotation axis of the JointModelRevoluteUnaligned.")
......@@ -44,9 +46,9 @@ namespace pinocchio
inline bp::class_<JointModelPrismaticUnaligned>& expose_joint_model<JointModelPrismaticUnaligned> (bp::class_<JointModelPrismaticUnaligned> & cl)
{
return cl
.def(bp::init<double, double, double> (bp::args("x", "y", "z"),
.def(bp::init<double, double, double> (bp::args("self","x", "y", "z"),
"Init JointModelPrismaticUnaligned from the components x, y, z of the axis"))
.def(bp::init<Eigen::Vector3d> (bp::args("axis"),
.def(bp::init<Eigen::Vector3d> (bp::args("self","axis"),
"Init JointModelPrismaticUnaligned from an axis with x-y-z components"))
.def_readwrite("axis",&JointModelPrismaticUnaligned::axis,
"Translation axis of the JointModelPrismaticUnaligned.")
......@@ -74,10 +76,11 @@ namespace pinocchio
}; // struct JointModelCompositeAddJointVisitor
static JointModelComposite & addJoint_proxy(JointModelComposite & joint_composite,
const JointModelVariant & jmodel_variant,
const JointModel & jmodel,
const SE3 & joint_placement = SE3::Identity())
{
return boost::apply_visitor(JointModelCompositeAddJointVisitor(joint_composite,joint_placement), jmodel_variant);
return boost::apply_visitor(JointModelCompositeAddJointVisitor(joint_composite,joint_placement),
jmodel.toVariant());
}
BOOST_PYTHON_FUNCTION_OVERLOADS(addJoint_proxy_overloads,addJoint_proxy,2,3)
......@@ -97,22 +100,25 @@ namespace pinocchio
}
}; // struct JointModelCompositeConstructorVisitor
static JointModelComposite* init_proxy1(const JointModelVariant & jmodel_variant)
static JointModelComposite* init_proxy1(const JointModel & jmodel)
{
return boost::apply_visitor(JointModelCompositeConstructorVisitor(SE3::Identity()), jmodel_variant);
return boost::apply_visitor(JointModelCompositeConstructorVisitor(SE3::Identity()),
jmodel);
}
static JointModelComposite* init_proxy2(const JointModelVariant & jmodel_variant,
static JointModelComposite* init_proxy2(const JointModel & jmodel,
const SE3 & joint_placement)
{
return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement), jmodel_variant);
return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement),
jmodel);
}
template<>
inline bp::class_<JointModelComposite>& expose_joint_model<JointModelComposite> (bp::class_<JointModelComposite> & cl)
{
return cl
.def(bp::init<const size_t> (bp::args("size"), "Init JointModelComposite with a defined size"))
.def(bp::init<const size_t> (bp::args("self","size"),
"Init JointModelComposite with a defined size"))
.def("__init__",
bp::make_constructor(init_proxy1,
bp::default_call_policies(),
......@@ -132,7 +138,7 @@ namespace pinocchio
.add_property("njoints",&JointModelComposite::njoints)
.def("addJoint",
&addJoint_proxy,
addJoint_proxy_overloads(bp::args("joint_model","joint_placement"),
addJoint_proxy_overloads(bp::args("self","joint_model","joint_placement"),
"Add a joint to the vector of joints."
)[bp::return_internal_reference<>()]
)
......
Markdown is supported
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