Skip to content

Commit e596e9b

Browse files
authored
Merge branch 'devel' into patch-1
2 parents 7a8e032 + 468acc3 commit e596e9b

File tree

16 files changed

+145
-62
lines changed

16 files changed

+145
-62
lines changed

.github/workflows/macos-linux-windows-pixi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
key: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_${{ github.sha }}
9494
restore-keys: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_
9595

96-
- uses: prefix-dev/[email protected].1
96+
- uses: prefix-dev/[email protected].2
9797
with:
9898
cache: true
9999
environments: ${{ matrix.environment }}

.github/workflows/update_pixi_lockfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
persist-credentials: false
2828

2929
- name: Set up pixi
30-
uses: prefix-dev/[email protected].1
30+
uses: prefix-dev/[email protected].2
3131
with:
3232
run-install: false
3333

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010

1111
## [Unreleased]
1212

13+
### Changed
1314
- Homogenize python viewers examples ([#2771](https://github.com/stack-of-tasks/pinocchio/pull/2771))
15+
- Rename hpp-fcl dependency to coal ([#2789](https://github.com/stack-of-tasks/pinocchio/pull/2794))
16+
- Removed CMake < 3.22 details ([#2790](https://github.com/stack-of-tasks/pinocchio/pull/2790))
17+
18+
### Added
19+
- Add names to joints that are inside a composite joint ([#2786](https://github.com/stack-of-tasks/pinocchio/pull/2786))
1420
- Add docker images ([#2776](https://github.com/stack-of-tasks/pinocchio/pull/2776))
21+
- Python : add overload of `BaseVisualizer::play()` to `VisualizerPythonVisitor` ([#2796](https://github.com/stack-of-tasks/pinocchio/pull/2796))
1522
- ROS: added jrl_cmakemodules dependency ([#2789](https://github.com/stack-of-tasks/pinocchio/pull/2789))
16-
- Rename hpp-fcl dependency to coal ([#2789](https://github.com/stack-of-tasks/pinocchio/pull/2794))
1723

1824
## [3.8.0] - 2025-09-17
1925

CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,10 @@ include("${JRL_CMAKE_MODULES}/python.cmake")
8686
include("${JRL_CMAKE_MODULES}/boost.cmake")
8787
include("${JRL_CMAKE_MODULES}/ide.cmake")
8888
include("${JRL_CMAKE_MODULES}/apple.cmake")
89-
if(APPLE) # Use the handmade approach
90-
if(${CMAKE_VERSION} VERSION_LESS "3.18.0") # Need to find the right version
91-
set(CMAKE_MODULE_PATH ${JRL_CMAKE_MODULES}/find-external/OpenMP ${CMAKE_MODULE_PATH})
92-
endif()
93-
elseif(UNIX)
94-
if(${CMAKE_VERSION} VERSION_EQUAL "3.20.0")
95-
set(CMAKE_MODULE_PATH ${JRL_CMAKE_MODULES}/find-external/OpenMP ${CMAKE_MODULE_PATH})
96-
endif()
97-
endif()
9889
include(CMakeDependentOption)
9990

10091
# If needed, set CMake policy for APPLE systems
10192
apply_default_apple_configuration()
102-
if(CMAKE_VERSION VERSION_GREATER "3.12")
103-
cmake_policy(SET CMP0074 NEW)
104-
endif()
10593

10694
# Force C++ standard to be C++11 at least
10795
check_minimal_cxx_standard(11 ENFORCE)

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
default = self'.packages.pinocchio;
3333
pinocchio = pkgs.python3Packages.pinocchio.overrideAttrs (super: {
3434
propagatedBuildInputs = super.propagatedBuildInputs ++ [ pkgs.example-robot-data ];
35+
nativeCheckInputs = [ pkgs.python3Packages.pybind11 ];
3536
src = pkgs.lib.fileset.toSource {
3637
root = ./.;
3738
fileset = pkgs.lib.fileset.unions [
@@ -78,6 +79,7 @@
7879
pkgs.example-robot-data
7980
self'.packages.libpinocchio
8081
];
82+
nativeCheckInputs = [ pkgs.python3Packages.pybind11 ];
8183
src = pkgs.lib.fileset.toSource {
8284
root = ./.;
8385
fileset = pkgs.lib.fileset.unions [

include/pinocchio/bindings/python/multibody/joint/joints-models.hpp

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,57 +276,76 @@ namespace pinocchio
276276
{
277277
context::JointModelComposite & m_joint_composite;
278278
const context::SE3 & m_joint_placement;
279+
const std::string & m_name;
279280

280281
JointModelCompositeAddJointVisitor(
281-
context::JointModelComposite & joint_composite, const context::SE3 & joint_placement)
282+
context::JointModelComposite & joint_composite,
283+
const context::SE3 & joint_placement,
284+
const std::string & name)
282285
: m_joint_composite(joint_composite)
283286
, m_joint_placement(joint_placement)
287+
, m_name(name)
284288
{
285289
}
286290

287291
template<typename JointModelDerived>
288292
context::JointModelComposite & operator()(JointModelDerived & jmodel) const
289293
{
290-
return m_joint_composite.addJoint(jmodel, m_joint_placement);
294+
return m_joint_composite.addJoint(jmodel, m_joint_placement, m_name);
291295
}
292296
}; // struct JointModelCompositeAddJointVisitor
293297

294298
static context::JointModelComposite & addJoint_proxy(
295299
context::JointModelComposite & joint_composite,
296300
const context::JointModel & jmodel,
297-
const context::SE3 & joint_placement = context::SE3::Identity())
301+
const context::SE3 & joint_placement = context::SE3::Identity(),
302+
const std::string & name = "")
298303
{
299304
return boost::apply_visitor(
300-
JointModelCompositeAddJointVisitor(joint_composite, joint_placement), jmodel.toVariant());
305+
JointModelCompositeAddJointVisitor(joint_composite, joint_placement, name),
306+
jmodel.toVariant());
301307
}
302308

303309
struct JointModelCompositeConstructorVisitor
304310
: public boost::static_visitor<context::JointModelComposite *>
305311
{
306312
const context::SE3 & m_joint_placement;
313+
const std::string & m_name;
307314

308-
JointModelCompositeConstructorVisitor(const context::SE3 & joint_placement)
315+
JointModelCompositeConstructorVisitor(
316+
const context::SE3 & joint_placement, const std::string & name)
309317
: m_joint_placement(joint_placement)
318+
, m_name(name)
310319
{
311320
}
312321

313322
template<typename JointModelDerived>
314323
context::JointModelComposite * operator()(JointModelDerived & jmodel) const
315324
{
316-
return new context::JointModelComposite(jmodel, m_joint_placement);
325+
return new context::JointModelComposite(jmodel, m_joint_placement, m_name);
317326
}
318327
}; // struct JointModelCompositeConstructorVisitor
319328

320329
static context::JointModelComposite * init_proxy1(const context::JointModel & jmodel)
321330
{
322331
return boost::apply_visitor(
323-
JointModelCompositeConstructorVisitor(context::SE3::Identity()), jmodel);
332+
JointModelCompositeConstructorVisitor(context::SE3::Identity(), "joint_1"), jmodel);
324333
}
325334

326335
static context::JointModelComposite *
327336
init_proxy2(const context::JointModel & jmodel, const context::SE3 & joint_placement)
328337
{
329-
return boost::apply_visitor(JointModelCompositeConstructorVisitor(joint_placement), jmodel);
338+
return boost::apply_visitor(
339+
JointModelCompositeConstructorVisitor(joint_placement, "joint_1"), jmodel);
340+
}
341+
342+
static context::JointModelComposite * init_proxy3(
343+
const context::JointModel & jmodel,
344+
const context::SE3 & joint_placement,
345+
const std::string & name)
346+
{
347+
return boost::apply_visitor(
348+
JointModelCompositeConstructorVisitor(joint_placement, name), jmodel);
330349
}
331350

332351
template<>
@@ -345,14 +364,23 @@ namespace pinocchio
345364
bp::make_constructor(
346365
init_proxy2, bp::default_call_policies(), bp::args("joint_model", "joint_placement")),
347366
"Init JointModelComposite from a joint and a placement")
367+
.def(
368+
"__init__",
369+
bp::make_constructor(
370+
init_proxy3, bp::default_call_policies(),
371+
bp::args("joint_model", "joint_placement", "name")),
372+
"Init JointModelComposite from a joint, a placement and a name")
348373
.add_property("joints", &context::JointModelComposite::joints)
349374
.add_property("jointPlacements", &context::JointModelComposite::jointPlacements)
350375
.add_property("njoints", &context::JointModelComposite::njoints)
351376
.def(
352377
"addJoint", &addJoint_proxy,
353378
(bp::arg("self"), bp::arg("joint_model"),
354-
bp::arg("joint_placement") = context::SE3::Identity()),
379+
bp::arg("joint_placement") = context::SE3::Identity(), bp::arg("name") = "joint_1"),
355380
"Add a joint to the vector of joints.", bp::return_internal_reference<>())
381+
.def(
382+
"getJointId", &context::JointModelComposite::getJointId, bp::args("joint_name"),
383+
"Find the index of a joint inside a joint composite based on its name.")
356384

357385
#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
358386
.def(bp::self == bp::self)

include/pinocchio/bindings/python/visualizers/visualizer-visitor.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "pinocchio/bindings/python/fwd.hpp"
99

1010
#include <eigenpy/optional.hpp>
11+
#include <eigenpy/std-vector.hpp>
1112

1213
namespace pinocchio
1314
{
@@ -19,7 +20,6 @@ namespace pinocchio
1920
struct VisualizerPythonVisitor : bp::def_visitor<VisualizerPythonVisitor<Visualizer>>
2021
{
2122
typedef ::pinocchio::visualizers::BaseVisualizer Base;
22-
typedef ::pinocchio::visualizers::ConstMatrixRef ConstMatrixRef;
2323
static_assert(
2424
std::is_base_of<Base, Visualizer>::value,
2525
"Visualizer class must be derived from pinocchio::visualizers::BaseVisualizer.");
@@ -34,7 +34,20 @@ namespace pinocchio
3434
vis.setCameraPose(pose);
3535
}
3636

37-
static void play_proxy2(Visualizer & vis, const ConstMatrixRef & qs, context::Scalar dt)
37+
static void play_proxy(
38+
Visualizer & vis, const std::vector<visualizers::VectorXs> & qs, context::Scalar dt)
39+
{
40+
std::vector<visualizers::ConstVectorRef> qs_;
41+
qs_.reserve(qs.size());
42+
for (size_t i = 0; i < qs.size(); i++)
43+
{
44+
qs_.emplace_back(qs[i]);
45+
}
46+
vis.play(qs_, dt);
47+
}
48+
49+
static void
50+
play_proxy2(Visualizer & vis, const visualizers::ConstMatrixRef & qs, context::Scalar dt)
3851
{
3952
vis.play(qs, dt);
4053
}
@@ -58,6 +71,7 @@ namespace pinocchio
5871
.def(
5972
"display", +[](Visualizer & v, const ConstVectorRef & q) { v.display(q); },
6073
(bp::arg("self"), bp::arg("q") = boost::none))
74+
.def("play", play_proxy, (bp::arg("self"), "qs", "dt"))
6175
.def("play", play_proxy2, (bp::arg("self"), "qs", "dt"))
6276
.def("setCameraTarget", &Visualizer::setCameraTarget, (bp::arg("self"), "target"))
6377
.def("setCameraPosition", &Visualizer::setCameraPosition, (bp::arg("self"), "position"))

include/pinocchio/multibody/joint/joint-composite.hpp

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ namespace pinocchio
205205
, m_nv(0)
206206
, m_nvExtended(0)
207207
, njoints(0)
208+
, jointNames()
208209
{
209210
}
210211

@@ -216,6 +217,7 @@ namespace pinocchio
216217
, m_nv(0)
217218
, m_nvExtended(0)
218219
, njoints(0)
220+
, jointNames()
219221
{
220222
joints.reserve(size);
221223
jointPlacements.reserve(size);
@@ -225,17 +227,21 @@ namespace pinocchio
225227
m_nqs.reserve(size);
226228
m_nvs.reserve(size);
227229
m_nvExtendeds.reserve(size);
230+
jointNames.reserve(size);
228231
}
229232

230233
///
231234
/// \brief Constructor with one joint.
232235
///
233236
/// \param jmodel Model of the first joint.
234237
/// \param placement Placement of the first joint w.r.t. the joint origin.
238+
/// \param name Name of the joint inside the composite
235239
///
236240
template<typename JointModel>
237241
JointModelCompositeTpl(
238-
const JointModelBase<JointModel> & jmodel, const SE3 & placement = SE3::Identity())
242+
const JointModelBase<JointModel> & jmodel,
243+
const SE3 & placement = SE3::Identity(),
244+
const std::string & name = "joint_1")
239245
: joints(1, (JointModelVariant)jmodel.derived())
240246
, jointPlacements(1, placement)
241247
, m_nq(jmodel.nq())
@@ -248,6 +254,7 @@ namespace pinocchio
248254
, m_idx_vExtended(1, 0)
249255
, m_nvExtendeds(1, jmodel.nvExtended())
250256
, njoints(1)
257+
, jointNames(1, name)
251258
{
252259
}
253260

@@ -270,6 +277,7 @@ namespace pinocchio
270277
, m_idx_vExtended(other.m_idx_vExtended)
271278
, m_nvExtendeds(other.m_nvExtendeds)
272279
, njoints(other.njoints)
280+
, jointNames(other.jointNames)
273281
{
274282
}
275283

@@ -278,12 +286,15 @@ namespace pinocchio
278286
///
279287
/// \param jmodel Model of the joint to add.
280288
/// \param placement Placement of the joint relatively to its predecessor.
289+
/// \param name name of the joint inside the composite
281290
///
282291
/// \return A reference to *this
283292
///
284293
template<typename JointModel>
285-
JointModelDerived &
286-
addJoint(const JointModelBase<JointModel> & jmodel, const SE3 & placement = SE3::Identity())
294+
JointModelDerived & addJoint(
295+
const JointModelBase<JointModel> & jmodel,
296+
const SE3 & placement = SE3::Identity(),
297+
const std::string & name = "")
287298
{
288299
joints.push_back((JointModelVariant)jmodel.derived());
289300
jointPlacements.push_back(placement);
@@ -295,6 +306,13 @@ namespace pinocchio
295306
updateJointIndexes();
296307
njoints++;
297308

309+
std::string final_name = name;
310+
if (name.empty())
311+
{
312+
final_name = "joint_" + std::to_string(njoints + 1);
313+
}
314+
jointNames.push_back(final_name);
315+
298316
return *this;
299317
}
300318

@@ -414,6 +432,7 @@ namespace pinocchio
414432
joints = other.joints;
415433
jointPlacements = other.jointPlacements;
416434
njoints = other.njoints;
435+
jointNames = other.jointNames;
417436

418437
return *this;
419438
}
@@ -432,7 +451,8 @@ namespace pinocchio
432451
&& internal::comparison_eq(m_nvExtendeds, other.m_nvExtendeds)
433452
&& internal::comparison_eq(joints, other.joints)
434453
&& internal::comparison_eq(jointPlacements, other.jointPlacements)
435-
&& internal::comparison_eq(njoints, other.njoints);
454+
&& internal::comparison_eq(njoints, other.njoints)
455+
&& internal::comparison_eq(jointNames, other.jointNames);
436456
}
437457

438458
/// \returns An expression of *this with the Scalar type casted to NewScalar.
@@ -452,6 +472,7 @@ namespace pinocchio
452472
res.m_nvs = m_nvs;
453473
res.m_nvExtendeds = m_nvExtendeds;
454474
res.njoints = njoints;
475+
res.jointNames = jointNames;
455476

456477
res.joints.resize(joints.size());
457478
res.jointPlacements.resize(jointPlacements.size());
@@ -464,6 +485,16 @@ namespace pinocchio
464485
return res;
465486
}
466487

488+
JointIndex getJointId(const std::string & joint_name) const
489+
{
490+
auto it = std::find(jointNames.begin(), jointNames.end(), joint_name);
491+
492+
if (it == jointNames.end())
493+
PINOCCHIO_THROW_PRETTY(std::invalid_argument, "JointComposite - joint_name not found");
494+
495+
return JointIndex(std::distance(jointNames.begin(), it));
496+
}
497+
467498
/// \brief Vector of joints contained in the joint composite.
468499
JointModelVector joints;
469500
/// \brief Vector of joint placements. Those placements correspond to the origin of the joint
@@ -688,6 +719,8 @@ namespace pinocchio
688719
std::vector<int> m_idx_vExtended;
689720
/// \brief Dimension of the segment in the jacobian matrix
690721
std::vector<int> m_nvExtendeds;
722+
/// \brief Vector of names for each joint inside the composite
723+
std::vector<std::string> jointNames;
691724

692725
public:
693726
/// \brief Number of joints contained in the JointModelComposite

include/pinocchio/serialization/joints-model.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace pinocchio
2929

3030
ar & make_nvp("joints", joint.joints);
3131
ar & make_nvp("jointPlacements", joint.jointPlacements);
32+
ar & make_nvp("jointNames", joint.jointNames);
3233
}
3334
};
3435
} // namespace pinocchio

unittest/joint-composite.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,16 @@ BOOST_AUTO_TEST_CASE(test_kinematics)
344344
BOOST_CHECK(data.a.back().isApprox(data_c.a.back()));
345345
}
346346

347+
BOOST_AUTO_TEST_CASE(checkJointNames)
348+
{
349+
JointModelComposite jmodel_composite;
350+
jmodel_composite.addJoint(JointModelRZ())
351+
.addJoint(JointModelRY(), SE3::Random(), "penultinum_joint")
352+
.addJoint(JointModelRX(), SE3::Random(), "last_joint");
353+
354+
BOOST_CHECK(jmodel_composite.getJointId("last_joint") == 2);
355+
BOOST_CHECK(jmodel_composite.getJointId("penultinum_joint") == 1);
356+
BOOST_CHECK_THROW(jmodel_composite.getJointId("wrong_name"), std::invalid_argument);
357+
}
358+
347359
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)