pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
namespace.hpp
1//
2// Copyright (c) 2019-2021 INRIA
3//
4
5#pragma once
6
7#include <boost/python.hpp>
8#include <string>
9
10namespace pinocchio
11{
12 namespace python
13 {
14
18 inline std::string getCurrentScopeName()
19 {
20 namespace bp = boost::python;
21 bp::scope current_scope;
22
23 return std::string(bp::extract<const char *>(current_scope.attr("__name__")));
24 }
25
33 inline boost::python::object getOrCreatePythonNamespace(const std::string & submodule_name)
34 {
35 namespace bp = boost::python;
36
37 const std::string complete_submodule_name = getCurrentScopeName() + "." + submodule_name;
38
39 bp::object submodule(bp::borrowed(PyImport_AddModule(complete_submodule_name.c_str())));
40 bp::scope current_scope;
41 current_scope.attr(submodule_name.c_str()) = submodule;
42
43 return submodule;
44 }
45 } // namespace python
46} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11