Closed florent-lamiraux closed 2 years ago
By the way, I wrote a function that removes a
GeometryObject
instance from aGeometryModel
and removes the corresponding collision pairs. The input of the function is the name of the object. Do you think this function should be added to pinocchio ?
Yes, of course.
Is there any difference between
ngeoms
andgeometryObjects
? If no, the first one should be deprecated and replaced by a const reference to the second one. For some robotics demo, I add and remove geometries from my model and I got confused sincegeometryObjects.erase(it)
needs to be coupled withngeoms--
.
Why not. How do you see the solution?
In class GeometryModel
:
const Index& ngeoms;
and in the constructor:
GeometryModel()
: ngeoms(geometryObjects.size())
, geometryObjects()
, collisionPairs()
{}
If the compiler accepts, this should do the job.
It will lead to some memory leaks I guess, as std::vector<T>::size
follows this signature:
size_type size() const noexcept;
It will lead to some memory leaks I guess, as
std::vector<T>::size
follows this signature:I do not think so. There is no memory allocation involved.
Yes, but the return object is a temporary variable: it is not held by the std::vector object.
Let see what the compiler thinks about it. I will try tomorrow.
Let's then bet a 🍺 dear Florent!?
I think you are right. My solution won't work. Then I will propose a PR to add a method that removes an object. Calling this method, users will not need to handle variable ngeoms
.
https://github.com/stack-of-tasks/pinocchio/blob/593d4d43fded997bb9aa2421f4e55294dbd233c4/src/multibody/geometry.hpp#L168 Is there any difference between
ngeoms
andgeometryObjects
? If no, the first one should be deprecated and replaced by a const reference to the second one. For some robotics demo, I add and remove geometries from my model and I got confused sincegeometryObjects.erase(it)
needs to be coupled withngeoms--
.By the way, I wrote a function that removes a
GeometryObject
instance from aGeometryModel
and removes the corresponding collision pairs. The input of the function is the name of the object. Do you think this function should be added to pinocchio ?