Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/port systems tests failure to new gazebo #4453

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nav2_system_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ if(BUILD_TESTING)

add_subdirectory(src/behavior_tree)
add_subdirectory(src/planning)
# Uncomment after https://github.com/ros-navigation/navigation2/pull/3634
add_subdirectory(src/localization)
# add_subdirectory(src/system)
# add_subdirectory(src/system_failure)
add_subdirectory(src/system)
add_subdirectory(src/system_failure)
# Uncomment after https://github.com/ros-navigation/navigation2/pull/3634
# add_subdirectory(src/updown)
# add_subdirectory(src/waypoint_follower)
# add_subdirectory(src/gps_navigation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ def main(argv=sys.argv[1:]):
lts.add_test_action(ld, test1_action)
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return lts.run(ls)
return_code = lts.run(ls)
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
# (TODO ) This is a workaround to kill the gz server after the test
# We noticed that the gz server is not killed after the test
# and it is still running in the background. This affects
# the next test run. This is a temporary fix until we find
# a better way of killing the gz server after the test.
return return_code


if __name__ == '__main__':
Expand Down
3 changes: 0 additions & 3 deletions nav2_system_tests/src/system_failure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ ament_add_test(test_failure_navigator
TIMEOUT 180
ENV
TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}
TEST_MAP=${PROJECT_SOURCE_DIR}/maps/map_circular.yaml
TEST_WORLD=${PROJECT_SOURCE_DIR}/worlds/turtlebot3_ros2_demo.world
GAZEBO_MODEL_PATH=${PROJECT_SOURCE_DIR}/models
BT_NAVIGATOR_XML=navigate_to_pose_w_replanning_and_recovery.xml
)
63 changes: 48 additions & 15 deletions nav2_system_tests/src/system_failure/test_system_failure_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
# limitations under the License.

import os
from pathlib import Path
import sys

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch import LaunchService
from launch.actions import (
AppendEnvironmentVariable,
ExecuteProcess,
IncludeLaunchDescription,
SetEnvironmentVariable,
Expand All @@ -33,20 +35,26 @@
from launch_testing.legacy import LaunchTestService

from nav2_common.launch import RewrittenYaml
from nav2_simple_commander.utils import kill_os_processes


def generate_launch_description():
map_yaml_file = os.getenv('TEST_MAP')
world = os.getenv('TEST_WORLD')
sim_dir = get_package_share_directory('nav2_minimal_tb3_sim')
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
ros_gz_sim_dir = get_package_share_directory('ros_gz_sim')

world_sdf_xacro = os.path.join(sim_dir, 'worlds', 'tb3_sandbox.sdf.xacro')
robot_sdf = os.path.join(sim_dir, 'urdf', 'gz_waffle.sdf')

map_yaml_file = os.path.join(nav2_bringup_dir, 'maps', 'tb3_sandbox.yaml')

bt_navigator_xml = os.path.join(
get_package_share_directory('nav2_bt_navigator'),
'behavior_trees',
os.getenv('BT_NAVIGATOR_XML'),
)

bringup_dir = get_package_share_directory('nav2_bringup')
params_file = os.path.join(bringup_dir, 'params', 'nav2_params.yaml')
params_file = os.path.join(nav2_bringup_dir, 'params', 'nav2_params.yaml')

# Replace the `use_astar` setting on the params file
param_substitutions = {
Expand All @@ -66,15 +74,33 @@ def generate_launch_description():
SetEnvironmentVariable('RCUTILS_LOGGING_BUFFERED_STREAM', '1'),
SetEnvironmentVariable('RCUTILS_LOGGING_USE_STDOUT', '1'),
# Launch gazebo server for simulation
ExecuteProcess(
cmd=[
'gzserver',
'-s',
'libgazebo_ros_init.so',
'--minimal_comms',
world,
],
output='screen',
AppendEnvironmentVariable(
'GZ_SIM_RESOURCE_PATH', os.path.join(sim_dir, 'models')
),
AppendEnvironmentVariable(
'GZ_SIM_RESOURCE_PATH',
str(Path(os.path.join(sim_dir)).parent.resolve())
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(ros_gz_sim_dir, 'launch', 'gz_sim.launch.py')
),
launch_arguments={'gz_args': ['-r -s ', world_sdf_xacro]}.items(),
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(sim_dir, 'launch', 'spawn_tb3.launch.py')
),
launch_arguments={
'use_sim_time': 'True',
'robot_sdf': robot_sdf,
'x_pose': '-2.0',
'y_pose': '-0.5',
'z_pose': '0.01',
'roll': '0.0',
'pitch': '0.0',
'yaw': '0.0',
}.items(),
),
# TODO(orduno) Launch the robot state publisher instead
# using a local copy of TB3 urdf file
Expand All @@ -92,7 +118,7 @@ def generate_launch_description():
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(bringup_dir, 'launch', 'bringup_launch.py')
os.path.join(nav2_bringup_dir, 'launch', 'bringup_launch.py')
),
launch_arguments={
'namespace': '',
Expand Down Expand Up @@ -129,7 +155,14 @@ def main(argv=sys.argv[1:]):
lts.add_test_action(ld, test1_action)
ls = LaunchService(argv=argv)
ls.include_launch_description(ld)
return lts.run(ls)
return_code = lts.run(ls)
# (TODO ) This is a workaround to kill the gz server after the test
# We noticed that the gz server is not killed after the test
# and it is still running in the background. This affects
# the next test run. This is a temporary fix until we find
# a better way of killing the gz server after the test.
kill_os_processes('gz sim')
return return_code


if __name__ == '__main__':
Expand Down
Loading