-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from husarion/test-gazebo
Test gazebo
- Loading branch information
Showing
19 changed files
with
734 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[develop] | ||
script_dir=$base/lib/rosbot_xl_gazebo | ||
[install] | ||
install_scripts=$base/lib/rosbot_xl_gazebo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2023 Husarion | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
from glob import glob | ||
from setuptools import find_packages, setup | ||
|
||
package_name = "rosbot_xl_gazebo" | ||
|
||
setup( | ||
name=package_name, | ||
version="0.8.2", | ||
packages=find_packages(exclude=["test"]), | ||
data_files=[ | ||
("share/ament_index/resource_index/packages", ["resource/" + package_name]), | ||
("share/" + package_name, ["package.xml"]), | ||
(os.path.join("share", package_name, "launch"), glob("launch/*.launch.py")), | ||
], | ||
install_requires=["setuptools"], | ||
zip_safe=True, | ||
maintainer="Husarion", | ||
maintainer_email="contact@husarion.com", | ||
description="Gazebo Ignition simulation for ROSbot XL", | ||
license="Apache License 2.0", | ||
tests_require=["pytest"], | ||
entry_points={ | ||
"console_scripts": [], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_copyright.main import main | ||
import pytest | ||
|
||
|
||
@pytest.mark.copyright | ||
@pytest.mark.linter | ||
def test_copyright(): | ||
rc = main(argv=[".", "test"]) | ||
assert rc == 0, "Found errors" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Copyright 2021 Open Source Robotics Foundation, Inc. | ||
# Copyright 2023 Intel Corporation. All Rights Reserved. | ||
# Copyright 2023 Husarion | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import launch_pytest | ||
import pytest | ||
import rclpy | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
from launch import LaunchDescription | ||
from launch.actions import IncludeLaunchDescription | ||
from launch.substitutions import PathJoinSubstitution | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
|
||
from test_utils import SimulationTestNode | ||
from test_ign_kill_utils import kill_ign_linux_processes | ||
|
||
|
||
@launch_pytest.fixture | ||
def generate_test_description(): | ||
rosbot_xl_gazebo = get_package_share_directory("rosbot_xl_gazebo") | ||
simulation_launch = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
PathJoinSubstitution( | ||
[ | ||
rosbot_xl_gazebo, | ||
"launch", | ||
"simulation.launch.py", | ||
] | ||
) | ||
), | ||
launch_arguments={ | ||
"headless": "True", | ||
}.items(), | ||
) | ||
|
||
return LaunchDescription([simulation_launch]) | ||
|
||
|
||
@pytest.mark.launch(fixture=generate_test_description) | ||
def test_diff_drive_simulation(): | ||
rclpy.init() | ||
try: | ||
node = SimulationTestNode("test_bringup") | ||
node.create_test_subscribers_and_publishers() | ||
node.start_node_thread() | ||
|
||
flag = node.odom_tf_event.wait(timeout=60.0) | ||
assert ( | ||
flag | ||
), "Expected odom to base_link tf but it was not received. Check robot_localization!" | ||
|
||
# 0.9 m/s and 3.0 rad/s are controller's limits defined in | ||
# rosbot_controller/config/diff_drive_controller.yaml | ||
node.set_destination_speed(0.9, 0.0, 0.0) | ||
controller_flag = node.controller_odom_event.wait(timeout=20.0) | ||
ekf_flag = node.ekf_odom_event.wait(timeout=20.0) | ||
assert ( | ||
controller_flag | ||
), "ROSbot does not move properly in x direction. Check rosbot_xl_base_controller!" | ||
assert ekf_flag, "ROSbot does not move properly in x direction. Check ekf_filter_node!" | ||
|
||
node.set_destination_speed(0.0, 0.0, 3.0) | ||
controller_flag = node.controller_odom_event.wait(timeout=20.0) | ||
ekf_flag = node.ekf_odom_event.wait(timeout=20.0) | ||
assert controller_flag, "ROSbot does not rotate properly. Check rosbot_xl_base_controller!" | ||
assert ekf_flag, "ROSbot does not rotate properly. Check ekf_filter_node!" | ||
|
||
flag = node.scan_event.wait(timeout=20.0) | ||
assert flag, "ROSbot's lidar does not work properly!" | ||
|
||
finally: | ||
# The pytest cannot kill properly the Gazebo Ignition's tasks what blocks launching | ||
# several tests in a row. | ||
kill_ign_linux_processes() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2017 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ament_flake8.main import main_with_errors | ||
import pytest | ||
|
||
|
||
@pytest.mark.flake8 | ||
@pytest.mark.linter | ||
def test_flake8(): | ||
rc, errors = main_with_errors(argv=[]) | ||
assert rc == 0, "Found %d code style errors / warnings:\n" % len(errors) + "\n".join(errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2023 Husarion | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import subprocess | ||
|
||
# The pytest cannot kill properly the Gazebo Ignition's tasks what blocks launching | ||
# several tests in a row. | ||
|
||
|
||
def kill_ign_linux_processes(): | ||
try: | ||
result = subprocess.run( | ||
["pgrep", "-f", "ign gazebo"], | ||
capture_output=True, | ||
text=True, | ||
check=True, | ||
) | ||
|
||
pids = result.stdout.strip().split("\n") | ||
for pid in pids: | ||
subprocess.run(["kill", pid], check=True) | ||
print("Killed all Ignition Gazebo processes") | ||
except subprocess.CalledProcessError as e: | ||
print(e) | ||
|
||
|
||
kill_ign_linux_processes() |
Oops, something went wrong.