toppra icon indicating copy to clipboard operation
toppra copied to clipboard

parametrizer->dof() returns undefined value

Open maxpla3 opened this issue 1 year ago • 1 comments

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 avatar Apr 20 '23 13:04 maxpla3

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(...)

maxpla3 avatar Apr 20 '23 14:04 maxpla3