Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
sys.path.append(os.path.abspath(os.path.dirname(__file__)+"/../utils"))
import pytest_rs_utils
from pytest_rs_utils import launch_descr_with_yaml
from pytest_rs_utils import get_rosbag_file_path
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

BAG = "outdoors_1color.bag"

'''
This test imitates the ros2 launch rs_launch.py realsense2_camera with the given parameters below
Full command to reproduce locally
Expand All @@ -49,7 +51,7 @@
Also we check that the recieved frames of each topic are in the right width and height
'''
test_params = {
"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'camera_1',
'enable_color': 'true',
'enable_depth': 'true',
Expand Down Expand Up @@ -78,6 +80,7 @@ def test_align_depth_on(self, launch_descr_with_yaml):
initialize, run and check the data
'''
self.init_test('RsTest'+params['camera_name'])
self.wait_for_node(params['camera_name'])
ret = self.run_test(themes)
assert ret[0], ret[1]
assert self.process_data(themes)
Expand Down
17 changes: 10 additions & 7 deletions realsense2_camera/test/rosbag/test_rosbag_all_topics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@

from pytest_rs_utils import delayed_launch_descr_with_parameters
from pytest_rs_utils import get_rosbag_file_path
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

BAG = "outdoors_1color.bag"

test_params_all_topics = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),

test_params_all_topics = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'AllTopics',
'enable_infra1':'true',
'enable_infra2':'true',
Expand All @@ -66,7 +69,7 @@ class TestAllTopics(pytest_rs_utils.RsTestBaseClass):
def test_all_topics(self,delayed_launch_descr_with_parameters):

params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)

depth_to_infra_extrinsics_data = msg_Extrinsics()
depth_to_infra_extrinsics_data.rotation = [1., 0., 0., 0., 1., 0., 0., 0., 1.]
Expand All @@ -76,7 +79,7 @@ def test_all_topics(self,delayed_launch_descr_with_parameters):
depth_to_color_extrinsics_data.rotation=array('f',[ 0.99999666, 0.00166541, 0.00198587, -0.00166956, 0.99999642,
0.00208678, -0.00198239, -0.00209009, 0.99999583])
depth_to_color_extrinsics_data.translation=array('f',[ 0.01484134, -0.00020221, 0.00013059])
data = pytest_rs_utils.ImageColorGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageColorGetData(get_rosbag_file_path(BAG))
themes = [
{
'topic':get_node_heirarchy(params)+'/extrinsics/depth_to_color',
Expand Down Expand Up @@ -110,7 +113,7 @@ def test_all_topics(self,delayed_launch_descr_with_parameters):
def process_data(self, themes):
return super().process_data(themes)

test_params_metadata_topics = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_metadata_topics = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'MetadataTopics',
'color_width': '0',
'color_height': '0',
Expand All @@ -135,7 +138,7 @@ def test_metadata_topics(self,delayed_launch_descr_with_parameters):
current rosbag file doesn't have color data
'''
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)

color_metadata = msg_Metadata()
color_metadata.json_data = '{"frame_number":39,"clock_domain":"system_time","frame_timestamp":1508282881033.132324,"frame_counter":-8134432827560165376,"time_of_arrival":1508282881033}'
Expand Down Expand Up @@ -178,7 +181,7 @@ def test_metadata_topics(self,delayed_launch_descr_with_parameters):
def process_data(self, themes):
return super().process_data(themes)

test_params_camera_info_topics = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_camera_info_topics = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'CameraInfoTopics',
'color_width': '0',
'color_height': '0',
Expand All @@ -202,7 +205,7 @@ def test_camera_info_topics(self,delayed_launch_descr_with_parameters):
current rosbag file doesn't have color data
'''
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)
'''
The test is hardwired to ensure the rosbag file is not changed.
The function CameraInfoColorGetData requires changes to adapt to the changes
Expand Down
15 changes: 9 additions & 6 deletions realsense2_camera/test/rosbag/test_rosbag_basic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
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
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

test_params = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
BAG = "outdoors_1color.bag"

