I am now trying to use rosserial_windows to generate these headers for use with a Windows client. Using the conventional make_libraries.py script, the generated header has this line instead:
enum { ANGLE_MAX = 9.6 };
Needless to say, the compiler complained because there's no such thing as a float value in an enum.
After some investigation, I looked in rosserial/rosserial_client/src/rosserial_client/make_library.py and found this block of code:
if value != None:
self.enums.append( EnumerationType(name, ty, value))
continue
which apparently considers any variable with a constant value assigned to it as an enum type, regardless of the variable data type. This means that float constants are always declared as enums. Shouldn't there be a check for the data type before declaring it an enum?
I faced this issue on ROS Melodic, but taking a quick look in the noetic-devel branch I see that the above block of code still exists.
I have a .msg that defines the maximum value for a certain input as a constant float value, as follows:
float32 ANGLE_MAX=9.6 # rad, maximum angle
When building the code on the ROS side, the generated header file handles this okay:
I am now trying to use rosserial_windows to generate these headers for use with a Windows client. Using the conventional make_libraries.py script, the generated header has this line instead:
enum { ANGLE_MAX = 9.6 };
Needless to say, the compiler complained because there's no such thing as a float value in an enum.
After some investigation, I looked in rosserial/rosserial_client/src/rosserial_client/make_library.py and found this block of code:
which apparently considers any variable with a constant value assigned to it as an enum type, regardless of the variable data type. This means that float constants are always declared as enums. Shouldn't there be a check for the data type before declaring it an enum?
I faced this issue on ROS Melodic, but taking a quick look in the noetic-devel branch I see that the above block of code still exists.