pinocchio
4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Toggle main menu visibility
Loading...
Searching...
No Matches
list.hpp
1
//
2
// Copyright (c) 2019 INRIA
3
//
4
5
#pragma once
6
7
#include "pinocchio/bindings/python/fwd.hpp"
8
#include "pinocchio/bindings/python/utils/path.hpp"
9
10
#include <eigenpy/exception.hpp>
11
12
#include <boost/python.hpp>
13
#include <boost/python/type_id.hpp>
14
#include <vector>
15
#include <sstream>
16
#include <string>
17
18
namespace
pinocchio
19
{
20
namespace
python
21
{
22
23
template
<
typename
T,
class
Allocator>
24
void
extract(
const
boost::python::list & list, std::vector<T, Allocator> & vec)
25
{
26
namespace
bp = boost::python;
27
28
size_t
size_list = (size_t)bp::len(list);
29
vec.resize(size_list);
30
for
(
size_t
i = 0; i < size_list; ++i)
31
{
32
bp::extract<T> input_T(list[i]);
33
if
(input_T.check())
34
vec[i] = input_T();
35
else
36
{
37
const
std::string classname =
38
bp::extract<std::string>(list[i].attr(
"__class__"
).attr(
"__name__"
));
39
std::stringstream ss;
40
ss <<
"The conversion from "
<< classname <<
" to "
<< bp::type_id<T>().name()
41
<<
" has failed."
<< std::endl;
42
throw
eigenpy::Exception(ss.str());
43
}
44
}
45
}
46
47
template
<
typename
T>
48
std::vector<T> extract(
const
boost::python::list & list)
49
{
50
std::vector<T> vec;
51
extract(list, vec);
52
return
vec;
53
}
54
55
template
<
typename
T,
class
Allocator>
56
std::vector<T, Allocator> extract(
const
boost::python::list & list)
57
{
58
std::vector<T, Allocator> vec;
59
extract(list, vec);
60
return
vec;
61
}
62
63
}
// namespace python
64
}
// namespace pinocchio
pinocchio
Main pinocchio namespace.
Definition
treeview.dox:11
include
pinocchio
bindings
python
utils
list.hpp
Generated by
1.17.0