Commit b9d06a05 authored by Rohan Budhiraja's avatar Rohan Budhiraja

Fix dynamic-graph-python to use dynamic-graph3 with eigen

parent 68e09d67
language: cpp
sudo: required
compiler:
- gcc
- clang
......@@ -6,7 +7,7 @@ env:
global:
- secure: ECiHIh0aT5ml/MdKifvFIM2UpDWiPsJPEZpafLYM8U0VAPYThSfUe8JWhMsky8amOwm38akbSbr6C7iBKVpzjAqpgNdOdufO1RUZ6pUvtlVXiXTw2KlqPqbDVlD3QroVDhnX/rIRcg5ezEHAIb594uEaHdf8tlikhjdTc3aAgMA=
- APT_DEPENDENCIES="doxygen doxygen-latex libboost-all-dev libeigen3-dev liblapack-dev libblas-dev gfortran python-dev python-sphinx"
- GIT_DEPENDENCIES="jrl-umi3218/jrl-mathtools jrl-umi3218/jrl-mal stack-of-tasks/dynamic-graph"
- GIT_DEPENDENCIES="stack-of-tasks/dynamic-graph"
- LCOV_IGNORE_RULES="*unitTesting*"
allow_failures:
- compiler: clang
......
......@@ -17,6 +17,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/pthread.cmake)
INCLUDE(cmake/cpack.cmake)
include(cmake/header.cmake)
......@@ -47,6 +48,7 @@ PKG_CONFIG_APPEND_LIBS("dynamic-graph-python")
# Search for Boost.
SET(BOOST_COMPONENTS python filesystem system thread program_options unit_test_framework)
SEARCH_FOR_BOOST()
SEARCH_FOR_EIGEN()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
......
......@@ -33,11 +33,11 @@ namespace dynamicgraph {
void fillMatrixRow(Matrix& m, unsigned iRow, PyObject* tuple)
{
if (PyTuple_Size(tuple) != (int)m.nbCols()) {
if (PyTuple_Size(tuple) != (int)m.cols()) {
throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
"lines of matrix have different sizes.");
}
for (unsigned int iCol=0; iCol < m.nbCols(); iCol++) {
for (int iCol=0; iCol < m.cols(); iCol++) {
PyObject* pyDouble = PyTuple_GetItem(tuple, iCol);
if (PyFloat_Check(pyDouble))
m(iRow, iCol) = PyFloat_AsDouble(pyDouble);
......@@ -185,7 +185,7 @@ namespace dynamicgraph {
PyObject* vectorToPython(const Vector& vector)
{
PyObject* tuple = PyTuple_New(vector.size());
for (unsigned int index = 0; index < vector.size(); index++) {
for (int index = 0; index < vector.size() ; index++) {
PyObject* pyDouble = PyFloat_FromDouble(vector(index));
PyTuple_SET_ITEM(tuple, index, pyDouble);
}
......@@ -194,10 +194,10 @@ namespace dynamicgraph {
PyObject* matrixToPython(const Matrix& matrix)
{
PyObject* tuple = PyTuple_New(matrix.nbRows());
for (unsigned int iRow = 0; iRow < matrix.nbRows(); iRow++) {
PyObject* row = PyTuple_New(matrix.nbCols());
for (unsigned iCol=0; iCol < matrix.nbCols(); iCol++) {
PyObject* tuple = PyTuple_New(matrix.rows());
for (int iRow = 0; iRow < matrix.rows(); iRow++) {
PyObject* row = PyTuple_New(matrix.cols());
for (int iCol=0; iCol < matrix.cols(); iCol++) {
PyObject* pyDouble = PyFloat_FromDouble(matrix(iRow, iCol));
PyTuple_SET_ITEM(row, iCol, pyDouble);
}
......@@ -217,7 +217,6 @@ namespace dynamicgraph {
std::string stringValue;
Vector vectorValue;
Matrix matrixValue;
switch(value.type()) {
case (Value::BOOL) :
boolValue = value.value();
......
......@@ -22,6 +22,7 @@
#include <dynamic-graph/command.h>
#include <dynamic-graph/value.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/linear-algebra.h>
#include "convert-dg-to-py.hh"
#include "exception.hh"
......@@ -214,11 +215,9 @@ namespace dynamicgraph {
PyObject* argTuple = NULL;
char* commandName = NULL;
void* pointer = NULL;
if (!PyArg_ParseTuple(args, "OsO", &object, &commandName, &argTuple)) {
return NULL;
}
// Retrieve the entity instance
if (!PyCObject_Check(object)) {
PyErr_SetString(PyExc_TypeError, "first argument is not an object");
......@@ -226,17 +225,14 @@ namespace dynamicgraph {
}
pointer = PyCObject_AsVoidPtr(object);
Entity* entity = (Entity*)pointer;
// Retrieve the argument tuple
if (!PyTuple_Check(argTuple)) {
PyErr_SetString(PyExc_TypeError, "third argument is not a tuple");
return NULL;
}
Py_ssize_t size = PyTuple_Size(argTuple);
std::map<const std::string, Command*> commandMap =
entity->getNewStyleCommandMap();
if (commandMap.count(std::string(commandName)) != 1) {
std::ostringstream oss;
oss << "'" << entity->getName() << "' entity has no command '"
......@@ -255,7 +251,6 @@ namespace dynamicgraph {
PyErr_SetString(dgpyError, ss.str().c_str());
return NULL;
}
std::vector<Value> valueVector;
for (Py_ssize_t iParam=0; iParam<size; iParam++) {
PyObject* PyValue = PyTuple_GetItem(argTuple, iParam);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment