pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
constraint-data-inheritance.hpp
1//
2// Copyright (c) 2025 INRIA
3//
4
5#pragma once
6
7#include <boost/python.hpp>
8#include <eigenpy/exception.hpp>
9#include <eigenpy/eigen-to-python.hpp>
10
11#include "pinocchio/constraints.hpp"
12#include "pinocchio/bindings/python/fwd.hpp"
13#include "pinocchio/bindings/python/utils/macros.hpp"
14
15namespace pinocchio
16{
17 namespace python
18 {
19 namespace bp = boost::python;
20
21 // -----------------------------------------------------------------
22 // Declaration of all inheritance visitor we want to apply
23 // i.e. level of CRTP where member or methods are declared
24 // -----------------------------------------------------------------
25 template<class T, class = void>
27
28 // -----------------------------------------------------------------
29 // The visitor that apply all the possible inheritance
30 // -----------------------------------------------------------------
31 template<class T>
33 : public bp::def_visitor<ConstraintDataInheritancePythonVisitor<T>>
34 {
35 public:
36 template<class PyClass>
37 void visit(PyClass & cl) const
38 {
40 }
41 };
42
43 // -----------------------------------------------------------------
44 // Actual implementation of visitors when there is inheritence
45 // -----------------------------------------------------------------
46 template<class T> // Check inheritence
47 inline constexpr bool inherit_binarykinematic_data_v =
48 std::is_base_of_v<PointConstraintDataBase<T>, T>
49 || std::is_base_of_v<FrameConstraintDataBase<T>, T>;
50
51 template<class T, class> // Default: do nothing
53 : public bp::def_visitor<BinaryKinematicsConstraintDataBasePythonVisitor<T>>
54 {
55 public:
56 template<class PyClass>
57 void visit(PyClass & /*cl*/) const
58 {
59 }
60 };
61
62 template<class T> // SFINAE specialization discard except when inherit
64 T,
65 std::enable_if_t<inherit_binarykinematic_data_v<T>>>
66 : public bp::def_visitor<BinaryKinematicsConstraintDataBasePythonVisitor<T>>
67 {
68 public:
69 template<class PyClass>
70 void visit(PyClass & cl) const
71 {
72 cl.def(bp::init<>(bp::arg("self"), "Default constructor."))
73 .def(
74 bp::init<const typename T::ConstraintModel &>(
75 bp::args("self", "constraint_model"), "From model constructor."))
76 .PINOCCHIO_ADD_PROPERTY(T, constraint_force, "Resulting force.")
77 .PINOCCHIO_ADD_PROPERTY(T, oMc1, "Placement of the constraint frame 1 wrt WORLD.")
78 .PINOCCHIO_ADD_PROPERTY(T, oMc2, "Placement of the constraint frame 2 wrt WORLD.")
79 .PINOCCHIO_ADD_PROPERTY(T, c1Mc2, "Placement of the constraint frame 2 wrt frame 1.")
80 .PINOCCHIO_ADD_PROPERTY(T, constraint_position_error, "Constraint position error.")
81 .PINOCCHIO_ADD_PROPERTY(T, constraint_velocity_error, "Constraint velocity error.")
82 .PINOCCHIO_ADD_PROPERTY(
83 T, constraint_acceleration_error, "Constraint acceleration error.")
84 .PINOCCHIO_ADD_PROPERTY(
85 T, constraint_acceleration_biais_term, "Constraint acceleration term.")
86 .PINOCCHIO_ADD_PROPERTY(T, A1_world, "Transform for joint1 in world frame.")
87 .PINOCCHIO_ADD_PROPERTY(T, A2_world, "Transform for joint2 in world frame.")
88 .PINOCCHIO_ADD_PROPERTY(
89 T, A_world, "Relative Transform between joint1 and joint2 in world frame.")
90 .PINOCCHIO_ADD_PROPERTY(T, A1_local, "Transform for joint1 in local frame.")
91 .PINOCCHIO_ADD_PROPERTY(T, A2_local, "Transform for joint2 in local frame.")
92 .PINOCCHIO_ADD_PROPERTY(
93 T, A_local, "Relative Transform between joint1 and joint2 in local frame.");
94 }
95 };
96 } // namespace python
97} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11