test_params = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Vis2_Cam',
'color_width': '0',
'color_height': '0',
Expand All @@ -53,7 +56,7 @@
class TestVis2(pytest_rs_utils.RsTestBaseClass):
def test_vis_2(self,delayed_launch_descr_with_parameters):
params = delayed_launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageColorGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageColorGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/color/image_raw',
'msg_type':msg_Image,
Expand All @@ -75,7 +78,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_depth = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_depth = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Depth_W_Cloud',
'color_width': '0',
'color_height': '0',
Expand All @@ -95,7 +98,7 @@ def process_data(self, themes):
class TestDepthWCloud(pytest_rs_utils.RsTestBaseClass):
def test_depth_w_cloud_1(self,launch_descr_with_parameters):
params = launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/depth/image_rect_raw',
'msg_type':msg_Image,
Expand All @@ -117,7 +120,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_depth_avg_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_depth_avg_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Depth_Avg_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -136,7 +139,7 @@ def process_data(self, themes):
class TestDepthAvg1(pytest_rs_utils.RsTestBaseClass):
def test_depth_avg_1(self,launch_descr_with_parameters):
params = launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/depth/image_rect_raw',
'msg_type':msg_Image,
Expand Down
19 changes: 11 additions & 8 deletions realsense2_camera/test/rosbag/test_rosbag_dec_point_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@
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
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

BAG = "outdoors_1color.bag"

test_params_depth_avg_decimation_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),

