Skip to content

Commit

Permalink
end2end test can now wait for headless sim to be ready before running…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
tharp789 committed Sep 13, 2024
1 parent de75fe7 commit 367f17d
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 68 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docker/extras/spirit_uav_fire_academy.usd
Binary file not shown.
Binary file modified docker/extras/test_drone_world.usd
Binary file not shown.
22 changes: 22 additions & 0 deletions ros_ws/src/end2end_tests/launch/isaac_test_env_bringup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<launch>
<!-- Test node -->
<node name="end2end_test_node" pkg="end2end_tests" exec="end2end_tester_node.py" output="screen" />

<!-- Simulator -->
<set_env name="OMNI_KIT_ALLOW_ROOT" value="1" />
<node name="isaacsim" pkg="isaacsim" exec="run_isaacsim.py" output="screen">
<param name="install_path" value="/isaac-sim" />
<param name="env_path" value="/extras/spirit_uav_fire_academy.usd" />
<param name="play_sim_on_start" value="true" />
<!-- <param name="headless" value="" /> -->
<param name="headless" value="native" />
<param name="isaac_args" value="--/app/scripting/ignoreWarningDialog=true" />
</node>

<!-- <group>
<set_env name="ROS_DOMAIN_ID" value="1" />
<push_ros_namespace namespace="robot1" />
<include file="$(find-pkg-share central)/launch/ascent_drone_headless.xml" />
</group> -->

</launch>
8 changes: 5 additions & 3 deletions ros_ws/src/end2end_tests/package.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>robot_system_tests</name>
<name>end2end_tests</name>
<version>0.0.0</version>
<description>Tests for the full robot system</description>
<description>Tests in simulation for full systems</description>
<maintainer email="[email protected]">uav</maintainer>
<license>TODO: License declaration</license>

<!-- <buildtool_depend>rclpy</buildtool_depend> -->
<buildtool_depend>ament_python</buildtool_depend>
<exec_depend>rclpy</exec_depend>


<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
Expand Down
46 changes: 24 additions & 22 deletions ros_ws/src/end2end_tests/setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from setuptools import setup, find_packages

package_name = 'end2end_tests'
package_name = "end2end_tests"

setup(
name=package_name,
version='0.0.0',
packages=find_packages(),
data_files=[
('share/' + package_name, ['package.xml']),
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
],
install_requires=['setuptools', 'launch', 'launch_ros', 'launch_testing', 'launch_testing_ros', 'pytest'],
zip_safe=True,
maintainer='TODO',
maintainer_email='TODO',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
# entry_points={
# 'console_scripts': [
# 'my_node = my_py_pkg.my_node:main'
# ],
# },
)
name=package_name,
version="0.0.0",
packages=find_packages(),
data_files=[
("share/" + package_name, ["package.xml"]),
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
("share/" + package_name + "/launch", ["launch/isaac_test_env_bringup.xml"]),
],
install_requires=[
"setuptools",
"launch",
"launch_ros",
"launch_testing",
"launch_testing_ros",
"pytest",
],
zip_safe=True,
maintainer="TODO",
maintainer_email="TODO",
description="Tests in simulation for full systems",
license="TODO: License declaration",
tests_require=["pytest"],
)
7 changes: 0 additions & 7 deletions ros_ws/src/end2end_tests/tests/end2end_tests.py

This file was deleted.

107 changes: 107 additions & 0 deletions ros_ws/src/end2end_tests/tests/test_end2end.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import os
import sys
import time
import unittest
import uuid

import launch
from launch.launch_service import LaunchService
import launch_ros
import launch_ros.actions
import launch_testing.actions
from launch_testing.io_handler import ActiveIoHandler
import launch_testing_ros

import pytest

import rclpy
from rclpy.node import Node

from std_msgs.msg import String

import time

class End2EndTestNode(Node):
def __init__(self):
super().__init__('end2end_test_node')
self.subscription = self.create_subscription(String, '/sim_status', self.sim_status_callback, 10)
self.sim_status = None

def sim_status_callback(self, msg):
self.sim_status = msg.data
self.get_logger().info(f'variable is now: {self.sim_status}')

@pytest.mark.rostest
# this is the test descriptioon used to launch the full robot system with launch_robot_headless.yaml
def generate_test_description():
robot_launch_path = '/root/AirStack/ros_ws/src/end2end_tests/launch/isaac_test_env_bringup.xml'

robot_launch = launch.actions.IncludeLaunchDescription( launch.launch_description_sources.AnyLaunchDescriptionSource(robot_launch_path))

return (
launch.LaunchDescription([
robot_launch,
launch_testing.actions.ReadyToTest(),
]),
{}
)


class TestEnd2End(unittest.TestCase):

@classmethod
def setUpClass(cls):
# Initialize the ROS context for the test node
rclpy.init()

@classmethod
def tearDownClass(cls):
# Shutdown the ROS context
rclpy.shutdown()

def setUp(self):
# Create a ROS node for tests
self.node = End2EndTestNode()

def tearDown(self):
self.node.destroy_node()

