From e67e4cd41dee96fae3ec0bf815e46f8c867fe0d9 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sun, 9 Feb 2025 11:53:12 -0500 Subject: [PATCH] parse command line arguments --- examples/plot_city10000.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/plot_city10000.py b/examples/plot_city10000.py index c914e22bc..e4e2805a6 100644 --- a/examples/plot_city10000.py +++ b/examples/plot_city10000.py @@ -8,15 +8,28 @@ See LICENSE for the license information Script to plot City10000 results. Can be used to plot results from both C++ and python scripts. -python plot_city10000.py +python plot_city10000.py Data/ISAM2_GT_city10000.txt ../build/examples/ISAM2_city10000.txt ../build/examples/Hybrid_City10000.txt Author: Varun Agrawal """ +import argparse + import numpy as np from matplotlib import pyplot as plt +def parse_args(): + """Parse command line arguments""" + parser = argparse.ArgumentParser() + parser.add_argument("ground_truth", help="The ground truth data file.") + parser.add_argument( + "estimates", + nargs='+', + help="File(s) with estimates (as .txt), can be more than one.") + return parser.parse_args() + + def plot_estimates(gt, estimates, fignum: int, @@ -42,15 +55,13 @@ def plot_estimates(gt, def main(): - gt = np.loadtxt('Data/ISAM2_GT_city10000.txt', delimiter=" ") + gt = np.loadtxt('', delimiter=" ") # Generate by running `make ISAM2_City10000.run` - eh_poses = np.loadtxt('../build/examples/ISAM2_city10000.txt', - delimiter=" ") + eh_poses = np.loadtxt('', delimiter=" ") # Generate by running `make Hybrid_City10000.run` - h_poses = np.loadtxt('../build/examples/Hybrid_City10000.txt', - delimiter=" ") + h_poses = np.loadtxt('', delimiter=" ") # Plot the same number of GT poses as estimated ones gt = gt[:h_poses.shape[0], :]