If jointPositions size is 0 YarpSensorBridge::getJointPositions() return an empty vector
https://github.com/dic-iit/bipedal-locomotion-framework/blob/e2385fc708e4bbb2d4b2553601f3ffdd735d976d/src/RobotInterface/YarpImplementation/src/YarpSensorBridge.cpp#L235-L242
The code does not crash if compiled in release, if it's compiled in debug the following exception is thrown
blf-cartesian-trajectory-player: /usr/include/eigen3/Eigen/src/Core/DenseBase.h:257: void Eigen::DenseBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived = Eigen::Ref<Eigen::Matrix<double, -1, 1> >; Eigen::Index = long int]: Assertion `rows == this->rows() && cols == this->cols() && "DenseBase::resize() does not actually allow one to resize."' failed.
apparently the operator=() do not resize the eigen::ref
@prashanthr05, @S-Dafarra do you have any clue>
Ref, like map or span cannot resize the underlying container because it does not own the memory. This is the reason why GenericContainer::Vector was designed in the first place 馃榿
For the time being, we can add a check into getJointPositions and similar functions
If I remember right, we switched from the usage of GenericContainer to Eigen::Ref and added this warning saying that the user should pass a resized vector.
and looks like the addition of checks were not done in the YarpSensorBridge implementation. So yes, we have to update the code in YarpSensorBridge.
I think that this is strongly related to https://github.com/dic-iit/bipedal-locomotion-framework/issues/95. I think it is necessary to clearly define a guideline.
Otherwise we may change
bool YarpSensorBridge::getJointPositions(Eigen::Ref<Eigen::VectorXd> jointPositions,
double* receiveTimeInSeconds)
into
Eigen::Ref<const Eigen::VectorXd> YarpSensorBridge::getJointPositions(double* receiveTimeInSeconds)
or
GenericVector<const double> YarpSensorBridge::getJointPositions(double* receiveTimeInSeconds)
Otherwise we may change
bool YarpSensorBridge::getJointPositions(Eigen::Ref<Eigen::VectorXd> jointPositions, double* receiveTimeInSeconds)into
Eigen::Ref<const Eigen::VectorXd> YarpSensorBridge::getJointPositions(double* receiveTimeInSeconds)or
GenericVector<const double> YarpSensorBridge::getJointPositions(double* receiveTimeInSeconds)
See https://github.com/dic-iit/bipedal-locomotion-framework/issues/124
Most helpful comment
Ref, like map or span cannot resize the underlying container because it does not own the memory. This is the reason why GenericContainer::Vector was designed in the first place 馃榿