What I learned in ROS this week
Messages:
In a discussion with members of OSRF (https://github.com/ros/std_msgs/issues/7#issuecomment-59396705) I learned that std_msgs shouldn’t really be used as stand alone message types directly on topics as they contain no semantic information describing what they are. Rather you should use custom message types.
- UDPROS (http://wiki.ros.org/ROS/UDPROS) - This should use a broadcast type system, so there should be no blocking or sequential calls
- in the callback functions of your subscribers, just grab the data and store it, don’t process it at this time. Rather, either kick off another thread to handle the processing, or have a single thread which triggers regularly and grabs the latest data from wherever you’ve stashed it.
- First submit an issue, talk to the owners of the repo, and see if they will approve the request before you go write a whole bunch of code that may or may not ever be accepted.
- Use the same docstring format to comment your code as the file you are editing. At least ros_comm seems to use the following format: http://epydoc.sourceforge.net/manual-epytext.html
- Write your code as if for Python3. So that means use .values() over .itervalues() as an example.
- Follow PEP8 style guides for spacing, etc. http://legacy.python.org/dev/peps/pep-0008/
- Even if you are just refactoring code, expect it to be treated as new code and scrutinized as such, even if you didn’t write it.
def foo(my_dict={}, my_list=())
def foo(my_dict=None, my_list=None):my_dict = my_dict or {}my_list = my_list or {}