Unittesting ROS in python

Setting up unit tests for ROS python modules is a little tricky, but once it’s in place you can easily automate testing of ros nodes.

Here is a very brief reference.

Read more

PyCharm type hints

For class variables that get assigned:

def foo():
#: :type: ObservablePlanarGraph
self._graph = graph

For input variables (in a docstring):

def foo(self, feature_finder):
:type feature_finder FeatureFinder

For return types (also note, tuples and lists):

def foo(self):
:rtype (list[PolicyData], list[PolicyData])

return res

File prepending magic

To prepend some text at the start of each file, use sed:

sed -i '1i <pattern>' <files>

Useful examples:

Add emacs headers for LaTeX mode:

sed -i '1i % -*- mode:LaTeX; mode:visual-line; mode:flyspell -*-' *.tex