-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YarpSensorBridge::getJointPositions() returns an empty vector if jointPositions size is zero #185
Comments
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 |
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 #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) |
See #124 |
The checks added in #946 mitigate the problem. Indeed now an error will be raised in case of wrong size of the vector |
If
jointPositions
size is 0YarpSensorBridge::getJointPositions()
return an empty vectorhttps://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
apparently the
operator=()
do not resize theeigen::ref
@prashanthr05, @S-Dafarra do you have any clue>
The text was updated successfully, but these errors were encountered: