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 165 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
4d9d884
Add Urdf support for mimic joint (revolute and prismatic)
Sep 29, 2024
2ef33e3
Sample Model : Now support a mimic joint at the end if wanted
Sep 29, 2024
445651b
[Joints] Added support for nj and idx_j
Sep 29, 2024
49794a9
[Joint] Mimic joint is now based on the variant and not templated
Sep 29, 2024
935177f
[Model] Support for nj and idx_j
Sep 29, 2024
3ee3922
[Data] Jacobian is now indexed on nj
Sep 29, 2024
55aec12
[LieGroup] Neutral Specialization for mimic joints
Sep 29, 2024
9f55133
[Serialization] Fix serialization
Sep 29, 2024
1974653
[Unittest] Fix unittest
Sep 29, 2024
007aac9
[unittest] Fix for mimic
Sep 29, 2024
1911aba
[Python] Add bindings
Sep 29, 2024
b7c405b
[Urdf] Add possibility to use mimic or not
Sep 29, 2024
eb8d975
[Serialization] Fix Test and serialization
Sep 29, 2024
5f42e76
[Mimic] Joint Tpl instead of JointBase
Sep 29, 2024
c8cde41
[Broken test] copy visitor from variant to variant
Sep 29, 2024
212a567
Add mimic to shortcuts
Sep 29, 2024
588d8e6
wip
Sep 29, 2024
a0ccbb6
Copy constructor instead of =
Sep 29, 2024
45820de
[EtienneAr feedback] Add mimic constructor for different primay/secon…
Sep 29, 2024
685e81b
[EtienneAr feedback] Move transferVariant to joint-basic-visitors and…
Sep 29, 2024
919050c
[EtienneAr feedback] PoC: fix appendModel
Sep 29, 2024
3d221f9
[EtienneAr feedback] Fix sample model for mimic in manipulator
Sep 29, 2024
c966d01
[EtienneAr feedback] Joint Mimic jointConfigSelector_impl follows con…
Sep 29, 2024
4b22cf2
[EtienneAr feedback] Fix appendToModel when mimic joint in model
Sep 29, 2024
e8e829f
[EtienneAr feedback] Apply pre-commit
Sep 29, 2024
ca5f77e
[EtienneAr feedback] Turn on mimic joint in model, reachable-workspac…
Sep 29, 2024
a55d3bf
[EtienneAr feedback] Split jointCols jointRows and jointBLock for ful…
Sep 29, 2024
5e21b59
[URDF] Modified the way mimic joint are added (still broken for romeo…
Sep 29, 2024
666abff
[urdf] Fix parsing of mimic joints
Sep 29, 2024
ba29849
[Example] Fix to include mimic
Sep 29, 2024
a86cb6b
[robot_wrapper] Fix to include mimic
Sep 29, 2024
5665e20
Merge branch
Sep 29, 2024
206d9b3
[RNEA] Modify to take mimic into account
Sep 29, 2024
b1a68b4
[Mimic] Modify to be able to mimic from base to Tpl
Sep 29, 2024
ac81325
[SampleModel] Test to compare a mimic and non mimic model
Sep 29, 2024
75584d0
[Data] Check on mimic is disable for now
Sep 29, 2024
ff706a7
Working test
Sep 29, 2024
368f3d2
[EtienneAr feedback] Fix RNEA: initialize tau to zero before summing
Sep 29, 2024
574e93e
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
28a641e
[EtienneAr feedback] Test crba before rnea for mimic joints
Sep 29, 2024
fcb68db
[EtienneAr feedback] Port crba fix to algorithm with other convention
Sep 29, 2024
ef45b95
[EtienneAr feedback] Port crba fix to rnea, compute-all-terms and con…
Sep 29, 2024
a13a685
[EtienneAr feedback] Revert useless change on Fcrb in crna.hxx
Sep 29, 2024
83bfe4f
[EtienneAr feedback] Make M matrix symetric in test
Sep 29, 2024
0e45c7a
[EtienneAr feedback] Properly use data.nle instead of rnea
Sep 29, 2024
631e13c
[EtienneAr feedback] Fix crba for mimic joints
Sep 29, 2024
2d0021d
[EtienneAr feedback] Fix RNEA after chage for mimic joints
Sep 29, 2024
6eaf2e0
[example] Change buildModelUrdf - added mimic bool
Sep 29, 2024
2ba6d37
[mimic-joint] Added support for FreeFlyer
Sep 29, 2024
38036c0
[unittest] Added bool mimic to build urdf
Sep 29, 2024
bc725ed
[Joint] Split Joint ConfigSelector in two functions
Sep 29, 2024
0c36825
Apply pre-commit
Sep 29, 2024
b493e9c
Split JointVelocitySelector in two functions
Sep 29, 2024
5ed5dd1
Apply pre-commit
Sep 29, 2024
ed295df
[EtienneAr feedback] Add more test for joint mimic in non trivial cases
Sep 29, 2024
796a4dd
[EtienneAr feedback] Fix scaling and offset in mimic joint calc
Sep 29, 2024
567cc44
[EtienneAr feedback] WiP: Fix ConfigVectorAffineTransform template sp…
Sep 29, 2024
de2669f
[EtienneAr feedback] Make visitor for config vector affine transform
Sep 29, 2024
32330e0
[EtienneAr feedback] Move configVectorAffineTransform code to joint-b…
Sep 29, 2024
6547456
[EtienneAr feedback] Add more test cases for config vector affine tra…
Sep 29, 2024
0aaad9d
[EtienneAr feedback] Test affine transform for identity and non ident…
Sep 29, 2024
2f9569d
[EtienneAr feedback] Cleaner floating point comparison for NoAffineTr…
Sep 29, 2024
847bbfd
[EtienneAr feedback] keep original q and v in JointDataMimic
Sep 29, 2024
dfbb342
[EtienneAr feedback] [Mimic] Set indexes of ref joint to 0
Sep 29, 2024
91ef1b5
[EtienneAr feedback] Fix mimic test for slightly new convention of re…
Sep 29, 2024
e77ebb0
[EtienneAr feedback] Fix serialization for mimic joint with setIndexes
Sep 29, 2024
f368187
[bindings] Added mimic to context
Sep 29, 2024
c5e50b7
[parser] remove std::cout
Sep 29, 2024
571be06
[bindings] BROKEN - Added specialization for mimic joint in bindings
Sep 29, 2024
a004218
[python] Added jointModelMimicable to context
Sep 29, 2024
4f94b07
[bindings] Fix mimic specialization for constructor
Sep 29, 2024
a24746f
[context] Added mimicable joint
Sep 29, 2024
b715881
[bindings] Finished specialization for mimic
Sep 29, 2024
1f65f7b
{Joints@ Added mimicable trait
Sep 29, 2024
016102e
[Visitor] Change TransferVariant visitor into checkMimic visitor
Sep 29, 2024
c4e8876
[Joint] Remove mimicable joint collection
Sep 29, 2024
56d91a2
[Joint] Use check mimic for jointMimic constructor
Sep 29, 2024
299fbbb
[bindings] Make bindings conform to new jointMimic
Sep 29, 2024
0af5c97
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
581341d
[EtienneAr feedback] Fix size in jointBlock
Sep 29, 2024
a407b48
[EtienneAr feedback] Fix mimic serialization for joint_q joint_v
Sep 29, 2024
6677d87
[EtienneAr feedback] Remove problematic testcase for mimic in python
Sep 29, 2024
932e313
[EtienneAr feedback] Add slightly more test on sample models for mimic
Sep 29, 2024
20f8bab
[EtienneAr feedback] Fix rebase conflict
Sep 29, 2024
762ce8c
[EtienneAr feedback] Activate mimic for joint-jacobian test
Sep 29, 2024
361eac2
[EtienneAr feedback] Fix some size for mimic col/row selection
Sep 29, 2024
6b22ea5
[EtienneAr feedback] Fix joint jacobians computation for mimic
Sep 29, 2024
ab2d2f4
[EtienneAr feedback] WiP fix crba malloc
Sep 29, 2024
15aa632
[EtienneAr feedback] Remove temporary variables before return for joi…
Sep 29, 2024
d0d9867
[EtienneAr feedback] Add stack allocation feature for JointMotionSubs…
Sep 29, 2024
c798814
[CRBA] Update computation of Ag
Sep 29, 2024
175cb8c
[EtienneAr feedback] Small serialization fix after changes in JoitMot…
Sep 29, 2024
c1976df
[EtienneAr feedback] Fix on Jcom for mimic
Sep 29, 2024
1a4e8ad
[EtienneAr feedback] Fix corriolis computation for mimic leading
Sep 29, 2024
39f2a49
[EtienneAr feedback] Enable mimic in rnea tests
Sep 29, 2024
3387d3a
[EtienneAr feedback] Define MaxDim in ScaledJointMotionSubspace and f…
Sep 29, 2024
0148b0f
[EtienneAr feedback] Add dedicated mimic test for crba
Sep 29, 2024
9b95ed1
[EtienneAr feedback] Template ScaledMotionSubspace on MaxDim
Sep 29, 2024
5a45359
[EtienneAr feedback] Add getRelativePlacement method for kinematics
Sep 29, 2024
ef899c9
[EtienneAr feedback] add patch to crba for mimic joints
Sep 29, 2024
34706b8
[EtienneAr feedback] Update comment and remove hardcoded max size for…
Sep 29, 2024
7ec158e
[EtienneAr feedback] Make random humanoid with mimic joint
Sep 29, 2024
4bb8cf6
[algorithm/model] Added a function to transform a joint into a mimic
Sep 29, 2024
e824cf4
[unittest/model] Added test for transformIntoJointMimic
Sep 29, 2024
5883d1f
Apply pre-commit
Sep 29, 2024
8cfd860
Fix rebase
Sep 29, 2024
0e68e76
[Algorithm/model] Remove useless if
Sep 29, 2024
73c9035
[EtienneAr feedback] Fix crba in local convention to prevent heap all…
Sep 29, 2024
9e3f49e
[EtienneAr feedback] Add assert for crba in world convention with mim…
Sep 29, 2024
627529c
[EtienneAr feedback] More exhaustive testing of crba for mimic
Sep 29, 2024
2968146
[EtienneAr feedback] Remove useless override of joint{Config,Velocity…
Sep 29, 2024
3a719dc
[EtienneAr feedback] Fix selectConfigFromDof for JointModelTpl in the…
Sep 29, 2024
030cc46
[EtienneAr feedback] Fix ConfigSelectorFromDof visitor
Sep 29, 2024
694475d
[EtienneAr feedback] Fix CRBA test for mimic, and remove mimic in wor…
Sep 29, 2024
2186256
[EtienneAr feedback] Fix G matric for mimic crba test
Sep 29, 2024
45aa219
[EtienneAr feedback] Patch warnings in mimic crba test
Sep 29, 2024
14b17b0
[Algorithm/crba] Fix world convention for mimic joints
Sep 29, 2024
cd6d3cf
fix not working for all cases (spaced and parallel)
Sep 29, 2024
a0b3011
[algo/crba] Fix for crba world (works for spaced and parallel)
Sep 29, 2024
93bb9e4
Fix crba world (small issue with parallel joint at the root where the…
Sep 29, 2024
602f61b
Fix for world convention
Sep 29, 2024
4698d0d
Make centroidal algorithm compatible with mimic and add tests
Sep 29, 2024
ceed8ad
Add mimic tests to rnea
Sep 29, 2024
bc7fcb1
Add security
Sep 29, 2024
d6791ca
[EtienneAr feedback] Fix getRelativePlacement and add unit test
Sep 29, 2024
af24229
Add security
Sep 29, 2024
b39b9c8
[EtienneAr feedback] Fix ForceOperator for generic motion subspace an…
Sep 29, 2024
f9dfabe
[EtienneAr feedback] Patch previous fix on ForceOperator for motion s…
Sep 29, 2024
e81f6a1
Fix some errrors for com computation
Sep 29, 2024
5890b0c
[Rnea] Patch Algorithms for mimic
Sep 29, 2024
995a6a4
remove mimic joints from test
Sep 29, 2024
aeeccb3
[unittest/rnea] Add more test
Sep 29, 2024
3492ad4
Fix tests and remove modification for Coriolis Matrix
Sep 29, 2024
cc74e43
[rnea] Remove useless setZero
Sep 29, 2024
e8b49f5
[Urdf] Rebase on new pinocchio release
Sep 29, 2024
c43f9bb
Add assert to non supported algorithms
Sep 29, 2024
df12ced
[algo/crba] Fix local convention for crba
Sep 29, 2024
3e44aa6
[EtienneAr feedback] Comment local fix for crba and don't use getRela…
Sep 29, 2024
31b9866
[EtienneAr feedback] Add comments to world fix for crba and factorize…
Sep 29, 2024
711a7b1
Update examples
Sep 30, 2024
587dd72
[EtienneAr Feedback] Fix LOCAL enum ambiguity in getRelativePlacement
Oct 1, 2024
59923fe
[EtienneAr Feedback]Fix Scalar / int confusion for model index
Oct 1, 2024
68fb12a
[EtienneAr Feedback] Fix explicit ConfigVectorAffineTransformVisitor …
Oct 1, 2024
9cd734f
[EtienneAr Feedback] Fix Scalar / int confusion for joint mimic index
Oct 1, 2024
d0dd2f3
[bindings/urdf] Rebasing
Oct 3, 2024
4cc9213
Make code compile with CppAd
Oct 3, 2024
b40ef0b
[algo/crba] remove double function
Oct 4, 2024
fe468d6
[unittest/kinematics] Cast to avoid errors
Oct 4, 2024
ac54906
[multibody/geometry] Force scalar to be double
Oct 4, 2024
fdbc21c
[multibody/op] Only do comparison when scalar=double
Oct 4, 2024
fcba9a3
Remove compilation warnings
Oct 4, 2024
983166f
Fix crba and some tests for casadi
Oct 4, 2024
a528fc3
[EtienneAr Feedback] Fix Scalar forced to double for GeometryObjects
Oct 6, 2024
89fda7d
[EtienneAr Feedback] Fix casadi test for joint mimic
Oct 7, 2024
b5e6ced
[serialization] Fix template errors
Oct 7, 2024
8009bbb
Fix examples
Oct 7, 2024
5085f9a
Fix Serialization
Oct 7, 2024
8b20cbb
Fix examples
Oct 7, 2024
d6d88bb
[test/rnea] Try fix for windows
Oct 8, 2024
a8fc9e6
[EtienneAr Feedback] Swap import order
Oct 11, 2024
5de5b35
[EtienneAr Feedback] Fix PINOCCHIO_EXPLICIT_INSTANTIATION DECLARATION…
Oct 11, 2024
3cefa42
[EtienneAr Feedback] Update changelog
Oct 11, 2024
cc2aee7
[EtienneAr Feedback] Add explicit to single argument constructors
Oct 11, 2024
3b4cc47
Applied pre-commit
Oct 11, 2024
53d7cd2
Fix init problem
Oct 11, 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 @@ -16,6 +16,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