test_params_depth_avg_decimation_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Align_Depth_Color_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -55,7 +58,7 @@
class TestDepthAvgDecimation1(pytest_rs_utils.RsTestBaseClass):
def test_depth_avg_decimation_1(self,launch_descr_with_parameters):
params = launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthGetData_decimation(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthGetData_decimation(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/depth/image_rect_raw',
'msg_type':msg_Image,
Expand All @@ -77,7 +80,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_depth_avg_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_depth_avg_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Depth_Avg_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -96,7 +99,7 @@ def process_data(self, themes):
class TestDepthAvg1(pytest_rs_utils.RsTestBaseClass):
def test_depth_avg_1(self,launch_descr_with_parameters):
params = launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/depth/image_rect_raw',
'msg_type':msg_Image,
Expand All @@ -118,7 +121,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_depth_avg_decimation_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_depth_avg_decimation_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Align_Depth_Color_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -138,7 +141,7 @@ def process_data(self, themes):
class TestDepthAvgDecimation1(pytest_rs_utils.RsTestBaseClass):
def test_depth_avg_decimation_1(self,launch_descr_with_parameters):
params = launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthGetData_decimation(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthGetData_decimation(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/depth/image_rect_raw',
'msg_type':msg_Image,
Expand All @@ -160,7 +163,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_points_cloud_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_points_cloud_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Points_cloud_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -180,7 +183,7 @@ def process_data(self, themes):
class TestPointsCloud1(pytest_rs_utils.RsTestBaseClass):
def test_points_cloud_1(self,delayed_launch_descr_with_parameters):
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)
themes = [
{'topic':get_node_heirarchy(params)+'/depth/color/points',
'msg_type':msg_PointCloud2,
Expand Down
25 changes: 14 additions & 11 deletions realsense2_camera/test/rosbag/test_rosbag_depth_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@
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
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

BAG = "outdoors_1color.bag"

test_params_depth_points_cloud_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),

test_params_depth_points_cloud_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Points_cloud_1',
'color_width': '0',
'color_height': '0',
Expand Down Expand Up @@ -70,8 +73,8 @@ def test_depth_points_cloud_1(self,delayed_launch_descr_with_parameters):
since there are two callbacks, the initial few frames/data gets lost.
'''
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
data2 = pytest_rs_utils.ImageDepthGetData(params["rosbag_filename"])
self.rosbag = get_rosbag_file_path(BAG)
data2 = pytest_rs_utils.ImageDepthGetData(get_rosbag_file_path(BAG))
data1 = {'width': [660353, 3300],
'height': [1],
'avg': [np.array([ 1.28251814, -0.15839984, 4.82235184, 80, 160, 240])],
Expand All @@ -97,7 +100,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_static_tf_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_static_tf_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Static_tf1',
'color_width': '0',
'color_height': '0',
Expand All @@ -116,7 +119,7 @@ def process_data(self, themes):
class TestStaticTf1(pytest_rs_utils.RsTestBaseClass):
def test_static_tf_1(self,delayed_launch_descr_with_parameters):
self.params = delayed_launch_descr_with_parameters[1]
self.rosbag = self.params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)
themes = [
{'topic':get_node_heirarchy(self.params)+'/color/image_raw',
'msg_type':msg_Image,
Expand Down Expand Up @@ -156,7 +159,7 @@ def process_data(self, themes):
return ret[0]


test_params_non_existing_rosbag = {"rosbag_filename":"non_existent.bag",
test_params_non_existing_rosbag = {"rosbag_filename":"non_existent.db3",
'camera_name': 'non_existing_rosbag',
}
'''
Expand All @@ -181,7 +184,7 @@ def test_non_existing_rosbag(self,delayed_launch_descr_with_parameters):



test_params_align_depth_color_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_align_depth_color_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Align_Depth_Color_1',
'color_width': '0',
'color_height': '0',
Expand All @@ -201,7 +204,7 @@ def test_non_existing_rosbag(self,delayed_launch_descr_with_parameters):
class TestAlignDepthColor(pytest_rs_utils.RsTestBaseClass):
def test_align_depth_color_1(self,delayed_launch_descr_with_parameters):
params = delayed_launch_descr_with_parameters[1]
data = pytest_rs_utils.ImageDepthInColorShapeGetData(params["rosbag_filename"])
data = pytest_rs_utils.ImageDepthInColorShapeGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/aligned_depth_to_color/image_raw',
'msg_type':msg_Image,
Expand All @@ -223,7 +226,7 @@ def process_data(self, themes):
return super().process_data(themes)


test_params_align_depth_infra_1 = {"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
test_params_align_depth_infra_1 = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Align_Depth_Infra_1',
'color_width': '0',
'color_height': '0',
Expand Down Expand Up @@ -256,8 +259,8 @@ def process_data(self, themes):
class TestAlignDepthInfra1(pytest_rs_utils.RsTestBaseClass):
def test_align_depth_infra_1(self,delayed_launch_descr_with_parameters):
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
#data = pytest_rs_utils.ImageDepthInColorShapeGetData(params["rosbag_filename"])
self.rosbag = get_rosbag_file_path(BAG)
#data = pytest_rs_utils.ImageDepthInColorShapeGetData(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/aligned_depth_to_infra1/image_raw',
'msg_type':msg_Image,
Expand Down
11 changes: 7 additions & 4 deletions realsense2_camera/test/rosbag/test_rosbag_imu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@

from pytest_rs_utils import delayed_launch_descr_with_parameters
from pytest_rs_utils import get_rosbag_file_path
from pytest_rs_utils import get_db3_file_path
from pytest_rs_utils import get_node_heirarchy

BAG = "D435i_Depth_and_IMU_Stands_still.bag"

test_params_accel = {"rosbag_filename":get_rosbag_file_path("D435i_Depth_and_IMU_Stands_still.bag"),

test_params_accel = {"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'Accel_Cam',
'color_width': '0',
'color_height': '0',
Expand All @@ -62,7 +65,7 @@
class TestAccelUp1(pytest_rs_utils.RsTestBaseClass):
def test_accel_up_1(self,delayed_launch_descr_with_parameters):
params = delayed_launch_descr_with_parameters[1]
data = pytest_rs_utils.AccelGetDataDeviceStandStraight(params["rosbag_filename"])
data = pytest_rs_utils.AccelGetDataDeviceStandStraight(get_rosbag_file_path(BAG))
themes = [
{'topic':get_node_heirarchy(params)+'/accel/sample',
'msg_type':msg_Imu,
Expand All @@ -84,7 +87,7 @@ def process_data(self, themes):
return super().process_data(themes)

test_params_imu_topics = {#"rosbag_filename":get_rosbag_file_path("outdoors_1color.bag"),
"rosbag_filename":get_rosbag_file_path("D435i_Depth_and_IMU_Stands_still.bag"),
"rosbag_filename":get_db3_file_path(BAG),
'camera_name': 'ImuTopics',
'color_width': '0',
'color_height': '0',
Expand All @@ -106,7 +109,7 @@ def test_imu_topics(self,delayed_launch_descr_with_parameters):
current rosbag file doesn't have color data
'''
params = delayed_launch_descr_with_parameters[1]
self.rosbag = params["rosbag_filename"]
self.rosbag = get_rosbag_file_path(BAG)
themes = [{
'topic':get_node_heirarchy(params)+'/imu',
'msg_type':msg_Imu,
Expand Down
9 changes: 9 additions & 0 deletions realsense2_camera/test/utils/pytest_rs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def get_rosbag_file_path(filename):
return path
get_rosbag_file_path.rosbagMgr = None

def get_db3_file_path(bag_filename):
bag = get_rosbag_file_path(bag_filename)
db3 = os.path.splitext(bag)[0] + ".db3"
if os.path.isfile(db3):
return db3
subprocess.run(["rs-convert", "-i", bag, "-D", db3],
check=True, capture_output=True, timeout=180)
return db3

def CameraInfoGetData(rec_filename, topic):
data = importRosbag(rec_filename, importTopics=[topic], log='ERROR', disable_bar=True)[topic]
data = {k.lower(): v for k, v in data.items()}
Expand Down
Loading