Skip to content

Commit ed26eb0

Browse files
committed
Controller frequency parameter example
1 parent d27779b commit ed26eb0

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

artefacts.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
- /distance_from_start_gt
4040
- /distance_from_start_est
4141
params:
42-
launch/world: ["bookstore.sdf", "empty.sdf"]
43-
amcl/update_min_a: [0.2, 0.05]
44-
amcl/update_min_d: [0.25, 0.05]
42+
launch/world: ["empty.sdf"]
43+
controller_server/controller_frequency: [10.0, 30.0]
4544
settings:
46-
- name: reach_goal
47-
ros_testfile: "src/sam_bot_nav2_gz/test/test_reach_goal.launch.py"
45+
#- name: reach_goal
46+
# ros_testfile: "src/sam_bot_nav2_gz/test/test_reach_goal.launch.py"
4847
- name: follow_waypoints
4948
ros_testfile: "src/sam_bot_nav2_gz/test/test_follow_waypoints.launch.py"
49+

src/sam_bot_nav2_gz/test/test_follow_waypoints.launch.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@
1515
from artefacts_toolkit.chart import make_chart
1616
from artefacts_toolkit.config import get_artefacts_param
1717

18+
ARTEFACTS_PARAMS_FILE = os.environ.get(
19+
"ARTEFACTS_SCENARIO_PARAMS_FILE", "scenario_params.yaml"
20+
)
21+
22+
def merge_ros_params_files(source, override, destination):
23+
"""Merge two ROS2 yaml parameter files into one, overriding the values in the first one with the values in `override`"""
24+
import yaml
25+
26+
with open(source, "r") as f:
27+
source_params = yaml.safe_load(f)
28+
29+
with open(override, "r") as f:
30+
override_params = yaml.safe_load(f)
31+
32+
# Merge the parameters
33+
for key, value in override_params.items():
34+
if key in source_params:
35+
source_params[key].update(value)
36+
else:
37+
source_params[key] = value
38+
# Write the merged parameters to the destination file
39+
with open(destination, "w") as f:
40+
yaml.dump(source_params, f)
1841

1942
# This function specifies the processes to be run for our test
2043
@pytest.mark.launch_test
@@ -26,6 +49,9 @@ def generate_test_description():
2649
world = "empty.world"
2750

2851
run_headless = LaunchConfiguration("run_headless")
52+
source_params_file = "src/sam_bot_nav2_gz/config/nav2_params.yaml"
53+
new_params_file = "all_params.yaml"
54+
merge_ros_params_files(source_params_file, ARTEFACTS_PARAMS_FILE, new_params_file)
2955
launch_navigation_stack = IncludeLaunchDescription(
3056
PythonLaunchDescriptionSource(
3157
[
@@ -36,7 +62,11 @@ def generate_test_description():
3662
),
3763
]
3864
),
39-
launch_arguments=[("run_headless", run_headless), ("world_file", world)],
65+
launch_arguments=[
66+
("run_headless", run_headless),
67+
("world_file", world),
68+
("params_file", new_params_file),
69+
],
4070
)
4171

4272
follow_waypoints = Node(

src/sam_bot_nav2_gz/test/test_reach_goal.launch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from artefacts_toolkit.chart import make_chart
1515
from artefacts_toolkit.config import get_artefacts_param
1616

17-
1817
# This function specifies the processes to be run for our test
1918
@pytest.mark.launch_test
2019
@launch_testing.markers.keep_alive

0 commit comments

Comments
 (0)