def test_wait_for_sim(self, timeout=30):
# Wait for the isaac sim to be available
start_time = time.time()
while time.time() - start_time < timeout:
rclpy.spin_once(self.node)
if self.node.sim_status == "ready":
self.assertTrue(True, "Simulation was initialized successfully")
return
self.assertTrue(False, "Timeout waiting for isaac sim to be ready")


# def test_arming(self):
# # Create a service call to existing "mavros/cmd/arming" service
# client = self.node.create_client(mavros_msgs.srv.CommandBool, '/mavros/cmd/arming')
# client.wait_for_service()
# request = mavros_msgs.srv.CommandBool.Request()
# request.value = True
# future = client.call_async(request)
# rclpy.spin_until_future_complete(self.node, future)
# response = future.result()
# self.assertTrue(response.success)

# def test_disarming(self):
# # Create a service call to existing "mavros/cmd/arming" service
# client = self.node.create_client(mavros_msgs.srv.CommandBool, '/mavros/cmd/arming')
# client.wait_for_service()
# request = mavros_msgs.srv.CommandBool.Request()
# request.value = False
# future = client.call_async(request)
# rclpy.spin_until_future_complete(self.node, future)
# response = future.result()
# self.assertTrue(response.success)







Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<set_env name="OMNI_KIT_ALLOW_ROOT" value="1" />
<node name="isaacsim" pkg="isaacsim" exec="run_isaacsim.py" output="screen">
<param name="install_path" value="/isaac-sim" />
<param name="gui" value="omniverse://128.237.74.43/Library/Assets/Ascent_Aerosystems/Spirit_UAV/two_ascent_fire_academy.usd" />
<param name="env_path" value="omniverse://128.237.74.43/Library/Assets/Ascent_Aerosystems/Spirit_UAV/two_ascent_fire_academy.usd" />
<param name="play_sim_on_start" value="true" />
<param name="isaac_args" value="--/app/scripting/ignoreWarningDialog=true" />
</node>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<set_env name="OMNI_KIT_ALLOW_ROOT" value="1" />
<node name="isaacsim" pkg="isaacsim" exec="run_isaacsim.py" output="screen">
<param name="install_path" value="/isaac-sim" />
<param name="gui" value="/extras/one_drone_world.usd" />
<param name="env_path" value="/extras/one_drone_world.usd" />
<param name="play_sim_on_start" value="true" />
<param name="isaac_args" value="--/app/scripting/ignoreWarningDialog=true" />
</node>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<set_env name="OMNI_KIT_ALLOW_ROOT" value="1" />
<node name="isaacsim" pkg="isaacsim" exec="run_isaacsim.py" output="screen">
<param name="install_path" value="/isaac-sim" />
<param name="gui" value="/extras/two_drone_world.usd" />
<param name="env_path" value="/extras/two_drone_world.usd" />
<param name="play_sim_on_start" value="true" />
<param name="isaac_args" value="--/app/scripting/ignoreWarningDialog=true" />
</node>
Expand Down
2 changes: 1 addition & 1 deletion ros_ws/src/robot/robot_systems_tests/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>robot_system_tests</name>
<version>0.0.0</version>
<description>Tests for the full robot system</description>
<description>Robot system tests for one singular robot</description>
<maintainer email="[email protected]">uav</maintainer>
<license>TODO: License declaration</license>

Expand Down
45 changes: 23 additions & 22 deletions ros_ws/src/robot/robot_systems_tests/setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from setuptools import setup, find_packages

package_name = 'robot_system_tests'
package_name = "robot_system_tests"

setup(
name=package_name,
version='0.0.0',
packages=find_packages(),
data_files=[
('share/' + package_name, ['package.xml']),
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
],
install_requires=['setuptools', 'launch', 'launch_ros', 'launch_testing', 'launch_testing_ros', 'pytest'],
zip_safe=True,
maintainer='TODO',
maintainer_email='TODO',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
# entry_points={
# 'console_scripts': [
# 'my_node = my_py_pkg.my_node:main'
# ],
# },
)
name=package_name,
version="0.0.0",
packages=find_packages(),
data_files=[
("share/" + package_name, ["package.xml"]),
("share/ament_index/resource_index/packages", ["resource/" + package_name]),
],
install_requires=[
"setuptools",
"launch",
"launch_ros",
"launch_testing",
"launch_testing_ros",
"pytest",
],
zip_safe=True,
maintainer="TODO",
maintainer_email="TODO",
description="Robot system tests for one singular robot",
license="TODO: License declaration",
tests_require=["pytest"],
)
2 changes: 2 additions & 0 deletions ros_ws/src/simulation/isaacsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(isaacsim)

find_package(ament_cmake REQUIRED)
find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)


install(DIRECTORY
scripts
Expand Down
2 changes: 2 additions & 0 deletions ros_ws/src/simulation/isaacsim/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>std_msgs</depend>

<exec_depend>launch</exec_depend>
<exec_depend>launch_ros</exec_depend>

Expand Down
Loading

0 comments on commit 367f17d

Please sign in to comment.