-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add live tests #2834
Closed
PrasRsRos
wants to merge
53
commits into
IntelRealSense:ros2-development
from
PrasRsRos:add_live_tests
Closed
Add live tests #2834
Changes from 15 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
0f763ed
Update README.md
PrasRsRos 0426cbe
add template for d455 live camera with dynamic parameter change
PrasRsRos 734ba1f
added conditional test addition based on device connected to the system
PrasRsRos fd11219
Merge branch 'IntelRealSense:ros2-development' into add_live_tests
PrasRsRos a9fcee4
Added live camera test for changing profile based on enumerated data
PrasRsRos 8fa253f
added tests for all profiles of d455 415 based on the inputs from rs-…
PrasRsRos eee09de
Added a new test for failing tests, without assert
PrasRsRos bd92294
Merge branch 'add_live_tests' of https://github.com/PrasRsRos/realsen…
PrasRsRos 0fccb9d
added failing 415 tests for further testing
PrasRsRos 1f9df74
Merge branch 'IntelRealSense:ros2-development' into add_live_tests
PrasRsRos 9b64dca
Moved configs to utils
PrasRsRos d89bd17
removed all skips in live camera test
PrasRsRos 6538c6d
added dynamic change of gyro enablement
PrasRsRos fea39c2
added dynamic change of gyro enablement, code cleaned
PrasRsRos 9b4ea54
added dynamic change of gyro enablement, fixed gyro accel false issue…
PrasRsRos 9c287b2
Added fps tests
PrasRsRos ea54ea9
added ros2topic to package
PrasRsRos e547ddb
Increase the timeout, due to failure in prerelease
PrasRsRos 436edc3
reverting back to 250 as the timeout for running test
PrasRsRos bf515dc
increased delay to compensate for prerelease delay
PrasRsRos b861562
Added variable delay to take care of machine capability
PrasRsRos f098ad8
testing ...1
PrasRsRos cb44783
Merge branch 'IntelRealSense:ros2-development' into add_live_tests
PrasRsRos 8ba72db
testing... 2
PrasRsRos 8260825
testing... 3
PrasRsRos 94db55d
testing... 4
PrasRsRos b272f2a
testing...5
PrasRsRos aa391f8
removed the tests added for the failing formats
PrasRsRos 6ece2e5
Upload before rebase
PrasRsRos c673c4b
- Reduce changes between hkr and development
SamerKhshiboun 99dbc5d
added failing 415 tests for further testing
PrasRsRos d03a8f2
Update rs_launch.py, rs_multi_camera_launch.py
hyunseok-yang 3f609f7
Moved configs to utils
PrasRsRos 5a62e54
removed all skips in live camera test
PrasRsRos 4d59658
added dynamic change of gyro enablement
PrasRsRos b36f068
added dynamic change of gyro enablement, code cleaned
PrasRsRos a17fe02
added dynamic change of gyro enablement, fixed gyro accel false issue…
PrasRsRos 61be45c
Added fps tests
PrasRsRos ee75cce
added ros2topic to package
PrasRsRos 8ac03a3
Increase the timeout, due to failure in prerelease
PrasRsRos a614bb6
reverting back to 250 as the timeout for running test
PrasRsRos 9e6deb8
increased delay to compensate for prerelease delay
PrasRsRos 2d18285
Added variable delay to take care of machine capability
PrasRsRos 30b7f40
testing ...1
PrasRsRos f57c050
support color and depth/ir formats
SamerKhshiboun 4ce8a61
return status when filling cv matrix and ros images
SamerKhshiboun 6fa71f3
testing... 2
PrasRsRos 5a6ace7
testing... 3
PrasRsRos 5e81d75
testing... 4
PrasRsRos d96e9a1
testing...5
PrasRsRos 8a6b6d0
removed the tests added for the failing formats
PrasRsRos 885bb8e
Upload before rebase
PrasRsRos a0a8ff1
Merge branch 'add_live_tests' of https://github.com/PrasRsRos/realsen…
PrasRsRos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
235 changes: 235 additions & 0 deletions
235
realsense2_camera/test/live_camera/test_camera_all_profile_tests.py
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,235 @@ | ||
# Copyright 2023 Intel Corporation. All Rights Reserved. | ||
# | ||
# 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 | ||
import sys | ||
import itertools | ||
|
||
|
||
import pytest | ||
import rclpy | ||
|
||
from sensor_msgs.msg import Image as msg_Image | ||
from sensor_msgs.msg import Imu as msg_Imu | ||
from sensor_msgs.msg import PointCloud2 as msg_PointCloud2 | ||
|
||
import numpy as np | ||
|
||
sys.path.append(os.path.abspath(os.path.dirname(__file__)+"/../utils")) | ||
import pytest_rs_utils | ||
from pytest_rs_utils import launch_descr_with_parameters | ||
from pytest_rs_utils import delayed_launch_descr_with_parameters | ||
from pytest_rs_utils import get_rosbag_file_path | ||
import pytest_live_camera_utils | ||
from rclpy.parameter import Parameter | ||
from rcl_interfaces.msg import ParameterValue | ||
from rcl_interfaces.srv import SetParameters, GetParameters, ListParameters | ||
from pytest_live_camera_utils import debug_print | ||
def check_if_skip_test(profile, format): | ||
''' | ||
if profile == 'Color': | ||
if "BGRA8" == format: | ||
return True | ||
if "RGBA8" == format: | ||
return True | ||
if "Y8" == format: | ||
return True | ||
elif profile == 'Depth': | ||
if "Z16" == format: | ||
return True | ||
elif profile == 'Infrared': | ||
if "Y8" == format: | ||
return True | ||
if "Y16" == format: | ||
return True | ||
if "BGRA8" == format: | ||
return True | ||
if "RGBA8" == format: | ||
return True | ||
if "Y10BPACK" == format: | ||
return True | ||
if "UYVY" == format: | ||
return True | ||
if "BGR8" == format: | ||
return True | ||
if "RGB8" == format: | ||
return True | ||
if "RAW10" == format: | ||
return True | ||
elif profile == 'Infrared1': | ||
if "Y8" ==format: | ||
return True | ||
if "Y16" ==format: | ||
return True | ||
if "Y10BPACK" == format: | ||
return True | ||
if "UYVY" ==format: | ||
return True | ||
if "BGR8" ==format: | ||
return True | ||
if "RGB8" ==format: | ||
return True | ||
if "RAW10" ==format: | ||
return True | ||
if profile == 'Infrared2': | ||
if "Y8" == format: | ||
return True | ||
if "Y16" == format: | ||
return True | ||
if "Y10BPACK" == format: | ||
return True | ||
if "UYVY" == format: | ||
return True | ||
if "BGR8" == format: | ||
return True | ||
if "RGB8" == format: | ||
return True | ||
if "RAW10" == format: | ||
return True | ||
''' | ||
return False | ||
|
||
|
||
test_params_all_profiles_d455 = { | ||
'camera_name': 'D455', | ||
'device_type': 'D455', | ||
} | ||
test_params_all_profiles_d415 = { | ||
'camera_name': 'D415', | ||
'device_type': 'D415', | ||
} | ||
test_params_all_profiles_d435 = { | ||
'camera_name': 'D435', | ||
'device_type': 'D435', | ||
} | ||
|
||
|
||
''' | ||
This test was implemented as a template to set the parameters and run the test. | ||
This directory is not added to the CMakeLists.txt so as to avoid the colcon failure in the | ||
machines that don't have the D455 connected. | ||
1. Only a subset of parameter types are implemented in py_rs_utils, it has to be extended for others | ||
2. After setting the param, rclpy.spin_once may be needed.Test passes even without this though. | ||
''' | ||
@pytest.mark.parametrize("launch_descr_with_parameters", [ | ||
pytest.param(test_params_all_profiles_d455, marks=pytest.mark.d455), | ||
pytest.param(test_params_all_profiles_d415, marks=pytest.mark.d415), | ||
pytest.param(test_params_all_profiles_d435, marks=pytest.mark.d435),] | ||
,indirect=True) | ||
@pytest.mark.launch(fixture=launch_descr_with_parameters) | ||
class TestLiveCamera_Change_Resolution(pytest_rs_utils.RsTestBaseClass): | ||
def test_LiveCamera_Change_Resolution(self,launch_descr_with_parameters): | ||
skipped_tests = [] | ||
num_passed = 0 | ||
num_failed = 0 | ||
params = launch_descr_with_parameters[1] | ||
themes = [{'topic':'/'+params['camera_name']+'/color/image_raw', 'msg_type':msg_Image,'expected_data_chunks':1}] | ||
config = pytest_live_camera_utils.get_profile_config(params['camera_name']) | ||
try: | ||
''' | ||
initialize, run and check the data | ||
''' | ||
serial_no = None | ||
if 'serial_no' in params: | ||
serial_no = params['serial_no'] | ||
self.init_test("RsTest"+params['camera_name']) | ||
cap = pytest_live_camera_utils.get_camera_capabilities(params['device_type'], serial_no) | ||
if cap == None: | ||
debug_print("Device not found? : " + params['device_type']) | ||
return | ||
self.create_param_ifs(params['camera_name'] + '/' + params['camera_name']) | ||
config["Color"]["default_profile1"],config["Color"]["default_profile2"] = pytest_live_camera_utils.get_default_profiles(cap["color_profile"], "Color") | ||
config["Depth"]["default_profile1"],config["Depth"]["default_profile2"] = pytest_live_camera_utils.get_default_profiles(cap["depth_profile"], "Depth") | ||
config["Infrared"]["default_profile1"],config["Infrared"]["default_profile2"] = pytest_live_camera_utils.get_default_profiles(cap["depth_profile"], "Infrared") | ||
config["Infrared1"]["default_profile1"],config["Infrared1"]["default_profile2"] = pytest_live_camera_utils.get_default_profiles(cap["depth_profile"], "Infrared1") | ||
config["Infrared2"]["default_profile1"],config["Infrared2"]["default_profile2"] = pytest_live_camera_utils.get_default_profiles(cap["depth_profile"], "Infrared2") | ||
for key in cap["color_profile"]: | ||
profile_type = key[0] | ||
profile = key[1] | ||
format = key[2] | ||
if check_if_skip_test(profile_type, format): | ||
skipped_tests.append(" ".join(key)) | ||
continue | ||
themes[0]['topic'] = config[profile_type]['topic'] | ||
themes[0]['width'] = int(profile.split('x')[0]) | ||
themes[0]['height'] = int(profile.split('x')[1]) | ||
if themes[0]['width'] == int(config[profile_type]["default_profile2"].split('x')[0]): | ||
self.set_string_param(config[profile_type]["profile"], config[profile_type]["default_profile1"]) | ||
else: | ||
self.set_string_param(config[profile_type]["profile"], config[profile_type]["default_profile2"]) | ||
self.set_bool_param(config[profile_type]["param"], True) | ||
self.disable_all_params() | ||
self.set_string_param(config[profile_type]["profile"], profile) | ||
self.set_string_param(config[profile_type]["format"], format) | ||
self.set_bool_param(config[profile_type]["param"], True) | ||
try: | ||
ret = self.run_test(themes) | ||
assert ret[0], ret[1] | ||
assert self.process_data(themes), " ".join(key) + " failed" | ||
num_passed += 1 | ||
except Exception as e: | ||
print("Test failed") | ||
print(e) | ||
num_failed += 1 | ||
debug_print("Color tests completed") | ||
for key in cap["depth_profile"]: | ||
profile_type = key[0] | ||
profile = key[1] | ||
format = key[2] | ||
if check_if_skip_test(profile_type, format): | ||
skipped_tests.append(" ".join(key)) | ||
continue | ||
debug_print("Testing " + " ".join(key)) | ||
|
||
themes[0]['topic'] = config[profile_type]['topic'] | ||
themes[0]['width'] = int(profile.split('x')[0]) | ||
themes[0]['height'] = int(profile.split('x')[1]) | ||
if themes[0]['width'] == int(config[profile_type]["default_profile2"].split('x')[0]): | ||
self.set_string_param(config[profile_type]["profile"], config[profile_type]["default_profile1"]) | ||
else: | ||
self.set_string_param(config[profile_type]["profile"], config[profile_type]["default_profile2"]) | ||
self.set_bool_param(config[profile_type]["param"], True) | ||
|
||
|
||
self.disable_all_params() | ||
self.set_string_param(config[profile_type]["profile"], profile) | ||
self.set_string_param(config[profile_type]["format"], format) | ||
self.set_bool_param(config[profile_type]["param"], True) | ||
try: | ||
ret = self.run_test(themes) | ||
assert ret[0], ret[1] | ||
assert self.process_data(themes), " ".join(key) + " failed" | ||
num_passed += 1 | ||
except Exception as e: | ||
print("Test failed") | ||
print(e) | ||
num_failed += 1 | ||
debug_print("Depth tests completed") | ||
finally: | ||
#this step is important because the test will fail next time | ||
pytest_rs_utils.kill_realsense2_camera_node() | ||
self.shutdown() | ||
debug_print("\nSkipped tests:" + params['device_type']) | ||
debug_print("\n".join(skipped_tests)) | ||
print("Tests passed " + str(num_passed)) | ||
print("Tests skipped " + str(len(skipped_tests))) | ||
print("Tests failed " + str(num_failed)) | ||
def disable_all_params(self): | ||
self.set_bool_param('enable_color', False) | ||
self.set_bool_param('enable_depth', False) | ||
self.set_bool_param('enable_infra', False) | ||
self.set_bool_param('enable_infra1', False) | ||
self.set_bool_param('enable_infra2', False) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on which camera model do you see this format ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in D415: