Overload operators for self-defined messages
Is it possible to overload operators for self-defined ROS messages? Say I have a vector message and I want to implement the multiplication by a scalar value.
EDIT: I know I can do it, as they are just classes, and they will be available at building time. But I was wondering what problems can occur and if this is a bad practice.
Thanks!
This is because I want to avoid doing a lot of conversions between for example pose msgs and pose representation to operate on them. It will have small impact on performance, but the lines of code will be reduced, together with "error-proneness" when coding.
Wouldn't there be only a conversion at the 'entrance' and at the 'exit' of your business logic?
In any case: it is actually 'accepted practice' to convert stuff to-and-fro ROS msgs. See fi tf2 and its many
tf2_bullet
,tf2_kdl
etc conversion pkgs.There will be 2 conversions per type, but if I use many types, like Vector, Matrix, Quaternion, etc, there would be lots of conversions.
For exactly these types there are already conversion packages to tf, Eigen.
Those are just an example (those are not self-defined messages). But in any case this post is about the practice of avoiding conversions.