Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Support for Mimic Joint #2441

Open
wants to merge 166 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
b956bcd
Add Urdf support for mimic joint (revolute and prismatic)
Sep 29, 2024
76bff65
Sample Model : Now support a mimic joint at the end if wanted
Sep 29, 2024
2b55c36
[Joints] Added support for nj and idx_j
Sep 29, 2024
a2a53bd
[Joint] Mimic joint is now based on the variant and not templated
Sep 29, 2024
7e900fa
[Model] Support for nj and idx_j
Sep 29, 2024
c415d95
[Data] Jacobian is now indexed on nj
Sep 29, 2024
8d0706e
[LieGroup] Neutral Specialization for mimic joints
Sep 29, 2024
ed1fd8e
[Serialization] Fix serialization
Sep 29, 2024
7455aee
[Unittest] Fix unittest
Sep 29, 2024
8173a72
[unittest] Fix for mimic
Sep 29, 2024
68ea871
[Python] Add bindings
Sep 29, 2024
36d83e6
[Urdf] Add possibility to use mimic or not
Sep 29, 2024
2bfea6b
[Serialization] Fix Test and serialization
Sep 29, 2024
1be7027
[Mimic] Joint Tpl instead of JointBase
Sep 29, 2024
30ef759
[Broken test] copy visitor from variant to variant
Sep 29, 2024
eba0592
Add mimic to shortcuts
Sep 29, 2024
89a087d
wip
Sep 29, 2024
bfc58be
Copy constructor instead of =
Sep 29, 2024
d752dd2
[EtienneAr feedback] Add mimic constructor for different primay/secon…
Sep 29, 2024
d3b8880
[EtienneAr feedback] Move transferVariant to joint-basic-visitors and…
Sep 29, 2024
5c22df6
[EtienneAr feedback] PoC: fix appendModel
Sep 29, 2024
092566c
[EtienneAr feedback] Fix sample model for mimic in manipulator
Sep 29, 2024
e754d3d
[EtienneAr feedback] Joint Mimic jointConfigSelector_impl follows con…
Sep 29, 2024
8b07410
[EtienneAr feedback] Fix appendToModel when mimic joint in model
Sep 29, 2024
7ad0434
[EtienneAr feedback] Apply pre-commit
Sep 29, 2024
137ecd9
[EtienneAr feedback] Turn on mimic joint in model, reachable-workspac…
Sep 29, 2024
a7daddd
[EtienneAr feedback] Split jointCols jointRows and jointBLock for ful…
Sep 29, 2024
203ba63
[URDF] Modified the way mimic joint are added (still broken for romeo…
Sep 29, 2024
0681ffb
[urdf] Fix parsing of mimic joints
Sep 29, 2024
503043b
[Example] Fix to include mimic
Sep 29, 2024
a1bb911
[robot_wrapper] Fix to include mimic
Sep 29, 2024
93dc075
Merge branch
Sep 29, 2024
33c2a88
[RNEA] Modify to take mimic into account
Sep 29, 2024
4458142
[Mimic] Modify to be able to mimic from base to Tpl
Sep 29, 2024
9eac944
[SampleModel] Test to compare a mimic and non mimic model
Sep 29, 2024
6cf3fed
[Data] Check on mimic is disable for now
Sep 29, 2024
bc4481d
Working test
Sep 29, 2024
b5bc007
[EtienneAr feedback] Fix RNEA: initialize tau to zero before summing
Sep 29, 2024
2976eff
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
d638c07
[EtienneAr feedback] Test crba before rnea for mimic joints
Sep 29, 2024
a6edd57
[EtienneAr feedback] Port crba fix to algorithm with other convention
Sep 29, 2024
fe11876
[EtienneAr feedback] Port crba fix to rnea, compute-all-terms and con…
Sep 29, 2024
c7d2332
[EtienneAr feedback] Revert useless change on Fcrb in crna.hxx
Sep 29, 2024
7047580
[EtienneAr feedback] Make M matrix symetric in test
Sep 29, 2024
67a4a86
[EtienneAr feedback] Properly use data.nle instead of rnea
Sep 29, 2024
928b80c
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
cd1365d
[EtienneAr feedback] Fix RNEA after chage for mimic joints
Sep 29, 2024
09d352b
[example] Change buildModelUrdf - added mimic bool
Sep 29, 2024
0cc0e82
[mimic-joint] Added support for FreeFlyer
Sep 29, 2024
6854df2
[unittest] Added bool mimic to build urdf
Sep 29, 2024
c02c167
[Joint] Split Joint ConfigSelector in two functions
Sep 29, 2024
bdf1f2d
Apply pre-commit
Sep 29, 2024
ac83802
Split JointVelocitySelector in two functions
Sep 29, 2024
ddc25ef
Apply pre-commit
Sep 29, 2024
3f2698d
[EtienneAr feedback] Add more test for joint mimic in non trivial cases
Sep 29, 2024
4e3673d
[EtienneAr feedback] Fix scaling and offset in mimic joint calc
Sep 29, 2024
2d186e1
[EtienneAr feedback] WiP: Fix ConfigVectorAffineTransform template sp…
Sep 29, 2024
8981a5d
[EtienneAr feedback] Make visitor for config vector affine transform
Sep 29, 2024
c4d0987
[EtienneAr feedback] Move configVectorAffineTransform code to joint-b…
Sep 29, 2024
243fc01
[EtienneAr feedback] Add more test cases for config vector affine tra…
Sep 29, 2024
63bd463
[EtienneAr feedback] Test affine transform for identity and non ident…
Sep 29, 2024
e8c6e22
[EtienneAr feedback] Cleaner floating point comparison for NoAffineTr…
Sep 29, 2024
4e84c99
[EtienneAr feedback] keep original q and v in JointDataMimic
Sep 29, 2024
2a90985
[EtienneAr feedback] [Mimic] Set indexes of ref joint to 0
Sep 29, 2024
56a7668
[EtienneAr feedback] Fix mimic test for slightly new convention of re…
Sep 29, 2024
5c13e80
[EtienneAr feedback] Fix serialization for mimic joint with setIndexes
Sep 29, 2024
87564c4
[bindings] Added mimic to context
Sep 29, 2024
99f23b6
[parser] remove std::cout
Sep 29, 2024
8f41e56
[bindings] BROKEN - Added specialization for mimic joint in bindings
Sep 29, 2024
4d8daae
[python] Added jointModelMimicable to context
Sep 29, 2024
77b6b3b
[bindings] Fix mimic specialization for constructor
Sep 29, 2024
655eae6
[context] Added mimicable joint
Sep 29, 2024
d4de67a
[bindings] Finished specialization for mimic
Sep 29, 2024
5e0d210
{Joints@ Added mimicable trait
Sep 29, 2024
6a67a00
[Visitor] Change TransferVariant visitor into checkMimic visitor
Sep 29, 2024
4be07da
[Joint] Remove mimicable joint collection
Sep 29, 2024
6c93c66
[Joint] Use check mimic for jointMimic constructor
Sep 29, 2024
6a4fb6f
[bindings] Make bindings conform to new jointMimic
Sep 29, 2024
7e8ddbd
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
052e4ae
[EtienneAr feedback] Fix size in jointBlock
Sep 29, 2024
e0b575f
[EtienneAr feedback] Fix mimic serialization for joint_q joint_v
Sep 29, 2024
faebc3c
[EtienneAr feedback] Remove problematic testcase for mimic in python
Sep 29, 2024
abdcca6
[EtienneAr feedback] Add slightly more test on sample models for mimic
Sep 29, 2024
0bd8951
[EtienneAr feedback] Fix rebase conflict
Sep 29, 2024
3e28f01
[EtienneAr feedback] Activate mimic for joint-jacobian test
Sep 29, 2024
d4cb0a1
[EtienneAr feedback] Fix some size for mimic col/row selection
Sep 29, 2024
b762ec5
[EtienneAr feedback] Fix joint jacobians computation for mimic
Sep 29, 2024
c10e022
[EtienneAr feedback] WiP fix crba malloc
Sep 29, 2024
3748e92
[EtienneAr feedback] Remove temporary variables before return for joi…
Sep 29, 2024
99a04dd
[EtienneAr feedback] Add stack allocation feature for JointMotionSubs…
Sep 29, 2024
ff63111
[CRBA] Update computation of Ag
Sep 29, 2024
429f05a
[EtienneAr feedback] Small serialization fix after changes in JoitMot…
Sep 29, 2024
4639319
[EtienneAr feedback] Fix on Jcom for mimic
Sep 29, 2024
670d421
[EtienneAr feedback] Fix corriolis computation for mimic leading
Sep 29, 2024
c408531
[EtienneAr feedback] Enable mimic in rnea tests
Sep 29, 2024
b50d81d
[EtienneAr feedback] Define MaxDim in ScaledJointMotionSubspace and f…
Sep 29, 2024
516232a
[EtienneAr feedback] Add dedicated mimic test for crba
Sep 29, 2024
49f089f
[EtienneAr feedback] Template ScaledMotionSubspace on MaxDim
Sep 29, 2024
a9fe864
[EtienneAr feedback] Add getRelativePlacement method for kinematics
Sep 29, 2024
9f8546a
[EtienneAr feedback] add patch to crba for mimic joints
Sep 29, 2024
e61fe51
[EtienneAr feedback] Update comment and remove hardcoded max size for…
Sep 29, 2024
e453754
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
5aaa169
[algorithm/model] Added a function to transform a joint into a mimic
Sep 29, 2024
fb7755b
[unittest/model] Added test for transformIntoJointMimic
Sep 29, 2024
0ac61c3
Apply pre-commit
Sep 29, 2024
0fb3485
Fix rebase
Sep 29, 2024
a353113
[Algorithm/model] Remove useless if
Sep 29, 2024
64ad8a9
[EtienneAr feedback] Fix crba in local convention to prevent heap all…
Sep 29, 2024
c27e864
[EtienneAr feedback] Add assert for crba in world convention with mim…
Sep 29, 2024
840b8c3
[EtienneAr feedback] More exhaustive testing of crba for mimic
Sep 29, 2024
5e684be
[EtienneAr feedback] Remove useless override of joint{Config,Velocity…
Sep 29, 2024
b5c7744
[EtienneAr feedback] Fix selectConfigFromDof for JointModelTpl in the…
Sep 29, 2024
507778a
[EtienneAr feedback] Fix ConfigSelectorFromDof visitor
Sep 29, 2024
93f5f8a
[EtienneAr feedback] Fix CRBA test for mimic, and remove mimic in wor…
Sep 29, 2024
8bc29eb
[EtienneAr feedback] Fix G matric for mimic crba test
Sep 29, 2024
c3c3572
[EtienneAr feedback] Patch warnings in mimic crba test
Sep 29, 2024
8e27e5b
[Algorithm/crba] Fix world convention for mimic joints
Sep 29, 2024
2749269
fix not working for all cases (spaced and parallel)
Sep 29, 2024
34a7cfd
[algo/crba] Fix for crba world (works for spaced and parallel)
Sep 29, 2024
ed5c36c
Fix crba world (small issue with parallel joint at the root where the…
Sep 29, 2024
11817af
Fix for world convention
Sep 29, 2024
5eebd76
Make centroidal algorithm compatible with mimic and add tests
Sep 29, 2024
9db83a0
Add mimic tests to rnea
Sep 29, 2024
1ac2f57
Add security
Sep 29, 2024
e1b5c21
[EtienneAr feedback] Fix getRelativePlacement and add unit test
Sep 29, 2024
7f34bc7
Add security
Sep 29, 2024
4d8acb0
[EtienneAr feedback] Fix ForceOperator for generic motion subspace an…
Sep 29, 2024
6272346
[EtienneAr feedback] Patch previous fix on ForceOperator for motion s…
Sep 29, 2024
ed76cfa
Fix some errrors for com computation
Sep 29, 2024
760f1dd
[Rnea] Patch Algorithms for mimic
Sep 29, 2024
7d422f1
remove mimic joints from test
Sep 29, 2024
6cb1369
[unittest/rnea] Add more test
Sep 29, 2024
6c85d2c
Fix tests and remove modification for Coriolis Matrix
Sep 29, 2024
f45e196
[rnea] Remove useless setZero
Sep 29, 2024
febe325
[Urdf] Rebase on new pinocchio release
Sep 29, 2024
1428f6e
Add assert to non supported algorithms
Sep 29, 2024
402b876
[algo/crba] Fix local convention for crba
Sep 29, 2024
d339483
[EtienneAr feedback] Comment local fix for crba and don't use getRela…
Sep 29, 2024
dc4976a
[EtienneAr feedback] Add comments to world fix for crba and factorize…
Sep 29, 2024
aeb450a
Update examples
Sep 30, 2024
94ec4de
[EtienneAr Feedback] Fix LOCAL enum ambiguity in getRelativePlacement
Oct 1, 2024
de4b8ed
[EtienneAr Feedback]Fix Scalar / int confusion for model index
Oct 1, 2024
35ed9da
[EtienneAr Feedback] Fix explicit ConfigVectorAffineTransformVisitor …
Oct 1, 2024
5d33f91
[EtienneAr Feedback] Fix Scalar / int confusion for joint mimic index
Oct 1, 2024
f1b29b7
[bindings/urdf] Rebasing
Oct 3, 2024
274928f
Make code compile with CppAd
Oct 3, 2024
da8f9bd
[algo/crba] remove double function
Oct 4, 2024
57aa014
[unittest/kinematics] Cast to avoid errors
Oct 4, 2024
b0efc9a
[multibody/geometry] Force scalar to be double
Oct 4, 2024
1a05f90
[multibody/op] Only do comparison when scalar=double
Oct 4, 2024
5a6017a
Remove compilation warnings
Oct 4, 2024
4add64d
Fix crba and some tests for casadi
Oct 4, 2024
3e8e5da
[EtienneAr Feedback] Fix Scalar forced to double for GeometryObjects
Oct 6, 2024
61a45c8
[EtienneAr Feedback] Fix casadi test for joint mimic
Oct 7, 2024
b2bc76f
[serialization] Fix template errors
Oct 7, 2024
520df4a
Fix examples
Oct 7, 2024
c4454e3
Fix Serialization
Oct 7, 2024
f1719a1
Fix examples
Oct 7, 2024
0efda83
[test/rnea] Try fix for windows
Oct 8, 2024
e924b48
[EtienneAr Feedback] Swap import order
Oct 11, 2024
cfda604
[EtienneAr Feedback] Fix PINOCCHIO_EXPLICIT_INSTANTIATION DECLARATION…
Oct 11, 2024
226d198
[EtienneAr Feedback] Update changelog
Oct 11, 2024
dc10ee5
[EtienneAr Feedback] Add explicit to single argument constructors
Oct 11, 2024
db6907e
Applied pre-commit
Oct 11, 2024
4613a0f
Fix init problem
Oct 11, 2024
30cf379
[algo/jacobian] Fix rebasing
Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Allow use of `pathlib.Path | str` for paths in python bindings ([#2431](https://github.com/stack-of-tasks/pinocchio/pull/2431))
- Add Pseudo inertia and Log-cholesky parametrization ([#2296](https://github.com/stack-of-tasks/pinocchio/pull/2296))
- Add Pixi support ([#2459](https://github.com/stack-of-tasks/pinocchio/pull/2459))
- Extend support for mimic joint: rnea, crba, forward kinematics, centroidal, jacobians and frames ([#2441](https://github.com/stack-of-tasks/pinocchio/pull/2441))
- Add idx_j, nj members in joint models, with their respective column/row/block selectors. ([#2441](https://github.com/stack-of-tasks/pinocchio/pull/2441))

### Fixed
- Fix linkage of Boost.Serialization on Windows ([#2400](https://github.com/stack-of-tasks/pinocchio/pull/2400))
Expand Down
26 changes: 26 additions & 0 deletions bindings/python/multibody/sample-models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ namespace pinocchio
return model;
}

Model buildSampleModelHumanoidRandom(bool usingFF, bool mimic)
{
Model model;
buildModels::humanoidRandom(model, usingFF, mimic);
return model;
}

Model buildSampleModelManipulator()
{
Model model;
buildModels::manipulator(model);
return model;
}

Model buildSampleModelManipulator(bool mimic)
{
Model model;
buildModels::manipulator(model, mimic);
return model;
}

#ifdef PINOCCHIO_WITH_HPP_FCL
GeometryModel buildSampleGeometryModelManipulator(const Model & model)
{
Expand Down Expand Up @@ -80,11 +94,23 @@ namespace pinocchio
"Generate a (hard-coded) model of a humanoid robot with 6-DOF limbs and random joint "
"placements.\nOnly meant for unit tests.");

bp::def(
"buildSampleModelHumanoidRandom",
static_cast<Model (*)(bool, bool)>(pinocchio::python::buildSampleModelHumanoidRandom),
bp::args("using_free_flyer", "mimic"),
"Generate a (hard-coded) model of a humanoid robot with 6-DOF limbs and random joint "
"placements.\nOnly meant for unit tests.");

bp::def(
"buildSampleModelManipulator",
static_cast<Model (*)()>(pinocchio::python::buildSampleModelManipulator),
"Generate a (hard-coded) model of a simple manipulator.");

bp::def(
"buildSampleModelManipulator",
static_cast<Model (*)(bool)>(pinocchio::python::buildSampleModelManipulator),
bp::args("mimic"), "Generate a (hard-coded) model of a simple manipulator.");

#ifdef PINOCCHIO_WITH_HPP_FCL
bp::def(
"buildSampleGeometryModelManipulator",
Expand Down
138 changes: 88 additions & 50 deletions bindings/python/parsers/urdf/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,107 @@ namespace pinocchio

#ifdef PINOCCHIO_WITH_URDFDOM

Model buildModelFromUrdf(const bp::object & filename)
Model buildModelFromUrdf(const bp::object & filename, const bool mimic = false)
{
Model model;
pinocchio::urdf::buildModel(path(filename), model);
pinocchio::urdf::buildModel(path(filename), model, mimic);
return model;
}

Model & buildModelFromUrdf(const bp::object & filename, Model & model)
Model & buildModelFromUrdf(const bp::object & filename, Model & model, const bool mimic = false)
{
return pinocchio::urdf::buildModel(path(filename), model);
return pinocchio::urdf::buildModel(path(filename), model, mimic);
}

Model buildModelFromUrdf(const bp::object & filename, const JointModel & root_joint)
Model buildModelFromUrdf(
const bp::object & filename, const JointModel & root_joint, const bool mimic = false)
{
Model model;
pinocchio::urdf::buildModel(path(filename), root_joint, model);
pinocchio::urdf::buildModel(path(filename), root_joint, model, mimic);
return model;
}

Model buildModelFromUrdf(
const bp::object & filename,
const JointModel & root_joint,
const std::string & root_joint_name)
const std::string & root_joint_name,
const bool mimic = false)
{
Model model;
pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model);
pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model, mimic);
return model;
}

Model &
buildModelFromUrdf(const bp::object & filename, const JointModel & root_joint, Model & model)
Model & buildModelFromUrdf(
const bp::object & filename,
const JointModel & root_joint,
Model & model,
const bool mimic = false)
{
return pinocchio::urdf::buildModel(path(filename), root_joint, model);
return pinocchio::urdf::buildModel(path(filename), root_joint, model, mimic);
}

Model & buildModelFromUrdf(
const bp::object & filename,
const JointModel & root_joint,
const std::string & root_joint_name,
Model & model)
Model & model,
const bool mimic = false)
{
return pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model);
return pinocchio::urdf::buildModel(path(filename), root_joint, root_joint_name, model, mimic);
}

Model buildModelFromXML(const std::string & xml_stream, const JointModel & root_joint)
Model buildModelFromXML(
const std::string & xml_stream, const JointModel & root_joint, const bool mimic = false)
{
Model model;
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model);
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model, mimic);
return model;
}

Model buildModelFromXML(
const std::string & xml_stream,
const JointModel & root_joint,
const std::string & root_joint_name)
const std::string & root_joint_name,
const bool mimic = false)
{
Model model;
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model);
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model, mimic);
return model;
}

Model &
buildModelFromXML(const std::string & xml_stream, const JointModel & root_joint, Model & model)
Model & buildModelFromXML(
const std::string & xml_stream,
const JointModel & root_joint,
Model & model,
const bool mimic = false)
{
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model);
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, model, mimic);
return model;
}

Model & buildModelFromXML(
const std::string & xml_stream,
const JointModel & root_joint,
const std::string & root_joint_name,
Model & model)
Model & model,
const bool mimic = false)
{
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model);
pinocchio::urdf::buildModelFromXML(xml_stream, root_joint, root_joint_name, model, mimic);
return model;
}

Model buildModelFromXML(const std::string & xml_stream)
Model buildModelFromXML(const std::string & xml_stream, const bool mimic = true)
{
Model model;
pinocchio::urdf::buildModelFromXML(xml_stream, model);
pinocchio::urdf::buildModelFromXML(xml_stream, model, mimic);
return model;
}

Model & buildModelFromXML(const std::string & xml_stream, Model & model)
Model &
buildModelFromXML(const std::string & xml_stream, Model & model, const bool mimic = true)
{
pinocchio::urdf::buildModelFromXML(xml_stream, model);
pinocchio::urdf::buildModelFromXML(xml_stream, model, mimic);
return model;
}

Expand All @@ -120,39 +133,41 @@ namespace pinocchio

bp::def(
"buildModelFromUrdf",
static_cast<Model (*)(const bp::object &, const JointModel &)>(
static_cast<Model (*)(const bp::object &, const JointModel &, const bool)>(
pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "root_joint"),
bp::args("urdf_filename", "root_joint", "mimic"),
"Parse the URDF file given in input and return a pinocchio Model starting with the "
"given root joint.");

bp::def(
"buildModelFromUrdf",
static_cast<Model (*)(const bp::object &, const JointModel &, const std::string &)>(
static_cast<Model (*)(
const bp::object &, const JointModel &, const std::string &, const bool)>(
pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "root_joint", "root_joint_name"),
bp::args("urdf_filename", "root_joint", "root_joint_name", "mimic"),
"Parse the URDF file given in input and return a pinocchio Model starting with the "
"given root joint with its specified name.");

bp::def(
"buildModelFromUrdf",
static_cast<Model (*)(const bp::object &)>(pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename"),
static_cast<Model (*)(const bp::object &, const bool)>(
pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "mimic"),
"Parse the URDF file given in input and return a pinocchio Model.");

bp::def(
"buildModelFromUrdf",
static_cast<Model & (*)(const bp::object &, Model &)>(
static_cast<Model & (*)(const bp::object &, Model &, const bool)>(
pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "model"),
bp::args("urdf_filename", "model", "mimic"),
"Append to a given model a URDF structure given by its filename.",
bp::return_internal_reference<2>());

bp::def(
"buildModelFromUrdf",
static_cast<Model & (*)(const bp::object &, const JointModel &, Model &)>(
static_cast<Model & (*)(const bp::object &, const JointModel &, Model &, const bool)>(
pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "root_joint", "model"),
bp::args("urdf_filename", "root_joint", "model", "mimic"),
"Append to a given model a URDF structure given by its filename and the root joint.\n"
"Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons,"
"it is treated as operational frame and not as a joint of the model.",
Expand All @@ -161,8 +176,8 @@ namespace pinocchio
bp::def(
"buildModelFromUrdf",
static_cast<Model & (*)(const bp::object &, const JointModel &, const std::string &,
Model &)>(pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "root_joint", "root_joint_name", "model"),
Model &, const bool)>(pinocchio::python::buildModelFromUrdf),
bp::args("urdf_filename", "root_joint", "root_joint_name", "model", "mimic"),
"Append to a given model a URDF structure given by its filename and the root joint with "
"its specified name.\n"
"Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons,"
Expand All @@ -171,49 +186,72 @@ namespace pinocchio

bp::def(
"buildModelFromXML",
static_cast<Model (*)(const std::string &, const JointModel &)>(
static_cast<Model (*)(const std::string &, const JointModel &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint"),
bp::args("urdf_xml_stream", "root_joint", "mimic"),
"Parse the URDF XML stream given in input and return a pinocchio Model starting with "
"the given root joint.");

bp::def(
"buildModelFromXML",
static_cast<Model (*)(const std::string &, const JointModel &, const std::string &)>(
static_cast<Model (*)(
const std::string &, const JointModel &, const std::string &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "root_joint_name"),
bp::args(
"urdf_xml_stream", "root_joint",
"root_joint_name"
"mimic"),
"Parse the URDF XML stream given in input and return a pinocchio Model starting with "
"the given root joint with its specified name.");

bp::def(
"buildModelFromXML",
static_cast<Model & (*)(const std::string &, const JointModel &, Model &)>(
static_cast<Model (*)(
const std::string &, const JointModel &, const std::string &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "model"),
bp::args("urdf_xml_stream", "root_joint", "root_joint_name", "mimic"),
"Parse the URDF XML stream given in input and return a pinocchio Model starting with "
"the given root joint with its specified name.");

bp::def(
"buildModelFromXML",
static_cast<Model & (*)(const std::string &, const JointModel &, Model &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "model", "mimic"),
"Parse the URDF XML stream given in input and append it to the input model with the "
"given interfacing joint.",
bp::return_internal_reference<3>());

bp::def(
"buildModelFromXML",
static_cast<Model & (*)(const std::string &, const JointModel &, const std::string &,
Model &)>(pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "root_joint_name", "model"),
Model &, const bool)>(pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "root_joint_name", "model", "mimic"),
"Parse the URDF XML stream given in input and append it to the input model with the "
"given interfacing joint with its specified name.",
bp::return_internal_reference<3>());

bp::def(
"buildModelFromXML",
static_cast<Model & (*)(const std::string &, const JointModel &, const std::string &,
Model &, const bool)>(pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "root_joint", "root_joint_name", "model", "mimic"),
"Parse the URDF XML stream given in input and append it to the input model with the "
"given interfacing joint with its specified name.",
bp::return_internal_reference<3>());

bp::def(
"buildModelFromXML",
static_cast<Model (*)(const std::string &)>(pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream"),
static_cast<Model (*)(const std::string &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "mimic"),
"Parse the URDF XML stream given in input and return a pinocchio Model.");

bp::def(
"buildModelFromXML",
static_cast<Model & (*)(const std::string &, Model &)>(
static_cast<Model & (*)(const std::string &, Model &, const bool)>(
pinocchio::python::buildModelFromXML),
bp::args("urdf_xml_stream", "model"),
bp::args("urdf_xml_stream", "model", "mimic"),
"Parse the URDF XML stream given in input and append it to the input model.",
bp::return_internal_reference<2>());
#endif
Expand Down
18 changes: 14 additions & 4 deletions bindings/python/pinocchio/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def buildModelsFromUrdf(
- verbose - print information of parsing (default - False)
- meshLoader - object used to load meshes (default - hpp::fcl::MeshLoader)
- geometry_types - Which geometry model to load. Can be pin.GeometryType.COLLISION, pin.GeometryType.VISUAL or both. (default - [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL])
- mimic - If urdf mimic joints should be parsed or not (default - False)
Return:
Tuple of the models, in this order : model, collision model, and visual model.

Expand All @@ -34,7 +35,14 @@ def buildModelsFromUrdf(
Remark: In the URDF format, a joint of type fixed can be defined. For efficiency reasons, it is treated as operational frame and not as a joint of the model.
"""
# Handle the switch from old to new api
arg_keys = ["package_dirs", "root_joint", "verbose", "meshLoader", "geometry_types"]
arg_keys = [
"package_dirs",
"root_joint",
"verbose",
"meshLoader",
"geometry_types",
"mimic",
]
if len(args) >= 3:
if isinstance(args[2], str):
arg_keys = [
Expand All @@ -44,6 +52,7 @@ def buildModelsFromUrdf(
"verbose",
"meshLoader",
"geometry_types",
"mimic",
]

for key, arg in zip(arg_keys, args):
Expand All @@ -63,16 +72,17 @@ def _buildModelsFromUrdf(
verbose=False,
meshLoader=None,
geometry_types=None,
mimic=False,
) -> Tuple[pin.Model, pin.GeometryModel, pin.GeometryModel]:
if geometry_types is None:
geometry_types = [pin.GeometryType.COLLISION, pin.GeometryType.VISUAL]

if root_joint is None:
model = pin.buildModelFromUrdf(filename)
model = pin.buildModelFromUrdf(filename, mimic)
elif root_joint is not None and root_joint_name is None:
model = pin.buildModelFromUrdf(filename, root_joint)
model = pin.buildModelFromUrdf(filename, root_joint, mimic)
else:
model = pin.buildModelFromUrdf(filename, root_joint, root_joint_name)
model = pin.buildModelFromUrdf(filename, root_joint, root_joint_name, mimic)

if verbose and not WITH_HPP_FCL and meshLoader is not None:
print(
Expand Down
Loading
Loading