This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
cs:coding_conventions:start [2017/04/08 12:44] Brandon Kallaher [All Languages] |
cs:coding_conventions:start [2017/04/08 12:50] (current) Brandon Kallaher |
||
---|---|---|---|
Line 27: | Line 27: | ||
===== Python ===== | ===== Python ===== | ||
- | + | Nodes should be defined in classes with the constructor called in the "main" section. | |
- | + | <code python> | |
- | + | def Node(): | |
- | + | def __init__(): | |
+ | # define pubs and subs here | ||
+ | ... | ||
+ | |||
+ | if __name__=='__main__': | ||
+ | rospy.init_node() | ||
+ | Node() | ||
+ | rospy.spin() | ||
+ | </code> |