Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8011234
Joints - Add a first implementation of joint spline
MegMll Oct 8, 2025
74af21a
Unittest - Add TU for spline joint
MegMll Oct 8, 2025
c1f4c9e
Bindings - add bindings for spline joint
MegMll Oct 8, 2025
ca4b5bf
Spatial - Weird fix to make spline joint work for now (to remove)
MegMll Oct 8, 2025
6fa0947
Unittest - update joint unittests to include spline joints
MegMll Oct 10, 2025
210a1b0
SplineJoint - apply pre-commit
MegMll Oct 10, 2025
ffe560e
Spline - use the true cumulative form of the spline
MegMll Oct 10, 2025
36f2618
Spline - Add isEqual Method
MegMll Oct 13, 2025
b901345
Spline - Add TU with finite difference
MegMll Oct 13, 2025
b562ae2
Unittest - fix tests for spline joint
MegMll Oct 13, 2025
c7c0b54
Spline joint - change if/else to be casadi compatible
MegMll Oct 14, 2025
823714b
Joint Spline - Remove useless comments
MegMll Oct 15, 2025
be2f401
Joint Spline - Fix indexing
MegMll Oct 15, 2025
e4b3f52
Joint Spline - Eigen No Malloc checked and passed
MegMll Oct 15, 2025
863fdd9
Spline joints - fix casadi joints tests
MegMll Oct 15, 2025
4be1e3c
Joint Spline - Add a build method
MegMll Oct 16, 2025
633f41a
Unittest - Fix joint spline's unittests
MegMll Oct 16, 2025
a3d7270
Model-graph - Add spline joint to model graph
MegMll Oct 16, 2025
a4f3d19
JointSpline - make some correction to the joint
MegMll Oct 20, 2025
6181cde
TU - apply new jointSpline constructor
MegMll Oct 20, 2025
dbe5f5a
ModelGraph - use new JointSpline method
MegMll Oct 20, 2025
393cf1c
Serialization - Add attributes from spline model and data
MegMll Oct 21, 2025
6db0782
Unittest - use std vector instead of se3
MegMll Oct 21, 2025
4028aa0
JointSpline - Diverse Changes
MegMll Oct 21, 2025
303ee6b
Casadi - Add a separated file for findSpan to be able to do specializ…
MegMll Oct 21, 2025
61e5f88
Bindings - modify joint spline binding
MegMll Oct 21, 2025
573935d
JointSpline - Remove findSpan
MegMll Oct 21, 2025
f207945
Unittest - remove buildJoint function
MegMll Oct 21, 2025
548b7a2
ModelGraph - finish adding jointSpline to model graph + unittest
MegMll Oct 21, 2025
a9b1bfe
cppadcg: Fix cppadcg cast test with spline joint
jorisv Oct 22, 2025
ac75a25
multiprecision: Fix multiprecision cast test with Spline joint
jorisv Oct 22, 2025
65a9421
multiprecision: Add missing header
jorisv Oct 22, 2025
1024893
lint: Run linter
jorisv Oct 22, 2025
903b9f5
JointSpline - Removed comments
MegMll Oct 22, 2025
44961b4
JointSpline - move bspline functions in public to be able to test it
MegMll Oct 22, 2025
5d7a739
Unittest - add more test for joint spline
MegMll Oct 22, 2025
207c26d
Bindings - Add another constructor for joint spline
MegMll Oct 23, 2025
fd7798f
Unittest - put full knee trajectory
MegMll Oct 23, 2025
c4e7865
Unittest - try a fix for windows and serialization
MegMll Oct 23, 2025
376b89c
Unittest - fix getTrajectory function
MegMll Oct 23, 2025
7156da5
Bindings - add modelgraph bindings constant
MegMll Oct 27, 2025
3ab2890
JointSpline - Fix indexing
MegMll Oct 27, 2025
2c19b45
JointSpline - Add a doc
MegMll Oct 27, 2025
a9ff06b
JointSpline - Fix bias computation
MegMll Oct 27, 2025
c4a6be4
Unittest - add a finite difference test for S and bias c for JointSpline
MegMll Oct 27, 2025
8e4dbf9
JointSpline - Add comments and complete isEqual function
MegMll Oct 28, 2025
da127f8
Unittest - Try to add tolerance to see if it fixes macos-intel problem
MegMll Oct 28, 2025
82c0f30
Unittest - fix compilation error
MegMll Oct 28, 2025
7d204a8
JointSpline - add assert for configuration to be between 0 and 1
MegMll Oct 30, 2025
951a79a
Bindings - Add graph spline joints bindings
MegMll Oct 30, 2025
3f82e27
Algo/Splines - remove comments
MegMll Oct 30, 2025
cbae7d3
Unittest - add find span test for q = 0
MegMll Oct 30, 2025
d86231f
Changelog - update
MegMll Oct 30, 2025
5ded836
JointSpline - remove SE3 and use Transformation_t
MegMll Oct 30, 2025
bf16106
Unittest - remove comments
MegMll Oct 30, 2025
9c0b4da
JointSpline - Use transformation_t and motion_t
MegMll Oct 30, 2025
b04d961
Examples - Add a small examples on what the spline joint can do
MegMll Oct 30, 2025
6b54af1
Unittest - Specialize for joint spline
MegMll Oct 30, 2025
ec39eeb
Examples - add spline joint examples
MegMll Oct 30, 2025
9f2aa54
Unittest - Fix joint generic test for joint spline
MegMll Nov 3, 2025
f755af3
Examples - Fix some linting errors
MegMll Nov 3, 2025
b4923b1
JointSpline - Disable assert
MegMll Nov 4, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
- Add names to joints that are inside a composite joint ([#2786](https://github.com/stack-of-tasks/pinocchio/pull/2786))
- Add a new spline joint to default joint collection ([#2784](https://github.com/stack-of-tasks/pinocchio/pull/2784))

## [3.8.0] - 2025-09-17

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)
49 changes: 49 additions & 0 deletions include/pinocchio/algorithm/splines.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright (c) 2025 INRIA
//

#ifndef __pinocchio_algorithm_splines_hpp__
#define __pinocchio_algorithm_splines_hpp__

namespace pinocchio
{
struct SpanIndexes
{
size_t start_idx;
size_t end_idx;
};

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