File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,3 +22,55 @@ cd python-moos
2222python setup.py build
2323python setup.py install
2424```
25+
26+ # Usage
27+
28+ python-moos provides two main classes for interacting with MOOS:
29+
30+ ## pymoos.comms - Asynchronous Communications
31+
32+ For simple publish/subscribe communication with the MOOSDB:
33+
34+ ``` python
35+ import pymoos
36+
37+ comms = pymoos.comms()
38+
39+ def on_connect ():
40+ return comms.register(' MY_VAR' , 0 )
41+
42+ comms.set_on_connect_callback(on_connect)
43+ comms.run(' localhost' , 9000 , ' my_client' )
44+ ```
45+
46+ See ` Documentation/examples/simplecomms.py ` for a complete example.
47+
48+ ## pymoos.app - MOOS Application Framework
49+
50+ For building full MOOS applications with structured lifecycle callbacks:
51+
52+ ``` python
53+ import pymoos
54+
55+ app = pymoos.app()
56+
57+ def on_startup ():
58+ app.set_app_freq(10.0 ) # Hz
59+ return True
60+
61+ def on_connect_to_server ():
62+ return app.register(' MY_VAR' , 0 )
63+
64+ def iterate ():
65+ # Main application loop
66+ return True
67+
68+ app.set_on_start_up_callback(on_startup)
69+ app.set_on_connect_to_server_callback(on_connect_to_server)
70+ app.set_iterate_callback(iterate)
71+
72+ app.run(' localhost' , 9000 , ' my_app' )
73+ ```
74+
75+ See ` Documentation/examples/simpleapp.py ` for a complete example.
76+
You can’t perform that action at this time.
0 commit comments