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!
Originally posted by Javier V. Gómez on ROS Answers with karma: 1305 on 2015-07-22
Post score: 0
Original comments
Comment by Javier V. Gómez on 2015-07-22:
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.
Comment by gvdhoorn on 2015-07-22:
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.
Comment by Javier V. Gómez on 2015-07-22:
There will be 2 conversions per type, but if I use many types, like Vector, Matrix, Quaternion, etc, there would be lots of conversions.
Comment by dornhege on 2015-07-22:
For exactly these types there are already conversion packages to tf, Eigen.
Comment by Javier V. Gómez on 2015-07-22:
Those are just an example (those are not self-defined messages). But in any case this post is about the practice of avoiding conversions.