pymoos2 logo: a moose head joined to the Python snake mark, beside the word pymoos2.

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

Getting it

pip install pymoos2

MIT license. pymoos2 on PyPI.

People

Lead: Raymond Turrisi

Related

← Back to Software