Skip to content

CLI Tools

Usage

The CLI tools use tyro:

  • Positional arguments are passed as positional command line arguments
  • Named arguments are passed as flagged command line arguments

roverd exit

Exit data collection processes and clean up.

Parameters:

Name Type Description Default
config str | None

path to the config file. If None, uses the ROVER_CFG environment variable.

None
Source code in collect/cli.py
def cli_exit(config: str | None = None) -> None:
    """Exit data collection processes and clean up.

    Args:
        config: path to the config file. If `None`, uses the `ROVER_CFG`
            environment variable.
    """
    Controller.from_config(_get_config_path(config)).exit()

roverd get-config

Get the value of a provided path from the target config.

Parameters:

Name Type Description Default
path str

'/'-separated path to the configuration key.

''
config str | None

path to the config file. If None, uses the ROVER_CFG environment variable.

None
Source code in collect/cli.py
def cli_get_config(path: str = '', config: str | None = None) -> None:
    """Get the value of a provided path from the target config.

    Args:
        path: '/'-separated path to the configuration key.
        config: path to the config file. If `None`, uses the `ROVER_CFG`
            environment variable.
    """
    with open(_get_config_path(config)) as f:
        cfg = yaml.safe_load(f)

    try:
        for p in path.split('/'):
            cfg = cfg[p]
        print(cfg)
    except KeyError:
        print("Unknown key:", path)
        exit(-1)

roverd start

Start data collection.

Parameters:

Name Type Description Default
path str

dataset directory.

'./data'
config str | None

path to the config file. If None, uses the ROVER_CFG environment variable.

None
Source code in collect/cli.py
def cli_start(path: str = './data', config: str | None = None) -> None:
    """Start data collection.

    Args:
        path: dataset directory.
        config: path to the config file. If `None`, uses the `ROVER_CFG`
            environment variable.
    """
    config = _get_config_path(config)
    ctrl = Controller.from_config(config)

    dt = datetime.now().strftime("%Y.%m.%d-%H.%M.%S")
    path = os.path.join(os.path.abspath(path), dt)
    os.makedirs(path, exist_ok=True)

    with open(config) as f:
        contents = f.read()
    with open(os.path.join(path, 'config.yaml'), 'w') as f:
        f.write(contents)

    ctrl.start(path)

roverd stop

Stop data collection.

Parameters:

Name Type Description Default
config str | None

path to the config file. If None, uses the ROVER_CFG environment variable.

None
Source code in collect/cli.py
def cli_stop(config: str | None = None) -> None:
    """Stop data collection.

    Args:
        config: path to the config file. If `None`, uses the `ROVER_CFG`
            environment variable.
    """
    Controller.from_config(_get_config_path(config)).stop()

roverd run

Run a sensor data collection process.

Parameters:

Name Type Description Default
config str | None

path to the config file. If None, uses the ROVER_CFG environment variable.

None
sensor str

name of the sensor to run.

'radar'
log_level int

logging level (default=info=20; 0-50).

INFO
Source code in collect/cli.py
def cli_run(
    config: str | None = None, sensor: str = "radar",
    log_level: int = logging.INFO
) -> None:
    """Run a sensor data collection process.

    Args:
        config: path to the config file. If `None`, uses the `ROVER_CFG`
            environment variable.
        sensor: name of the sensor to run.
        log_level: logging level (default=info=20; 0-50).
    """
    config = _get_config_path(config)

    root = logging.getLogger()
    root.setLevel(log_level)

    handler = logging.StreamHandler()
    handler.setFormatter(JsonFormatter())
    root.addHandler(handler)

    path = os.path.abspath(os.path.expanduser(config))
    with open(path) as f:
        try:
            cfg = yaml.load(f, Loader=yaml.FullLoader)[sensor]
        except KeyError:
            root.critical("Sensor '{}' not defined in {}.".format(
                sensor, config))
            exit(-1)

    try:
        roverc.SENSORS[cfg["type"]](name=sensor, **cfg["args"]).loop()
    except Exception as e:
        root.critical("".join(traceback.format_exception(e)))
    except KeyboardInterrupt:
        root.critical("Terminating due to KeyboardInterrupt.")
        exit(0)