PyUtil.h
Go to the documentation of this file.
1 #ifndef __PYUTIL_H__
2 #define __PYUTIL_H__
3 
4 template<class T>
5 void VectorToPyList(const T& v, boost::python::list &l)
6 {
7  for (int i=0; i<v.size(); i++){
8  l.append(boost::python::object(v[i]));
9  }
10 }
11 
12 static void Matrix33ToPyList(const hrp::Matrix33& M, boost::python::list &l)
13 {
14  for (int i=0; i<3; i++){
15  for (int j=0; j<3; j++){
16  l.append(boost::python::object(M(i,j)));
17  }
18  }
19 }
20 
21 template<class T>
22 void PyListToVector(PyObject *pyo, T& v)
23 {
24  for (int i=0; i<PySequence_Size(pyo); i++) {
25  v[i] = boost::python::extract<double>(PySequence_GetItem(pyo, i));
26  }
27 }
28 
29 static void PyListToMatrix33(PyObject *pyo, hrp::Matrix33& M)
30 {
31  for (int i=0; i<9; i++) {
32  M(i/3, i%3) = boost::python::extract<double>(PySequence_GetItem(pyo, i));
33  }
34 }
35 
36 #endif
static void Matrix33ToPyList(const hrp::Matrix33 &M, boost::python::list &l)
Definition: PyUtil.h:12
png_uint_32 i
Eigen::Matrix3d Matrix33
static void PyListToMatrix33(PyObject *pyo, hrp::Matrix33 &M)
Definition: PyUtil.h:29
def j(str, encoding="cp932")
void VectorToPyList(const T &v, boost::python::list &l)
Definition: PyUtil.h:5
void PyListToVector(PyObject *pyo, T &v)
Definition: PyUtil.h:22


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50