ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
517 stars 525 forks source link

Information: python reserved keyword can not be used as msg variable name #542

Open rahuldeo2047 opened 3 years ago

rahuldeo2047 commented 3 years ago

I stuck with it for few 10 minutes. I thought I should keep this information here if it helps. It may seem very natural not to use the python keyword as any variable name in python or msg.

However, unknowingly, I tried making a custom msg and used it inside another custom msg. (Not relevant) As I have given the name as 'in' (as I am mostly coding in c/cpp) the msg was not being created.

However, this issue could be with any variable in msg, given reserved python keyword. It will not be able to make a msg for Arduino or so.

msg example

int32 in
int32 out

The error msg will look like this:

$ rosrun rosserial_stm32f1 make_libraries.py (.... rest of the args)
Traceback (most recent call last):
  File "make_libraries.py", line 101, in <module>
    rosserial_generate(rospack, path+"/Inc/", ROS_TO_EMBEDDED_TYPES)
  File "rosserial_client/make_library.py", line 571, in rosserial_generate
    raise Exception("Failed to generate libraries for: " + str(failed))
Exception: Failed to generate libraries for: ['crazy_msgs (invalid syntax (_crazy_msg.py, line 112))']

Hope it helps someone.