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
5434dea
Add Urdf support for mimic joint (revolute and prismatic)
Sep 29, 2024
1f3d678
Sample Model : Now support a mimic joint at the end if wanted
Sep 29, 2024
c75857e
[Joints] Added support for nj and idx_j
Sep 29, 2024
add81ce
[Joint] Mimic joint is now based on the variant and not templated
Sep 29, 2024
c4b6962
[Model] Support for nj and idx_j
Sep 29, 2024
3e04887
[Data] Jacobian is now indexed on nj
Sep 29, 2024
30a7c17
[LieGroup] Neutral Specialization for mimic joints
Sep 29, 2024
e35415e
[Serialization] Fix serialization
Sep 29, 2024
c30ec70
[Unittest] Fix unittest
Sep 29, 2024
a737c6e
[unittest] Fix for mimic
Sep 29, 2024
3794077
[Python] Add bindings
Sep 29, 2024
83598c9
[Urdf] Add possibility to use mimic or not
Sep 29, 2024
9f0191d
[Serialization] Fix Test and serialization
Sep 29, 2024
ed5650b
[Mimic] Joint Tpl instead of JointBase
Sep 29, 2024
a0bcd85
[Broken test] copy visitor from variant to variant
Sep 29, 2024
9501a72
Add mimic to shortcuts
Sep 29, 2024
affef7e
wip
Sep 29, 2024
ff96d5c
Copy constructor instead of =
Sep 29, 2024
a810252
[EtienneAr feedback] Add mimic constructor for different primay/secon…
Sep 29, 2024
f39c03a
[EtienneAr feedback] Move transferVariant to joint-basic-visitors and…
Sep 29, 2024
7e0c090
[EtienneAr feedback] PoC: fix appendModel
Sep 29, 2024
72d7c8e
[EtienneAr feedback] Fix sample model for mimic in manipulator
Sep 29, 2024
424fd52
[EtienneAr feedback] Joint Mimic jointConfigSelector_impl follows con…
Sep 29, 2024
366f21f
[EtienneAr feedback] Fix appendToModel when mimic joint in model
Sep 29, 2024
e9de47f
[EtienneAr feedback] Apply pre-commit
Sep 29, 2024
3c630f5
[EtienneAr feedback] Turn on mimic joint in model, reachable-workspac…
Sep 29, 2024
2176a5f
[EtienneAr feedback] Split jointCols jointRows and jointBLock for ful…
Sep 29, 2024
bce84b1
[URDF] Modified the way mimic joint are added (still broken for romeo…
Sep 29, 2024
3d293cf
[urdf] Fix parsing of mimic joints
Sep 29, 2024
0496323
[Example] Fix to include mimic
Sep 29, 2024
ef08565
[robot_wrapper] Fix to include mimic
Sep 29, 2024
f46fea1
Merge branch
Sep 29, 2024
33c7fa3
[RNEA] Modify to take mimic into account
Sep 29, 2024
f353cab
[Mimic] Modify to be able to mimic from base to Tpl
Sep 29, 2024
39a6918
[SampleModel] Test to compare a mimic and non mimic model
Sep 29, 2024
e8df4c4
[Data] Check on mimic is disable for now
Sep 29, 2024
f31ac29
Working test
Sep 29, 2024
cf82408
[EtienneAr feedback] Fix RNEA: initialize tau to zero before summing
Sep 29, 2024
9db26de
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
76a0969
[EtienneAr feedback] Test crba before rnea for mimic joints
Sep 29, 2024
218d155
[EtienneAr feedback] Port crba fix to algorithm with other convention
Sep 29, 2024
0c96e2a
[EtienneAr feedback] Port crba fix to rnea, compute-all-terms and con…
Sep 29, 2024
339d822
[EtienneAr feedback] Revert useless change on Fcrb in crna.hxx
Sep 29, 2024
24e857d
[EtienneAr feedback] Make M matrix symetric in test
Sep 29, 2024
3526191
[EtienneAr feedback] Properly use data.nle instead of rnea
Sep 29, 2024
3f9c3f2
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
16c7c96
[EtienneAr feedback] Fix RNEA after chage for mimic joints
Sep 29, 2024
9a46d13
[example] Change buildModelUrdf - added mimic bool
Sep 29, 2024
b087e76
[mimic-joint] Added support for FreeFlyer
Sep 29, 2024
c62da7a
[unittest] Added bool mimic to build urdf
Sep 29, 2024
ad639d4
[Joint] Split Joint ConfigSelector in two functions
Sep 29, 2024
6ab6049
Apply pre-commit
Sep 29, 2024
2fe8b5a
Split JointVelocitySelector in two functions
Sep 29, 2024
167c23f
Apply pre-commit
Sep 29, 2024
185ff55
[EtienneAr feedback] Add more test for joint mimic in non trivial cases
Sep 29, 2024
f670aa0
[EtienneAr feedback] Fix scaling and offset in mimic joint calc
Sep 29, 2024
eba619a
[EtienneAr feedback] WiP: Fix ConfigVectorAffineTransform template sp…
Sep 29, 2024
d75eedc
[EtienneAr feedback] Make visitor for config vector affine transform
Sep 29, 2024
a4023a9
[EtienneAr feedback] Move configVectorAffineTransform code to joint-b…
Sep 29, 2024
1dc3138
[EtienneAr feedback] Add more test cases for config vector affine tra…
Sep 29, 2024
c1aa0ca
[EtienneAr feedback] Test affine transform for identity and non ident…
Sep 29, 2024
b176c5e
[EtienneAr feedback] Cleaner floating point comparison for NoAffineTr…
Sep 29, 2024
0b3d70a
[EtienneAr feedback] keep original q and v in JointDataMimic
Sep 29, 2024
75ec986
[EtienneAr feedback] [Mimic] Set indexes of ref joint to 0
Sep 29, 2024
78da384
[EtienneAr feedback] Fix mimic test for slightly new convention of re…
Sep 29, 2024
3a51078
[EtienneAr feedback] Fix serialization for mimic joint with setIndexes
Sep 29, 2024
0c4c36b
[bindings] Added mimic to context
Sep 29, 2024
a3c9622
[parser] remove std::cout
Sep 29, 2024
f7b0fa3
[bindings] BROKEN - Added specialization for mimic joint in bindings
Sep 29, 2024
efea7f8
[python] Added jointModelMimicable to context
Sep 29, 2024
745b0a7
[bindings] Fix mimic specialization for constructor
Sep 29, 2024
e508e4c
[context] Added mimicable joint
Sep 29, 2024
be5ac35
[bindings] Finished specialization for mimic
Sep 29, 2024
f789dd6
{Joints@ Added mimicable trait
Sep 29, 2024
4d70402
[Visitor] Change TransferVariant visitor into checkMimic visitor
Sep 29, 2024
59c610f
[Joint] Remove mimicable joint collection
Sep 29, 2024
263f807
[Joint] Use check mimic for jointMimic constructor
Sep 29, 2024
adaa1ff
[bindings] Make bindings conform to new jointMimic
Sep 29, 2024
9b81b89
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
30948c3
[EtienneAr feedback] Fix size in jointBlock
Sep 29, 2024
d5cf0a3
[EtienneAr feedback] Fix mimic serialization for joint_q joint_v
Sep 29, 2024
c5854f1
[EtienneAr feedback] Remove problematic testcase for mimic in python
Sep 29, 2024
ce7c2d3
[EtienneAr feedback] Add slightly more test on sample models for mimic
Sep 29, 2024
68bc0c4
[EtienneAr feedback] Fix rebase conflict
Sep 29, 2024
0697623
[EtienneAr feedback] Activate mimic for joint-jacobian test
Sep 29, 2024
251ec2b
[EtienneAr feedback] Fix some size for mimic col/row selection
Sep 29, 2024
54c4af2
[EtienneAr feedback] Fix joint jacobians computation for mimic
Sep 29, 2024
c797831
[EtienneAr feedback] WiP fix crba malloc
Sep 29, 2024
4ee2ecf
[EtienneAr feedback] Remove temporary variables before return for joi…
Sep 29, 2024
28335c6
[EtienneAr feedback] Add stack allocation feature for JointMotionSubs…
Sep 29, 2024
d8efd15
[CRBA] Update computation of Ag
Sep 29, 2024
4085795
[EtienneAr feedback] Small serialization fix after changes in JoitMot…
Sep 29, 2024
b0e3955
[EtienneAr feedback] Fix on Jcom for mimic
Sep 29, 2024
653a9cb
[EtienneAr feedback] Fix corriolis computation for mimic leading
Sep 29, 2024
e386113
[EtienneAr feedback] Enable mimic in rnea tests
Sep 29, 2024
d1aa428
[EtienneAr feedback] Define MaxDim in ScaledJointMotionSubspace and f…
Sep 29, 2024
5ddbb7c
[EtienneAr feedback] Add dedicated mimic test for crba
Sep 29, 2024
1a42e72
[EtienneAr feedback] Template ScaledMotionSubspace on MaxDim
Sep 29, 2024
0f1a75b
[EtienneAr feedback] Add getRelativePlacement method for kinematics
Sep 29, 2024
4f94494
[EtienneAr feedback] add patch to crba for mimic joints
Sep 29, 2024
8e34295
[EtienneAr feedback] Update comment and remove hardcoded max size for…
Sep 29, 2024
eadd005
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
d180773
[algorithm/model] Added a function to transform a joint into a mimic
Sep 29, 2024
43f9959
[unittest/model] Added test for transformIntoJointMimic
Sep 29, 2024
0263aca
Apply pre-commit
Sep 29, 2024
8f9e6b3
Fix rebase
Sep 29, 2024
d9af1ba
[Algorithm/model] Remove useless if
Sep 29, 2024
df1c2f9
[EtienneAr feedback] Fix crba in local convention to prevent heap all…
Sep 29, 2024
1093017
[EtienneAr feedback] Add assert for crba in world convention with mim…
Sep 29, 2024
47e5482
[EtienneAr feedback] More exhaustive testing of crba for mimic
Sep 29, 2024
97cb065
[EtienneAr feedback] Remove useless override of joint{Config,Velocity…
Sep 29, 2024
86dcb6b
[EtienneAr feedback] Fix selectConfigFromDof for JointModelTpl in the…
Sep 29, 2024
fef5932
[EtienneAr feedback] Fix ConfigSelectorFromDof visitor
Sep 29, 2024
813798f
[EtienneAr feedback] Fix CRBA test for mimic, and remove mimic in wor…
Sep 29, 2024
a4ac37c
[EtienneAr feedback] Fix G matric for mimic crba test
Sep 29, 2024
33282e5
[EtienneAr feedback] Patch warnings in mimic crba test
Sep 29, 2024
dd83d3f
[Algorithm/crba] Fix world convention for mimic joints
Sep 29, 2024
2ce8335
fix not working for all cases (spaced and parallel)
Sep 29, 2024
7c42901
[algo/crba] Fix for crba world (works for spaced and parallel)
Sep 29, 2024
6491e4a
Fix crba world (small issue with parallel joint at the root where the…
Sep 29, 2024
df5949b
Fix for world convention
Sep 29, 2024
121a201
Make centroidal algorithm compatible with mimic and add tests
Sep 29, 2024
80e9f40
Add mimic tests to rnea
Sep 29, 2024
c95789b
Add security
Sep 29, 2024
35c26d7
[EtienneAr feedback] Fix getRelativePlacement and add unit test
Sep 29, 2024
cffacd8
Add security
Sep 29, 2024
aec853a
[EtienneAr feedback] Fix ForceOperator for generic motion subspace an…
Sep 29, 2024
303a1bc
[EtienneAr feedback] Patch previous fix on ForceOperator for motion s…
Sep 29, 2024
3681413
Fix some errrors for com computation
Sep 29, 2024
e524e42
[Rnea] Patch Algorithms for mimic
Sep 29, 2024
9d82361
remove mimic joints from test
Sep 29, 2024
9f2a1e3
[unittest/rnea] Add more test
Sep 29, 2024
ec4db7c
Fix tests and remove modification for Coriolis Matrix
Sep 29, 2024
f099ac7
[rnea] Remove useless setZero
Sep 29, 2024
4f8db67
[Urdf] Rebase on new pinocchio release
Sep 29, 2024
e7d28cd
Add assert to non supported algorithms
Sep 29, 2024
3481963
[algo/crba] Fix local convention for crba
Sep 29, 2024
39a7590
[EtienneAr feedback] Comment local fix for crba and don't use getRela…
Sep 29, 2024
18309be
[EtienneAr feedback] Add comments to world fix for crba and factorize…
Sep 29, 2024
14060fd
Update examples
Sep 30, 2024
741d1a1
[EtienneAr Feedback] Fix LOCAL enum ambiguity in getRelativePlacement
Oct 1, 2024
b05103e
[EtienneAr Feedback]Fix Scalar / int confusion for model index
Oct 1, 2024
fd54278
[EtienneAr Feedback] Fix explicit ConfigVectorAffineTransformVisitor …
Oct 1, 2024
4706838
[EtienneAr Feedback] Fix Scalar / int confusion for joint mimic index
Oct 1, 2024
6d3fb86
[bindings/urdf] Rebasing
Oct 3, 2024
dfe746f
Make code compile with CppAd
Oct 3, 2024
d18fea3
[algo/crba] remove double function
Oct 4, 2024
13fdd10
[unittest/kinematics] Cast to avoid errors
Oct 4, 2024
ea9fdea
[multibody/geometry] Force scalar to be double
Oct 4, 2024
c9fc664
[multibody/op] Only do comparison when scalar=double
Oct 4, 2024
ef22674
Remove compilation warnings
Oct 4, 2024
cc6dc3e
Fix crba and some tests for casadi
Oct 4, 2024
ac94d1c
[EtienneAr Feedback] Fix Scalar forced to double for GeometryObjects
Oct 6, 2024
237b26e
[EtienneAr Feedback] Fix casadi test for joint mimic
Oct 7, 2024
4cf3bf7
[serialization] Fix template errors
Oct 7, 2024
a0dc57b
Fix examples
Oct 7, 2024
a87b80d
Fix Serialization
Oct 7, 2024
86822ee
Fix examples
Oct 7, 2024
26ee516
[test/rnea] Try fix for windows
Oct 8, 2024
ccb5ade
[EtienneAr Feedback] Swap import order
Oct 11, 2024
1219043
[EtienneAr Feedback] Fix PINOCCHIO_EXPLICIT_INSTANTIATION DECLARATION…
Oct 11, 2024
0406098
[EtienneAr Feedback] Update changelog
Oct 11, 2024
765059d
[EtienneAr Feedback] Add explicit to single argument constructors
Oct 11, 2024
7b9a81b
Applied pre-commit
Oct 11, 2024
df43e4a
Fix init problem
Oct 11, 2024
bd466b3
[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 @@ -31,6 +31,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