ros-industrial / universal_robot

ROS-Industrial Universal Robots support (https://wiki.ros.org/universal_robot)
1.11k stars 1.04k forks source link

Multiple #defines when using boost and ur_kin.h #217

Closed shaun-edwards closed 9 years ago

shaun-edwards commented 9 years ago

Compiler errors result when the ur_kin.h file is included with boost header files. The error is caused by redefinition of #define macros here.

These macros should be prefixed with a namespace and/or check for previous definition and undef'ed.

de-vri-es commented 9 years ago

There's no real reason to have them as defines, but those are some very dangerously generic names for macros. Undeffing them might have weird effects if boost code uses them (though boost should know better than to use macros with names like that).

The easiest "fix" is to move them to the source file instead of the header since they're not needed in the header anyway. Better yet they can be turned into const doubles in an anonymous namespace in the source file. It should have no noticeable effect in terms of optimization with any modern compiler.

Note that the current interface prevents linking an executable that can do inverse kinematics for more than one arm type. For my own use I changed the kinematics functions to accept a struct containing the kinematic parameters instead.

de-vri-es commented 9 years ago

Actually, after double checking, there are guarantees about using const integral types as compile time constants, but not for doubles. Although I doubt it will make a difference in practise, that could be a reason to use #defines.

Of course, c++11 constexpr would be perfect here if that was allowed.

gavanderhoorn commented 9 years ago

Nothing more than a +1 from me, this is a really nasty issue, just ran into it myself.

fmessmer commented 9 years ago

I (most likely) will be able to test this on Monday...