aligator
0.19.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Toggle main menu visibility
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1
3
#pragma once
4
5
#include <eigenpy/registration.hpp>
6
#include <boost/python.hpp>
7
8
namespace
aligator
{
9
namespace
python
{
10
namespace
bp = boost::python;
11
12
inline
std::string
get_scope_name
(bp::scope scope) {
13
return
std::string(bp::extract<const char *>(scope.attr(
"__name__"
)));
14
}
15
22
inline
bp::object
get_namespace
(
const
std::string &name) {
23
bp::scope cur_scope;
// current scope
24
const
std::string complete_name =
get_scope_name
(cur_scope) +
"."
+ name;
25
bp::object submodule(bp::borrowed(PyImport_AddModule(complete_name.c_str())));
26
cur_scope.attr(name.c_str()) = submodule;
27
return
submodule;
28
}
29
30
template
<
typename
T>
bool
register_enum_symlink
(
bool
export_values) {
31
namespace
bp = boost::python;
32
namespace
converter = bp::converter;
33
if
(eigenpy::register_symbolic_link_to_registered_type<T>()) {
34
const
bp::type_info info = bp::type_id<T>();
35
const
converter::registration *reg = converter::registry::query(info);
36
bp::object class_obj(bp::handle<>(reg->get_class_object()));
37
bp::enum_<T> &as_enum =
static_cast<
bp::enum_<T> &
>
(class_obj);
38
if
(export_values)
39
as_enum.export_values();
40
return
true
;
41
}
42
return
false
;
43
}
44
45
}
// namespace python
46
}
// namespace aligator
aligator::python
The Python bindings.
Definition
blk-matrix.hpp:7
aligator::python::get_namespace
bp::object get_namespace(const std::string &name)
Create or retrieve a Python scope (that is, a class or module namespace).
Definition
utils.hpp:22
aligator::python::get_scope_name
std::string get_scope_name(bp::scope scope)
Definition
utils.hpp:12
aligator::python::register_enum_symlink
bool register_enum_symlink(bool export_values)
Definition
utils.hpp:30
aligator
Main package namespace.
Definition
action-model-wrap.hpp:14
bindings
python
include
aligator
python
utils.hpp
Generated by
1.17.0