PyShape.cpp
Go to the documentation of this file.
1 #include "PyShape.h"
2 #include "PyUtil.h"
3 
5 {
6  boost::python::list retval;
7  VectorToPyList(getPosition(), retval);
8  return boost::python::incref(retval.ptr());
9 }
10 
11 void PyShape::setRelPosition(PyObject *v)
12 {
13  if (PySequence_Size(v) != 3) return;
15  PyListToVector(v, b);
17 }
18 
20 {
21  boost::python::list retval;
23  Matrix33ToPyList(Rs, retval);
24  return boost::python::incref(retval.ptr());
25 }
26 
27 void PyShape::setRelRotation(PyObject *v)
28 {
29  int n = PySequence_Size(v);
30  hrp::Matrix33 Rs;
31  if (n == 9){
32  PyListToMatrix33(v, Rs);
33  }else if (n == 4){
34  hrp::Vector3 axis;
35  for (int i=0; i<3; i++) {
36  axis(i) = boost::python::extract<double>(PySequence_GetItem(v, i));
37  }
38  double angle = boost::python::extract<double>(PySequence_GetItem(v, 3));
39  hrp::calcRodrigues(Rs, axis, angle);
40  }else if (n == 3){
41  hrp::Vector3 rpy;
42  PyListToVector(v, rpy);
43  hrp::calcRotFromRpy(Rs, rpy[0], rpy[1], rpy[2]);
44  }else{
45  return;
46  }
48 }
49 
51 {
52  boost::python::list retval;
53  for (int i=0; i<4; i++) retval.append(m_diffuse[i]);
54  return boost::python::incref(retval.ptr());
55 }
56 
57 void PyShape::setDiffuseColor(PyObject *v)
58 {
59  if (PySequence_Size(v) != 4) return;
60 
61  for (int i=0; i<PySequence_Size(v); i++) {
62  m_diffuse[i] = boost::python::extract<double>(PySequence_GetItem(v, i));
63  }
64  compile();
65 }
66 
68 {
69  return new PyShape();
70 }
static void Matrix33ToPyList(const hrp::Matrix33 &M, boost::python::list &l)
Definition: PyUtil.h:12
void setRelPosition(PyObject *v)
Definition: PyShape.cpp:11
void compile()
Definition: GLshape.cpp:129
void setRelRotation(PyObject *v)
Definition: PyShape.cpp:27
HRP_UTIL_EXPORT void calcRotFromRpy(Matrix33 &out_R, double r, double p, double y)
GLshape * createPyShape()
Definition: PyShape.cpp:67
png_uint_32 i
hrp::Matrix33 getRotation()
void setRotation(double r, double p, double y)
Eigen::Vector3d Vector3
hrp::Vector3 getPosition()
Eigen::Matrix3d Matrix33
PyObject * getRelRotation()
Definition: PyShape.cpp:19
static void PyListToMatrix33(PyObject *pyo, hrp::Matrix33 &M)
Definition: PyUtil.h:29
void setPosition(double x, double y, double z)
PyObject * getRelPosition()
Definition: PyShape.cpp:4
HRP_UTIL_EXPORT void calcRodrigues(Matrix44 &out_R, const Vector3 &axis, double q)
n
Definition: PyShape.h:7
void VectorToPyList(const T &v, boost::python::list &l)
Definition: PyUtil.h:5
void setDiffuseColor(PyObject *v)
Definition: PyShape.cpp:57
PyObject * getDiffuseColor()
Definition: PyShape.cpp:50
void PyListToVector(PyObject *pyo, T &v)
Definition: PyUtil.h:22
float m_diffuse[4]
Definition: GLshape.h:48


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