timings-jacobian.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2025 CNRS
3 //
4 
5 #include "model-fixture.hpp"
6 
15 
16 #include <iostream>
17 
18 #include <benchmark/benchmark.h>
19 
20 static void CustomArguments(benchmark::internal::Benchmark * b)
21 {
22  b->MinWarmUpTime(3.);
23 }
24 
26 {
27  void SetUp(benchmark::State & st)
28  {
30  J.setZero(6, model.nv);
32  pinocchio::SE3 framePlacement = pinocchio::SE3::Random();
34  pinocchio::Frame("test_frame", joint_id, 0, framePlacement, pinocchio::OP_FRAME));
35  // Data must be recreated after model modification
37  }
38  void TearDown(benchmark::State & st)
39  {
41  }
42 
46 };
47 
48 // FORWARD_KINEMATICS_Q
49 
51  const pinocchio::Model & model, pinocchio::Data & data, const Eigen::VectorXd & q)
52 {
54 }
55 BENCHMARK_DEFINE_F(JacobianFixture, FORWARD_KINEMATICS_Q)(benchmark::State & st)
56 {
57  for (auto _ : st)
58  {
60  }
61 }
62 BENCHMARK_REGISTER_F(JacobianFixture, FORWARD_KINEMATICS_Q)->Apply(CustomArguments);
63 
64 // COMPUTE_JOINT_JACOBIAN
65 
67  const pinocchio::Model & model,
69  const Eigen::VectorXd & q,
72 {
74 }
75 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_JOINT_JACOBIAN)(benchmark::State & st)
76 {
77  for (auto _ : st)
78  {
80  }
81 }
82 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_JOINT_JACOBIAN)->Apply(CustomArguments);
83 
84 // COMPUTE_JOINT_JACOBIANS_Q
85 
87  const pinocchio::Model & model, pinocchio::Data & data, const Eigen::VectorXd & q)
88 {
90 }
91 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_JOINT_JACOBIANS_Q)(benchmark::State & st)
92 {
93  for (auto _ : st)
94  {
96  }
97 }
98 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_JOINT_JACOBIANS_Q)->Apply(CustomArguments);
99 
100 // COMPUTE_JOINT_JACOBIANS
101 
102 PINOCCHIO_DONT_INLINE static void
104 {
106 }
107 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_JOINT_JACOBIANS)(benchmark::State & st)
108 {
110  for (auto _ : st)
111  {
113  }
114 }
115 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_JOINT_JACOBIANS)->Apply(CustomArguments);
116 
117 // GET_JOINT_JACOBIAN
118 
119 template<pinocchio::ReferenceFrame Frame>
121  const pinocchio::Model & model,
122  const pinocchio::Data & data,
125 {
127 }
128 
129 BENCHMARK_DEFINE_F(JacobianFixture, GET_JOINT_JACOBIAN_LOCAL)(benchmark::State & st)
130 {
132  for (auto _ : st)
133  {
134  getJointJacobianCall<pinocchio::LOCAL>(model, data, joint_id, J);
135  }
136 }
137 BENCHMARK_REGISTER_F(JacobianFixture, GET_JOINT_JACOBIAN_LOCAL)->Apply(CustomArguments);
138 BENCHMARK_DEFINE_F(JacobianFixture, GET_JOINT_JACOBIAN_WORLD)(benchmark::State & st)
139 {
141  for (auto _ : st)
142  {
143  getJointJacobianCall<pinocchio::WORLD>(model, data, joint_id, J);
144  }
145 }
146 BENCHMARK_REGISTER_F(JacobianFixture, GET_JOINT_JACOBIAN_WORLD)->Apply(CustomArguments);
147 BENCHMARK_DEFINE_F(JacobianFixture, GET_JOINT_JACOBIAN_LOCAL_WORLD_ALIGNED)(benchmark::State & st)
148 {
150  for (auto _ : st)
151  {
152  getJointJacobianCall<pinocchio::LOCAL_WORLD_ALIGNED>(model, data, joint_id, J);
153  }
154 }
155 BENCHMARK_REGISTER_F(JacobianFixture, GET_JOINT_JACOBIAN_LOCAL_WORLD_ALIGNED)
156  ->Apply(CustomArguments);
157 
158 // GET_FRAME_JACOBIAN
159 
160 template<pinocchio::ReferenceFrame Frame>
162  const pinocchio::Model & model,
166 {
168 }
169 
170 BENCHMARK_DEFINE_F(JacobianFixture, GET_FRAME_JACOBIAN_LOCAL)(benchmark::State & st)
171 {
174  std::cout << "frame_id: " << frame_id << std::endl;
175  for (auto _ : st)
176  {
177  getFrameJacobianCall<pinocchio::LOCAL>(model, data, frame_id, J);
178  }
179 }
180 BENCHMARK_REGISTER_F(JacobianFixture, GET_FRAME_JACOBIAN_LOCAL)->Apply(CustomArguments);
181 BENCHMARK_DEFINE_F(JacobianFixture, GET_FRAME_JACOBIAN_WORLD)(benchmark::State & st)
182 {
185  for (auto _ : st)
186  {
187  getFrameJacobianCall<pinocchio::WORLD>(model, data, frame_id, J);
188  }
189 }
190 BENCHMARK_REGISTER_F(JacobianFixture, GET_FRAME_JACOBIAN_WORLD)->Apply(CustomArguments);
191 BENCHMARK_DEFINE_F(JacobianFixture, GET_FRAME_JACOBIAN_LOCAL_WORLD_ALIGNED)(benchmark::State & st)
192 {
195  for (auto _ : st)
196  {
197  getFrameJacobianCall<pinocchio::LOCAL_WORLD_ALIGNED>(model, data, frame_id, J);
198  }
199 }
200 BENCHMARK_REGISTER_F(JacobianFixture, GET_FRAME_JACOBIAN_LOCAL_WORLD_ALIGNED)
201  ->Apply(CustomArguments);
202 
203 // COMPUTE_FRAME_JACOBIAN
204 
205 template<pinocchio::ReferenceFrame Frame>
207  const pinocchio::Model & model,
209  const Eigen::VectorXd & q,
212 {
214 }
215 
216 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_LOCAL)(benchmark::State & st)
217 {
218  for (auto _ : st)
219  {
220  computeFrameJacobianCall<pinocchio::LOCAL>(model, data, q, frame_id, J);
221  }
222 }
223 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_LOCAL)->Apply(CustomArguments);
224 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_WORLD)(benchmark::State & st)
225 {
226  for (auto _ : st)
227  {
228  computeFrameJacobianCall<pinocchio::WORLD>(model, data, q, frame_id, J);
229  }
230 }
231 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_WORLD)->Apply(CustomArguments);
232 BENCHMARK_DEFINE_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_LOCAL_WORLD_ALIGNED)(
233  benchmark::State & st)
234 {
235  for (auto _ : st)
236  {
237  computeFrameJacobianCall<pinocchio::LOCAL_WORLD_ALIGNED>(model, data, q, frame_id, J);
238  }
239 }
240 BENCHMARK_REGISTER_F(JacobianFixture, COMPUTE_FRAME_JACOBIAN_LOCAL_WORLD_ALIGNED)
241  ->Apply(CustomArguments);
242 
computeJointJacobianCall
static PINOCCHIO_DONT_INLINE void computeJointJacobianCall(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::VectorXd &q, pinocchio::Index joint_id, pinocchio::Data::Matrix6x &J)
Definition: timings-jacobian.cpp:66
pinocchio::FrameIndex
Index FrameIndex
Definition: multibody/fwd.hpp:28
frames.hpp
pinocchio::DataTpl
Definition: context/generic.hpp:25
PINOCCHIO_DONT_INLINE
#define PINOCCHIO_DONT_INLINE
Function attribute to forbid inlining. This is a compiler hint that can be not respected.
Definition: include/pinocchio/macros.hpp:53
pinocchio::forwardKinematics
void forwardKinematics(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Update the joint placements according to the current joint configuration.
pinocchio::getFrameJacobian
void getFrameJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const JointIndex joint_id, const SE3Tpl< Scalar, Options > &placement, const ReferenceFrame reference_frame, const Eigen::MatrixBase< Matrix6xLike > &J)
Returns the jacobian of the frame given by its relative placement w.r.t. a joint frame,...
ModelFixture::model
pinocchio::Model model
Definition: model-fixture.hpp:79
forwardKinematicsQCall
static PINOCCHIO_DONT_INLINE void forwardKinematicsQCall(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::VectorXd &q)
Definition: timings-jacobian.cpp:50
ModelFixture::TearDown
void TearDown(benchmark::State &)
Definition: model-fixture.hpp:51
ModelFixture
Definition: model-fixture.hpp:37
pinocchio::python::context::Frame
FrameTpl< Scalar, Options > Frame
Definition: bindings/python/context/generic.hpp:62
pinocchio::SE3
context::SE3 SE3
Definition: spatial/fwd.hpp:59
kinematics.hpp
model.hpp
setup.data
data
Definition: cmake/cython/setup.in.py:48
inverse-kinematics-3d.J
J
Definition: inverse-kinematics-3d.py:28
JacobianFixture
Definition: timings-jacobian.cpp:25
pinocchio::computeJointJacobians
const DataTpl< Scalar, Options, JointCollectionTpl >::Matrix6x & computeJointJacobians(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q)
Computes the full model Jacobian, i.e. the stack of all motion subspace expressed in the world frame....
ModelFixture::data
pinocchio::Data data
Definition: model-fixture.hpp:80
JacobianFixture::SetUp
void SetUp(benchmark::State &st)
Definition: timings-jacobian.cpp:27
b
Vec3f b
CustomArguments
static void CustomArguments(benchmark::internal::Benchmark *b)
Definition: timings-jacobian.cpp:20
ModelFixture::SetUp
void SetUp(benchmark::State &)
Definition: model-fixture.hpp:39
JacobianFixture::joint_id
pinocchio::Model::JointIndex joint_id
Definition: timings-jacobian.cpp:44
pinocchio::computeFrameJacobian
void computeFrameJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const FrameIndex frameId, const ReferenceFrame reference_frame, const Eigen::MatrixBase< Matrix6xLike > &J)
Computes the Jacobian of a specific Frame expressed in the desired reference_frame given as argument.
pinocchio::FrameTpl
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition: multibody/frame.hpp:55
PINOCCHIO_BENCHMARK_MAIN
PINOCCHIO_BENCHMARK_MAIN()
pinocchio::Index
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
Definition: multibody/fwd.hpp:22
anymal-simulation.model
model
Definition: anymal-simulation.py:8
pinocchio::ModelTpl< context::Scalar, context::Options >::JointIndex
pinocchio::JointIndex JointIndex
Definition: multibody/model.hpp:67
joint-configuration.hpp
computeFrameJacobianCall
static PINOCCHIO_DONT_INLINE void computeFrameJacobianCall(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::VectorXd &q, pinocchio::FrameIndex frame_id, const pinocchio::Data::Matrix6x &J)
Definition: timings-jacobian.cpp:206
pinocchio::updateFramePlacements
void updateFramePlacements(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data)
Updates the position of each frame contained in the model.
JacobianFixture::J
pinocchio::Data::Matrix6x J
Definition: timings-jacobian.cpp:43
model-fixture.hpp
pinocchio::Data
DataTpl< context::Scalar, context::Options > Data
Definition: multibody/fwd.hpp:34
pinocchio::getJointJacobian
void getJointJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const JointIndex joint_id, const ReferenceFrame reference_frame, const Eigen::MatrixBase< Matrix6Like > &J)
Computes the Jacobian of a specific joint frame expressed in one of the pinocchio::ReferenceFrame opt...
urdf.hpp
data.hpp
pinocchio::ModelTpl::FrameIndex
pinocchio::FrameIndex FrameIndex
Definition: multibody/model.hpp:69
inverse-dynamics._
_
Definition: inverse-dynamics.py:22
q
q
computeJointJacobiansCall
static PINOCCHIO_DONT_INLINE void computeJointJacobiansCall(const pinocchio::Model &model, pinocchio::Data &data)
Definition: timings-jacobian.cpp:103
contact-cholesky.frame_id
frame_id
Definition: contact-cholesky.py:19
BENCHMARK_REGISTER_F
BENCHMARK_REGISTER_F(JacobianFixture, FORWARD_KINEMATICS_Q) -> Apply(CustomArguments)
getFrameJacobianCall
static PINOCCHIO_DONT_INLINE void getFrameJacobianCall(const pinocchio::Model &model, pinocchio::Data &data, pinocchio::FrameIndex frame_id, const pinocchio::Data::Matrix6x &J)
Definition: timings-jacobian.cpp:161
computeJointJacobiansQCall
static PINOCCHIO_DONT_INLINE void computeJointJacobiansQCall(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::VectorXd &q)
Definition: timings-jacobian.cpp:86
pinocchio::OP_FRAME
@ OP_FRAME
operational frame: user-defined frames that are defined at runtime
Definition: multibody/frame.hpp:33
JacobianFixture::frame_id
pinocchio::Model::FrameIndex frame_id
Definition: timings-jacobian.cpp:45
pinocchio::computeJointJacobian
void computeJointJacobian(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const JointIndex joint_id, const Eigen::MatrixBase< Matrix6Like > &J)
Computes the Jacobian of a specific joint frame expressed in the local frame of the joint and store t...
pinocchio::ModelTpl::nv
int nv
Dimension of the velocity vector space.
Definition: multibody/model.hpp:101
getJointJacobianCall
static PINOCCHIO_DONT_INLINE void getJointJacobianCall(const pinocchio::Model &model, const pinocchio::Data &data, pinocchio::Index joint_id, const pinocchio::Data::Matrix6x &J)
Definition: timings-jacobian.cpp:120
pinocchio::ModelTpl::addFrame
FrameIndex addFrame(const Frame &frame, const bool append_inertia=true)
Adds a frame to the kinematic tree. The inertia stored within the frame will be happened to the inert...
pinocchio::DataTpl::Matrix6x
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
The 6d jacobian type (temporary)
Definition: multibody/data.hpp:92
JacobianFixture::TearDown
void TearDown(benchmark::State &st)
Definition: timings-jacobian.cpp:38
sample-models.hpp
append-urdf-model-with-another-model.joint_id
joint_id
Definition: append-urdf-model-with-another-model.py:34
BENCHMARK_DEFINE_F
BENCHMARK_DEFINE_F(JacobianFixture, FORWARD_KINEMATICS_Q)(benchmark
Definition: timings-jacobian.cpp:55
jacobian.hpp
pinocchio::ModelTpl< context::Scalar, context::Options >
pinocchio::ModelTpl::njoints
int njoints
Number of joints.
Definition: multibody/model.hpp:107


pinocchio
Author(s):
autogenerated on Thu Apr 10 2025 02:42:22