hungpham2511 / toppra

robotic motion planning library
https://hungpham2511.github.io/toppra/index.html
MIT License
603 stars 167 forks source link

parametrizer->dof() returns undefined value #231

Open maxpla3 opened 1 year ago

maxpla3 commented 1 year ago

Calling parametrizer->dof() returns undefined value.

GeometricPathPtr geo_path       = std::make_shared<ToppRaGeometricPathWrapper>(path);
LinearConstraintPtrs lin_constr = FromConstraints(constraints);
algorithm::TOPPRA toppra_algo   = algorithm::TOPPRA(lin_constr, geo_path);

int dof_test_1 = geo_path->dof(); // yields 4

toppra_algo.computePathParametrization(0, 0);
const Vector& gridpoints = toppra_algo.getParameterizationData().gridpoints;
const Vector& vsquared   = toppra_algo.getParameterizationData().parametrization;

parametrizer_ = std::make_shared<parametrizer::ConstAccel>(geo_path, gridpoints, vsquared);

int dof_test_2 = geo_path->dof(); // yields -842150451

dof_test_1 equals 4 (correct value in the test scenario)

dof_test_2 equals -842150451

maxpla3 commented 1 year ago

Solutions:

Either override int GeometricPath::dof() const { return m_dof; } with int Parametrizer::dof() const { return m_path->dof(); }

or (probably better, since this prevents uninitialized values) add

m_dof = path->dof();
m_configSize = path->configSize();

in the constructor Parametrizer(...)