Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7a5c37e
Joints - Add a first implementation of joint spline
MegMll Oct 8, 2025
2f6dd50
Unittest - Add TU for spline joint
MegMll Oct 8, 2025
1fd4295
Bindings - add bindings for spline joint
MegMll Oct 8, 2025
f169e9c
Spatial - Weird fix to make spline joint work for now (to remove)
MegMll Oct 8, 2025
936c1d4
Unittest - update joint unittests to include spline joints
MegMll Oct 10, 2025
7109553
SplineJoint - apply pre-commit
MegMll Oct 10, 2025
d42f298
Spline - use the true cumulative form of the spline
MegMll Oct 10, 2025
c9c780a
Spline - Add isEqual Method
MegMll Oct 13, 2025
245bc08
Spline - Add TU with finite difference
MegMll Oct 13, 2025
87c9314
Unittest - fix tests for spline joint
MegMll Oct 13, 2025
343c4fa
Spline joint - change if/else to be casadi compatible
MegMll Oct 14, 2025
befe587
Joint Spline - Remove useless comments
MegMll Oct 15, 2025
ba09e10
Joint Spline - Fix indexing
MegMll Oct 15, 2025
8e6fac3
Joint Spline - Eigen No Malloc checked and passed
MegMll Oct 15, 2025
835a3be
Spline joints - fix casadi joints tests
MegMll Oct 15, 2025
6bf8e04
Joint Spline - Add a build method
MegMll Oct 16, 2025
2c73df3
Unittest - Fix joint spline's unittests
MegMll Oct 16, 2025
5a15d61
Model-graph - Add spline joint to model graph
MegMll Oct 16, 2025
bbff9a3
JointSpline - make some correction to the joint
MegMll Oct 20, 2025
59c7cf6
TU - apply new jointSpline constructor
MegMll Oct 20, 2025
0c69a04
ModelGraph - use new JointSpline method
MegMll Oct 20, 2025
5b614da
Serialization - Add attributes from spline model and data
MegMll Oct 21, 2025
0a6e431
Unittest - use std vector instead of se3
MegMll Oct 21, 2025
522db04
JointSpline - Diverse Changes
MegMll Oct 21, 2025
cb17904
Casadi - Add a separated file for findSpan to be able to do specializ…
MegMll Oct 21, 2025
db6439b
Bindings - modify joint spline binding
MegMll Oct 21, 2025
11f31c9
JointSpline - Remove findSpan
MegMll Oct 21, 2025
1f14429
Unittest - remove buildJoint function
MegMll Oct 21, 2025
2592cc6
ModelGraph - finish adding jointSpline to model graph + unittest
MegMll Oct 21, 2025
0f8bb0e
cppadcg: Fix cppadcg cast test with spline joint
jorisv Oct 22, 2025
fa73b20
multiprecision: Fix multiprecision cast test with Spline joint
jorisv Oct 22, 2025
4d3d02e
multiprecision: Add missing header
jorisv Oct 22, 2025
dbcbf1a
lint: Run linter
jorisv Oct 22, 2025
57d00f0
JointSpline - Removed comments
MegMll Oct 22, 2025
9f418a8
JointSpline - move bspline functions in public to be able to test it
MegMll Oct 22, 2025
789fe01
Unittest - add more test for joint spline
MegMll Oct 22, 2025
2bbd344
Bindings - Add another constructor for joint spline
MegMll Oct 23, 2025
3e1b6a3
Unittest - put full knee trajectory
MegMll Oct 23, 2025
10e0012
Unittest - try a fix for windows and serialization
MegMll Oct 23, 2025
119595d
Unittest - fix getTrajectory function
MegMll Oct 23, 2025
0fd8a15
Bindings - add modelgraph bindings constant
MegMll Oct 27, 2025
26bf375
JointSpline - Fix indexing
MegMll Oct 27, 2025
5887519
JointSpline - Add a doc
MegMll Oct 27, 2025
618c495
JointSpline - Fix bias computation
MegMll Oct 27, 2025
db32494
Unittest - add a finite difference test for S and bias c for JointSpline
MegMll Oct 27, 2025
de1ef3a
JointSpline - Add comments and complete isEqual function
MegMll Oct 28, 2025
fe4b5ca
Unittest - Try to add tolerance to see if it fixes macos-intel problem
MegMll Oct 28, 2025
78ec286
Unittest - fix compilation error
MegMll Oct 28, 2025
3f4b6a6
JointSpline - add assert for configuration to be between 0 and 1
MegMll Oct 30, 2025
f9c336c
Bindings - Add graph spline joints bindings
MegMll Oct 30, 2025
d89552b
Algo/Splines - remove comments
MegMll Oct 30, 2025
e5fbd70
Unittest - add find span test for q = 0
MegMll Oct 30, 2025
1097d4f
Changelog - update
MegMll Oct 30, 2025
4b42132
JointSpline - remove SE3 and use Transformation_t
MegMll Oct 30, 2025
d5b210a
Unittest - remove comments
MegMll Oct 30, 2025
2ffe305
JointSpline - Use transformation_t and motion_t
MegMll Oct 30, 2025
a2b0703
Examples - Add a small examples on what the spline joint can do
MegMll Oct 30, 2025
f2e5c30
Unittest - Specialize for joint spline
MegMll Oct 30, 2025
4768a32
Examples - add spline joint examples
MegMll Oct 30, 2025
079720e
Unittest - Fix joint generic test for joint spline
MegMll Nov 3, 2025
ef9b1e3
Examples - Fix some linting errors
MegMll Nov 3, 2025
86b40d7
JointSpline - Disable assert
MegMll Nov 4, 2025
096a5ec
core: Apply small changes
jorisv Nov 25, 2025
a94b07b
Algo/splines - add doc
MegMll Nov 26, 2025
f4421ae
Unittest - Avoid code duplication for randomConfig vector generation
MegMll Nov 26, 2025
a8c2e58
Unittest - more complex and complete tests
MegMll Nov 26, 2025
4b8c8e9
Unittest/cppad - use degree 3 spline joint
MegMll Nov 27, 2025
57e31ab
unittest - change name of struct to be more generic
MegMll Nov 27, 2025
08af0ca
unittest - avoid code duplication
MegMll Nov 27, 2025
86537d9
unittest - avoid code duplication
MegMll Nov 27, 2025
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: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add docker images ([#2776](https://github.com/stack-of-tasks/pinocchio/pull/2776))
- Add names to joints that are inside a composite joint ([#2786](https://github.com/stack-of-tasks/pinocchio/pull/2786))
- Add color support for robot meshes in Viser ([#2793](https://github.com/stack-of-tasks/pinocchio/pull/2793))
- Add a new spline joint to default joint collection ([#2784](https://github.com/stack-of-tasks/pinocchio/pull/2784))

### Changed
- Python version update ([#2802](https://github.com/stack-of-tasks/pinocchio/pull/2802)):
Expand All @@ -35,7 +36,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
- Remove CMake < 3.22 details ([#2790](https://github.com/stack-of-tasks/pinocchio/pull/2790))


## [3.8.0] - 2025-09-17

### Added
Expand Down
18 changes: 18 additions & 0 deletions bindings/python/parsers/graph/expose-edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace pinocchio

const int JointMimic::nq;
const int JointMimic::nv;

const int JointSpline::nq;
const int JointSpline::nv;
} // namespace graph

namespace python
Expand Down Expand Up @@ -141,6 +144,21 @@ namespace pinocchio
.def_readonly("nq", &JointUniversal::nq, "Number of configuration variables.")
.def_readonly("nv", &JointUniversal::nv, "Number of tangent variables.");

bp::class_<JointSpline>(
"JointSpline", "Represents a spline-based joint.",
bp::init<>(bp::args("self"), "Default constructor."))
.def(bp::init<int>(bp::args("self", "degree"), "Constructor with degree."))
.def(bp::init<const SE3 &, int>(
bp::args("self", "ctrlFrame", "degree"),
"Constructor with a single control frame and degree."))
.def_readwrite("ctrlFrames", &JointSpline::ctrlFrames, "Control frames of the spline.")
.def_readwrite("degree", &JointSpline::degree, "Degree of the spline.")
.def_readonly("nq", &JointSpline::nq, "Number of configuration variables.")
.def_readonly("nv", &JointSpline::nv, "Number of tangent variables.")
.def(
"addCtrlFrame", &JointSpline::addCtrlFrame, bp::args("self", "ctrlFrame"),
"Add a control frame to the spline.");

bp::class_<JointComposite>(
"JointComposite", "Represents a composite joint.",
bp::init<>(bp::args("self"), "Default constructor."))
Expand Down
94 changes: 94 additions & 0 deletions examples/spline-joint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import time

import hppfcl
import numpy as np
import pinocchio as pin
from pinocchio.visualize import MeshcatVisualizer


def generate_random_se3_trajectory(num_steps, radius, num_revolutions, height):
"""
Generates a random trajectory in SE(3) with rotating orientation.

Args:
num_keyframes: The number of random keyframes to generate.
num_steps_per_segment: The number of intermediate steps between each keyframe.

Returns:
A list of pinocchio.SE3 objects representing the trajectory.
"""
trajectory = []
for i in range(num_steps):
# 1. Parameter to track progress along the helix (from 0.0 to 1.0)
alpha = float(i) / num_steps

# 2. Define the translational part (the helical path)
# The angle determines the position on the XY plane
angle = alpha * num_revolutions * 2 * np.pi

# Calculate the x, y, z coordinates for the helix
translation = np.array(
[radius * np.cos(angle), radius * np.sin(angle), alpha * height]
)

# 3. Define the rotational part (a new random orientation at each step)
# pin.SE3.Random().rotation generates a random 3x3 rotation matrix
random_rotation = pin.SE3.Random().rotation

# 4. Combine the translation and random rotation into a single SE(3) pose
pose = pin.SE3(random_rotation, translation)
trajectory.append(pose)

return trajectory


# --- Visualization Setup ---

# Generate the random trajectory
# Parameters for the helical trajectory
num_steps = 30
radius = 1.0
num_revolutions = 3
height = 2

trajectory = generate_random_se3_trajectory(num_steps, radius, num_revolutions, height)

# Create a Pinocchio model with a single free-flyer joint
model = pin.Model()
joint_id = model.addJoint(
0, pin.JointModelSpline(trajectory, 3), pin.SE3.Identity(), "free_flyer"
)

# Attach a simple visual geometry (a box) to the joint
visual_model = pin.GeometryModel()
box_shape = hppfcl.Box(0.1, 0.2, 0.3)
# The placement of the geometry with respect to the joint frame
geom_placement = pin.SE3.Identity()
geom_obj = pin.GeometryObject("box", joint_id, geom_placement, box_shape)
# Assign a color to the geometry
geom_obj.meshColor = np.array([1.0, 0.5, 0.5, 1.0]) # RGBA
visual_model.addGeometryObject(geom_obj)

# --- Main Execution ---

# Initialize the MeshCat visualizer.
try:
viz = MeshcatVisualizer(model, visual_model, visual_model)
viz.initViewer(open=True)
viz.loadViewerModel()
except ImportError as e:
print("Error while initializing the viewer.")
print(e)


time.sleep(0.1)

q = pin.neutral(model)

q_vector = np.arange(0, 1, 0.05)
for q in q_vector:
# Display the new configuration.
viz.display(np.array([q]))

# Delay for visualization
time.sleep(0.05)
58 changes: 58 additions & 0 deletions include/pinocchio/algorithm/splines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Copyright (c) 2025 INRIA
//

#ifndef __pinocchio_algorithm_splines_hpp__
#define __pinocchio_algorithm_splines_hpp__

namespace pinocchio
{
/// @brief Helper structure defining a range of indices.
/// @details This struct identifies the subset of control frames in a spline that are active
/// (i.e., have non-zero basis functions) for a specific spline parameter value.
/// Using this local support property allows for efficient computation of the joint
/// transformation, S, and bias c.
struct SpanIndexes
{
size_t start_idx;
size_t end_idx;
};

/// @brief Algorithm to locate the span for a given B-spline parameter, q.
/// @details This struct implements a binary search (FindSpan) to determine which knot span
/// a given parameter value falls into. In B-spline curves, a parameter value $u$ implies that
/// only $(p+1)$ control points affect the curve at that location (where $p$ is the degree).
template<typename Scalar, int Options>
struct FindSpan
{
template<typename ConfigVector, typename KnotsVector>
static SpanIndexes run(
const Eigen::MatrixBase<ConfigVector> & q,
const int degree,
const int nbCtrlFrames,
const Eigen::MatrixBase<KnotsVector> & knots)
{
// Edge case: if q is at or beyond the end of the spline parameterization
if (q[0] >= 1.0)
return {
static_cast<size_t>(nbCtrlFrames - (degree + 1)), static_cast<size_t>(nbCtrlFrames)};

int low = degree;
int high = nbCtrlFrames;
int mid;

while (low < high)
{
mid = low + (high - low) / 2;
if (q[0] < knots[mid])
high = mid;
else
low = mid + 1;
}

return {static_cast<size_t>(low - (degree + 1)), static_cast<size_t>(low)};
}
};
} // namespace pinocchio

#endif // __pinocchio_algorithm_splines_hpp__
1 change: 1 addition & 0 deletions include/pinocchio/autodiff/casadi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,6 @@ namespace Eigen
#include "pinocchio/autodiff/casadi/math/matrix.hpp"
#include "pinocchio/autodiff/casadi/math/quaternion.hpp"
#include "pinocchio/autodiff/casadi/math/triangular-matrix.hpp"
#include "pinocchio/autodiff/casadi/algorithm/splines.hpp"

#endif // #ifndef __pinocchio_autodiff_casadi_hpp__
33 changes: 33 additions & 0 deletions include/pinocchio/autodiff/casadi/algorithm/splines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright (c) 2025 INRIA
//

#ifndef __pinocchio_autodiff_casadi_splines_hpp__
#define __pinocchio_autodiff_casadi_splines_hpp__

#include "pinocchio/algorithm/splines.hpp"

namespace pinocchio
{
// Fwd Declare
struct SpanIndexes;

template<typename Scalar, int Options>
struct FindSpan;

template<int Options>
struct FindSpan<::casadi::SX, Options>
{
template<typename ConfigVector, typename KnotsVector>
static SpanIndexes run(
const Eigen::MatrixBase<ConfigVector> & /*q*/,
const int /*degree*/,
const int nbCtrlFrames,
const Eigen::MatrixBase<KnotsVector> & /*knots*/)
{
return {0, static_cast<size_t>(nbCtrlFrames)};
}
};
} // namespace pinocchio

#endif // __pinocchio_autodiff_casadi_splines_hpp__
3 changes: 3 additions & 0 deletions include/pinocchio/bindings/python/context/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ namespace pinocchio
typedef JointModelUniversalTpl<Scalar> JointModelUniversal;
typedef JointDataUniversalTpl<Scalar> JointDataUniversal;

typedef JointModelSplineTpl<Scalar> JointModelSpline;
typedef JointDataSplineTpl<Scalar> JointDataSpline;

typedef JointModelTranslationTpl<Scalar> JointModelTranslation;
typedef JointDataTranslationTpl<Scalar> JointDataTranslation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ namespace pinocchio
.add_property("pjMi", &JointDataComposite::pjMi)
.add_property("StU", &JointDataComposite::StU);
}

} // namespace python
} // namespace pinocchio

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,38 @@ namespace pinocchio
"Second rotation axis of the JointModelUniversal.");
}

// Specialization for JointModelSpline
template<>
bp::class_<context::JointModelSpline> &
expose_joint_model<context::JointModelSpline>(bp::class_<context::JointModelSpline> & cl)
{
return cl
.def(bp::init<>(
bp::args("self"),
"Init an empty joint Spline. Default degree of spline basis function is 3."))
.def(bp::init<int>(
bp::args("self", "degree"),
"Init an empty joint Spline, with the degree of the future basis functions"))
.def(bp::init<const ::pinocchio::container::aligned_vector<context::SE3> &, int>(
bp::args("self", "controlFrames", "degree"),
"Init an empty joint Spline, with a list of controlFrames and the degree of the future "
"basis functions"))
.def(
"setControlFrames", &context::JointModelSpline::setControlFrames, bp::arg("frames"),
"Add a vector of frames to the joint. It cannot be changed afterward and no frames can "
"be added afterwards either")
.def(
"makeKnots", &context::JointModelSpline::makeKnots,
"generate the knots vector for the spline. Call after all the control frame have been "
"added")
.def(
"computeRelativeMotion", &context::JointModelSpline::computeRelativeMotions,
"compute the relative motion between the control frames. Call after all the control "
"frames have been added")
.def_readwrite(
"degree", &context::JointModelSpline::degree, "Degree of the spline basis functions");
}

// specialization for JointModelComposite

struct JointModelCompositeAddJointVisitor
Expand Down
1 change: 1 addition & 0 deletions include/pinocchio/math/multiprecision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "pinocchio/math/fwd.hpp"

#include <boost/mpl/bool_fwd.hpp>
#include <boost/multiprecision/number.hpp>
#include <boost/random.hpp>
#include <Eigen/Dense>
Expand Down
8 changes: 8 additions & 0 deletions include/pinocchio/multibody/joint/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ namespace pinocchio
struct JointDataTranslationTpl;
typedef JointDataTranslationTpl<context::Scalar> JointDataTranslation;

template<typename Scalar, int Options = context::Options>
struct JointModelSplineTpl;
typedef JointModelSplineTpl<context::Scalar> JointModelSpline;

template<typename Scalar, int Options = context::Options>
struct JointDataSplineTpl;
typedef JointDataSplineTpl<context::Scalar> JointDataSpline;

template<typename Scalar, int Options = context::Options>
struct JointCollectionDefaultTpl;
typedef JointCollectionDefaultTpl<context::Scalar> JointCollectionDefault;
Expand Down
8 changes: 8 additions & 0 deletions include/pinocchio/multibody/joint/joint-collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ namespace pinocchio
// Joint Universal
typedef JointModelUniversalTpl<Scalar, Options> JointModelUniversal;

// Joint Spline
typedef JointModelSplineTpl<Scalar, Options> JointModelSpline;

typedef boost::variant<
// JointModelVoid,
JointModelRX,
Expand All @@ -106,6 +109,7 @@ namespace pinocchio
JointModelHz,
JointModelHelicalUnaligned,
JointModelUniversal,
JointModelSpline,
boost::recursive_wrapper<JointModelComposite>,
boost::recursive_wrapper<JointModelMimic>>
JointModelVariant;
Expand Down Expand Up @@ -169,6 +173,9 @@ namespace pinocchio
// Joint Universal
typedef JointDataUniversalTpl<Scalar, Options> JointDataUniversal;

// Joint Spline
typedef JointDataSplineTpl<Scalar, Options> JointDataSpline;

typedef boost::variant<
// JointDataVoid
JointDataRX,
Expand All @@ -193,6 +200,7 @@ namespace pinocchio
JointDataHz,
JointDataHelicalUnaligned,
JointDataUniversal,
JointDataSpline,
boost::recursive_wrapper<JointDataComposite>,
boost::recursive_wrapper<JointDataMimic>>
JointDataVariant;
Expand Down
Loading
Loading