Commit 18ebe0d4 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Guilhem Saurel
Browse files

DynamicPinocchio owns a pinocchio::Data object.

parent 1ef6c7e6
......@@ -17,6 +17,7 @@
/* STD */
#include <string>
#include <map>
#include <memory>
/* SOT */
#include <pinocchio/fwd.hpp>
......@@ -29,6 +30,7 @@
#include <sot/core/matrix-geometry.hh>
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
#include <sot/dynamic-pinocchio/deprecated.hh>
/* PINOCCHIO */
#include <pinocchio/macros.hpp>
......@@ -80,7 +82,7 @@ class SOTDYNAMIC_EXPORT DynamicPinocchio : public dg::Entity {
/* --- MODEL ATRIBUTES --- */
pinocchio::Model* m_model;
pinocchio::Data* m_data;
std::unique_ptr<pinocchio::Data> m_data;
/* --- MODEL ATRIBUTES --- */
......@@ -164,11 +166,15 @@ class SOTDYNAMIC_EXPORT DynamicPinocchio : public dg::Entity {
void setModel(pinocchio::Model*);
void setData(pinocchio::Data*);
void createData();
/// \deprecated this function does nothing. This class has its own
/// pinocchio::Data object, which can be access with \ref getData.
void setData(pinocchio::Data*) SOT_DYNAMIC_PINOCCHIO_DEPRECATED;
pinocchio::Model* getModel() { return m_model; };
pinocchio::Data* getData() { return m_data; };
pinocchio::Data* getData() { return m_data.get(); };
/* --- GETTERS --- */
......
......@@ -20,6 +20,7 @@ BOOST_PYTHON_MODULE(wrap)
bp::make_function(&dgs::DynamicPinocchio::getData, reference_existing_object()),
bp::make_function(&dgs::DynamicPinocchio::setData))
.def("setModel", &dgs::DynamicPinocchio::setModel)
.def("createData", &dgs::DynamicPinocchio::createData)
.def("setData", &dgs::DynamicPinocchio::setData)
;
}
......@@ -35,7 +35,7 @@ const std::string dg::sot::DynamicPinocchio::CLASS_NAME = "DynamicPinocchio";
DynamicPinocchio::DynamicPinocchio(const std::string& name)
: Entity(name),
m_model(NULL),
m_data(NULL)
m_data()
,
jointPositionSIN(NULL, "sotDynamicPinocchio(" + name + ")::input(vector)::position"),
......@@ -241,9 +241,15 @@ void DynamicPinocchio::setModel(pinocchio::Model* modelPtr) {
if (pinocchio::nq(this->m_model->joints[i]) == 4) // Spherical Joint Only
sphericalJoints.push_back(pinocchio::idx_v(this->m_model->joints[i]));
}
createData();
}
void DynamicPinocchio::setData(pinocchio::Data* dataPtr) { this->m_data = dataPtr; }
void DynamicPinocchio::setData(pinocchio::Data*) {}
void DynamicPinocchio::createData() {
m_data.reset(new pinocchio::Data (*m_model));
}
/*--------------------------------GETTERS-------------------------------------------*/
......
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