Open glennib opened 4 years ago
I think this genmsg issue is more appropriate here.
In cases where constants in messages are set to special floats, for example: float32 a = NaN float32 p = Inf float32 n = -Inf The successfully generated Python script declare those as: a = nan p = inf n = -inf However, those causes NameError as nan, inf don't exist. The following works in Python: a = float('nan') p = float('inf') n = float('-inf')
In cases where constants in messages are set to special floats, for example:
float32 a = NaN float32 p = Inf float32 n = -Inf
The successfully generated Python script declare those as:
a = nan p = inf n = -inf
However, those causes NameError as nan, inf don't exist.
The following works in Python:
a = float('nan') p = float('inf') n = float('-inf')
A suggestion is to add the lines
nan = float('nan') inf = float('inf')
at the top of the output of msg_generator: https://github.com/ros/genpy/blob/5008399c9e8f936c0a7067505c2b7cc4c6c09748/src/genpy/generator.py#L817-L821
msg_generator
Another solution would be to have special handling of these types of values at https://github.com/ros/genpy/blob/5008399c9e8f936c0a7067505c2b7cc4c6c09748/src/genpy/generator.py#L864
As stated on the referenced ticket already: please consider to provide a pull request for that enhancement.
I think this genmsg issue is more appropriate here.
A suggestion is to add the lines
at the top of the output of
msg_generator
: https://github.com/ros/genpy/blob/5008399c9e8f936c0a7067505c2b7cc4c6c09748/src/genpy/generator.py#L817-L821Another solution would be to have special handling of these types of values at https://github.com/ros/genpy/blob/5008399c9e8f936c0a7067505c2b7cc4c6c09748/src/genpy/generator.py#L864