Skip to content

Commit

Permalink
Robot existense test, with a planned failure to verify that it is run…
Browse files Browse the repository at this point in the history
…ning

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Nov 14, 2024
1 parent 1b4e8b9 commit c79371a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions free_fleet_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if(BUILD_TESTING)
if (INTEGRATION_TESTING)
set(_pytest_tests
tests/integration/test_nav2_tf_handler.py
tests/integration/test_nav2_robot_adapter.py
)
foreach(_test_path ${_pytest_tests})
get_filename_component(_test_name ${_test_path} NAME_WE)
Expand Down
82 changes: 82 additions & 0 deletions free_fleet_adapter/tests/integration/test_nav2_robot_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env python3

# Copyright 2024 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.

import time

from free_fleet_adapter.nav2_robot_adapter import Nav2RobotAdapter
from tf2_ros import Buffer

import zenoh


def test_robot_does_not_exist():
zenoh.try_init_log_from_env()
with zenoh.open(zenoh.Config()) as session:
tf_buffer = Buffer()

robot_adapter = Nav2RobotAdapter(
name='missing_turtlebot3_1',
configuration=None,
robot_config_yaml={
'initial_map': 'L1',
},
node=None,
zenoh_session=session,
fleet_handle=None,
tf_buffer=tf_buffer
)

robot_exists = False
for i in range(10):
transform = robot_adapter.pose()
if transform is not None:
robot_exists = True
break
time.sleep(1)

assert not robot_exists


def test_robot_exists():
zenoh.try_init_log_from_env()
with zenoh.open(zenoh.Config()) as session:
tf_buffer = Buffer()

robot_adapter = Nav2RobotAdapter(
name='turtlebot3_1',
configuration=None,
robot_config_yaml={
'initial_map': 'L1',
},
node=None,
zenoh_session=session,
fleet_handle=None,
tf_buffer=tf_buffer
)

robot_exists = False
for i in range(10):
transform = robot_adapter.pose()
if transform is not None:
robot_exists = True
break
time.sleep(1)

# To check that it is running
assert not robot_exists


# def test_robot_navigate():

0 comments on commit c79371a

Please sign in to comment.