Open GiulioRomualdi opened 3 years ago
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
If
jointPositions
size is 0YarpSensorBridge::getJointPositions()
return an empty vector https://github.com/dic-iit/bipedal-locomotion-framework/blob/e2385fc708e4bbb2d4b2553601f3ffdd735d976d/src/RobotInterface/YarpImplementation/src/YarpSensorBridge.cpp#L235-L242The code does not crash if compiled in release, if it's compiled in debug the following exception is thrown
apparently the
operator=()
do not resize theeigen::ref
@prashanthr05, @S-Dafarra do you have any clue>