pymoos2 speaks the native MOOSDB wire protocol, so a Python app sits beside
C++ apps under pAntler, shows up in uMAC and pMarineViewer with a full
AppCast, and reads its configuration from the same .moos
mission file. It also parses what other apps publish (VIEW_* geometry,
NODE_REPORT, APPCAST, REALMCAST) and converts positions with PROJ.
pymoos2 is pure Python. Its one dependency is pyproj, which ships binary wheels for Linux (x86_64, aarch64), macOS and Windows. It needs Python 3.8 or newer, and a MOOSDB from moos-ivp to connect to.
A first app
from pymoos2 import AppCastingMOOSApp, ACTable, run
class Doubler(AppCastingMOOSApp):
def on_startup(self):
self.gain = self.config("gain", default=2.0, type=float)
self.nav_x = 0.0
def register_variables(self):
self.register("NAV_X")
def on_new_mail(self, mail):
for msg in mail:
if msg.name == "NAV_X":
self.nav_x = msg.double()
def iterate(self):
self.notify("NAV_X_SCALED", self.nav_x * self.gain)
def build_report(self):
table = ACTable(["Variable", "Value"])
table.add("NAV_X", f"{self.nav_x:.2f}")
self.report(table)
return True
if __name__ == "__main__":
import sys
run(Doubler, "pDoubler", sys.argv[1])
Features
- Configuration from the app's block in the
.moosfile, including repeated keys and top-level keys such asLatOrigin. - AppCasting: exceptions in
iterate()oron_new_mail()are shown as AppCast run warnings, and the app keeps running. - Parsing of VIEW_* geometry, NODE_REPORT, APPCAST and REALMCAST.
- Geodesy with PROJ, for local-grid and latitude/longitude conversions.
- Builds in a moos-ivp extend tree: a Python app lives in
src/beside the C++ apps and builds with the same./build.sh, with generators for new apps.
Getting it
pip install pymoos2
MIT license. pymoos2 on PyPI.
People
Lead: Raymond Turrisi