model-checker.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2025 INRIA
3 //
4 
5 #ifndef __pinocchio_python_utils_model_checker_hpp__
6 #define __pinocchio_python_utils_model_checker_hpp__
7 
8 #include <Python.h>
9 #include <string>
10 
13 
14 namespace pinocchio
15 {
16  namespace python
17  {
18 
19  // Checker Policy to make a safe version of python function, concerning joint mimic.
20  // This will throw a runtime error in case algorithm does not allow joint mimic in the model.
21  template<class Policy = boost::python::default_call_policies>
23  {
24  mimic_not_supported_function(size_t model_idx_)
25  : Policy()
26  , model_idx(model_idx_)
27  {
28  }
29 
30  template<class ArgumentPackage>
31  bool precall(ArgumentPackage const & args) const
32  {
33  // Convert the object to a tuple
34  boost::python::tuple py_args = boost::python::extract<boost::python::tuple>(args);
35 
36  context::Model m = boost::python::extract<context::Model>(py_args[model_idx]);
37  if (!m.check(MimicChecker()))
38  {
39  PyErr_SetString(PyExc_RuntimeError, m_error_message.c_str());
40  return false;
41  }
42  else
43  return static_cast<const Policy *>(this)->precall(args);
44  }
45 
46  protected:
47  static const std::string m_error_message;
48  // index of the pinocchio in the function arguments. Need it to avoid a loop
49  const size_t model_idx;
50  };
51 
52  template<class Policy>
54  "This algorithm does not support Joint Mimic type in the model.";
55  } // namespace python
56 } // namespace pinocchio
57 #endif // model_checker
pinocchio::python::mimic_not_supported_function::m_error_message
static const std::string m_error_message
Definition: model-checker.hpp:47
test-cpp2pybind11.m
m
Definition: test-cpp2pybind11.py:25
pinocchio::python::mimic_not_supported_function::model_idx
const size_t model_idx
Definition: model-checker.hpp:49
pinocchio::python::mimic_not_supported_function::mimic_not_supported_function
mimic_not_supported_function(size_t model_idx_)
Definition: model-checker.hpp:24
pinocchio::python::mimic_not_supported_function::precall
bool precall(ArgumentPackage const &args) const
Definition: model-checker.hpp:31
args
args
python
check-model.hpp
pinocchio::python::mimic_not_supported_function
Definition: model-checker.hpp:22
fwd.hpp
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:33


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