Skip to content

Commit

Permalink
update launch file
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-labs committed Oct 1, 2024
1 parent 27eccfe commit 8154a1e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
14 changes: 10 additions & 4 deletions docs/how_to_run.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,29 @@ Override scenario parameters

To override scenario parameters, specify the required parameters within a yaml file and use the command-line parameter ``--scenario-parameter-file``.

Let's look at the following example scenario ``my_scenario.osc`` with the parameter ``my_param``.
Let's look at the following example scenario ``my_scenario.osc`` with the parameter ``my_base_param`` and ``my_struct_param``.

.. code-block::
import osc.helpers
scenario my_scenario:
my_param: string = "default value"
my_base_param: string = "default value"
my_struct_param: position_3d
do serial:
log(my_param)
log(my_base_param)
log(my_struct_param)
To override the parameter, the following yaml file ``overrides.yaml`` can be used.

.. code-block:: yaml
my_scenario:
my_param: "my_val"
my_base_param: "my_val"
my_struct_param:
x: 1.0
y: 2.0
z: 0.0
The following command executes the scenario with the defined override.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ModelFileLoader(object):
def __init__(self, logger) -> None:
self.logger = logger

def process_file(self, file_name, log_tree: bool = False, debug: bool = False, _ = None):
def process_file(self, file_name, log_tree: bool = False, debug: bool = False, _=None):
model = self.load_file(file_name, log_tree)
tree = py_trees.composites.Sequence(name="", memory=True)
resolve_internal_model(model, tree, self.logger, log_tree)
Expand Down
5 changes: 4 additions & 1 deletion scenario_execution_ros/launch/scenario_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def generate_launch_description():
scenario_execution = LaunchConfiguration('scenario_execution')
scenario_status = LaunchConfiguration('scenario_status')
output_dir = LaunchConfiguration('output_dir')
scenario_parameter_file = LaunchConfiguration('scenario_parameter_file')

return LaunchDescription([
DeclareLaunchArgument('scenario', description='Scenario file to execute'),
Expand All @@ -48,6 +49,7 @@ def generate_launch_description():
DeclareLaunchArgument('log_level', default_value='info',
description='Log level for scenario execution'),
DeclareLaunchArgument('output_dir', description='Output directory', default_value=''),
DeclareLaunchArgument('scenario_parameter_file', description='Yaml file specifying scenario parameter overrides', default_value=''),

Node(
condition=IfCondition(scenario_execution),
Expand All @@ -63,7 +65,8 @@ def generate_launch_description():
'live_tree': live_tree,
'log_model': log_model,
'output_dir': output_dir,
'scenario': scenario
'scenario': scenario,
'scenario_parameter_file': scenario_parameter_file
}],
on_exit=Shutdown()),

Expand Down

0 comments on commit 8154a1e

Please sign in to comment.