From c2b61ed443e408bbc5566fb272b866693e970cf3 Mon Sep 17 00:00:00 2001 From: brainiac-ws Date: Fri, 29 Jan 2021 15:12:50 -0800 Subject: [PATCH] Add --world option for demo command line arg World command line spec overrides that used in config yaml file. This makes it easier to run the demos without having to modify the demo_control_cfg yaml file. --- demos/README.md | 1 + demos/demo.py | 3 +++ demos/run_gc_demo.py | 3 ++- demos/run_jointimp_demo.py | 2 ++ demos/run_osc_line_demo.py | 1 + demos/run_osc_rot_demo.py | 2 ++ demos/run_osc_square_demo.py | 3 +++ 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/demos/README.md b/demos/README.md index a9f8c2bf..674a7f5c 100644 --- a/demos/README.md +++ b/demos/README.md @@ -50,6 +50,7 @@ You can see the valid command line args for a demo with: The parameters general to all demos are listed here: + --world (str): (Optional) World to use for demo (Bullet or Real). If not defined, spec from config yaml file is used. --ctrl_type (str): Controller type for the demo. --demo_type (str): Type of demo to perform. --test_fn (str): RobotInterface function environment will use to perform actions. Specific to controller type. diff --git a/demos/demo.py b/demos/demo.py index ee7d8311..f428d338 100644 --- a/demos/demo.py +++ b/demos/demo.py @@ -42,6 +42,9 @@ def __init__(self, # Overwrite config file controlType self.config = YamlConfig(self.config_file) self.config['world']['controlType'] = self.ctrl_type + # Use command line argument over the config spec. + if kwargs['world'] is not None: + self.config['world']['type'] = kwargs['world'] self.demo_type = demo_type self.test_fn = test_fn diff --git a/demos/run_gc_demo.py b/demos/run_gc_demo.py index 5e7142c0..a42e9f4c 100644 --- a/demos/run_gc_demo.py +++ b/demos/run_gc_demo.py @@ -8,7 +8,8 @@ parser = argparse.ArgumentParser( description="Test controllers and measure errors.") - +parser.add_argument('--world', default=None, + help='World type for the demo, uses config file if not specified', choices=['Bullet', 'Real']) parser.add_argument('--num_steps', default=500, type=int, help="max steps for demo.") parser.add_argument('--plot_pos', action="store_true", diff --git a/demos/run_jointimp_demo.py b/demos/run_jointimp_demo.py index 41b9a3c3..895326b0 100644 --- a/demos/run_jointimp_demo.py +++ b/demos/run_jointimp_demo.py @@ -5,6 +5,8 @@ parser = argparse.ArgumentParser( description="Test controllers and measure errors.") +parser.add_argument('--world', default=None, help='World type for the demo, uses config file if not specified', choices=['Bullet', 'Real']) + parser.add_argument('--delta_val', default=0.01, type=float, help="Max step size (m or rad) to take for demo.") diff --git a/demos/run_osc_line_demo.py b/demos/run_osc_line_demo.py index f66232d1..89fcc16a 100644 --- a/demos/run_osc_line_demo.py +++ b/demos/run_osc_line_demo.py @@ -7,6 +7,7 @@ parser = argparse.ArgumentParser( description="Run OpSpace Line Demo in XYZ directions") +parser.add_argument('--world', default=None, help='World type for the demo, uses config file if not specified', choices=['Bullet', 'Real']) parser.add_argument('--ctrl_type', default="EEImpedance", help='Type of controller to test', diff --git a/demos/run_osc_rot_demo.py b/demos/run_osc_rot_demo.py index 1c628c3e..7499e1fc 100644 --- a/demos/run_osc_rot_demo.py +++ b/demos/run_osc_rot_demo.py @@ -7,6 +7,8 @@ parser = argparse.ArgumentParser( description="Run OpSpace Line Demo in XYZ directions") +parser.add_argument('--world', default=None, help='World type for the demo, uses config file if not specified', choices=['Bullet', 'Real']) + parser.add_argument('--ctrl_type', default="EEImpedance", help='Type of controller to test', diff --git a/demos/run_osc_square_demo.py b/demos/run_osc_square_demo.py index 02f5b693..760b7696 100644 --- a/demos/run_osc_square_demo.py +++ b/demos/run_osc_square_demo.py @@ -6,6 +6,9 @@ parser = argparse.ArgumentParser( description="Run OpSpace Square Demo ") +parser.add_argument('--world', default=None, + help='World type for the demo, uses config file if not specified', choices=['Bullet', 'Real']) + parser.add_argument('--ctrl_type', default="EEImpedance", help='Type of controller to test',