migrate passthrough and project_inliers filters (#395)

* migrate passthrough and project_inliers filters

Signed-off-by: Daisuke Sato <daisukes@cmu.edu>

* - remove throwing runtime_error (result always true)
- use get_subscription_count()

Signed-off-by: Daisuke Sato <daisukes@cmu.edu>

* change comparison operator

Signed-off-by: Daisuke Sato <daisukes@cmu.edu>

---------

Signed-off-by: Daisuke Sato <daisukes@cmu.edu>
This commit is contained in:
Daisuke Sato
2023-01-30 21:36:12 -05:00
committed by GitHub
parent 0c8e7dafce
commit de09161924
11 changed files with 319 additions and 198 deletions
+30 -1
View File
@@ -21,15 +21,44 @@ OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/test_ament_index/share/ament_index/resource_index/rclcpp_components/pcl_ros_tests_filters"
CONTENT "${components}")
ament_add_pytest_test(test_filter_extract_indices_node_component
# test components
ament_add_pytest_test(test_pcl_ros::ExtractIndices
test_filter_component.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_PLUGIN=pcl_ros::ExtractIndices
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
ament_add_pytest_test(test_pcl_ros::PassThrough
test_filter_component.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_PLUGIN=pcl_ros::PassThrough
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
ament_add_pytest_test(test_pcl_ros::ProjectInliers
test_filter_component.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_PLUGIN=pcl_ros::ProjectInliers
PARAMETERS={'model_type':0}
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
# test executables
ament_add_pytest_test(test_filter_extract_indices_node
test_filter_executable.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_EXECUTABLE=filter_extract_indices_node
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
ament_add_pytest_test(test_filter_passthrough_node
test_filter_executable.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_EXECUTABLE=filter_passthrough_node
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
ament_add_pytest_test(test_filter_project_inliers_node
test_filter_executable.py
ENV DUMMY_PLUGIN=pcl_ros_tests_filters::DummyTopics
FILTER_EXECUTABLE=filter_project_inliers_node
PARAMETERS={'model_type':0}
APPEND_ENV AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_ament_index
)
@@ -27,6 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
import ast
import os
import unittest
@@ -46,14 +47,8 @@ from sensor_msgs.msg import PointCloud2
def generate_test_description():
dummy_plugin = os.getenv('DUMMY_PLUGIN')
filter_plugin = os.getenv('FILTER_PLUGIN')
use_indices = os.getenv('USE_INDICES')
approximate_sync = os.getenv('APPROXIMATE_SYNC')
parameters = ast.literal_eval(os.getenv('PARAMETERS')) if 'PARAMETERS' in os.environ else {}
parameters = {}
if use_indices:
parameters['use_indices'] = (use_indices == 'true')
if approximate_sync:
parameters['approximate_sync'] = (approximate_sync == 'true')
print(parameters)
return launch.LaunchDescription([
@@ -1,3 +1,33 @@
#
# Copyright (c) 2022 Carnegie Mellon University
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Carnegie Mellon University nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
import ast
import os
import unittest
@@ -17,14 +47,11 @@ from sensor_msgs.msg import PointCloud2
def generate_test_description():
dummy_plugin = os.getenv('DUMMY_PLUGIN')
filter_executable = os.getenv('FILTER_EXECUTABLE')
use_indices = os.getenv('USE_INDICES')
approximate_sync = os.getenv('APPROXIMATE_SYNC')
parameters = ast.literal_eval(os.getenv('PARAMETERS')) if 'PARAMETERS' in os.environ else {}
ros_arguments = ["-r", "input:=point_cloud2"]
if use_indices:
ros_arguments.extend(["-p", "use_indices:={}".format(use_indices)])
if approximate_sync:
ros_arguments.extend(["-p", "approximate_sync:={}".format(approximate_sync)])
for key in parameters.keys():
ros_arguments.extend(["-p", "{}:={}".format(key, parameters[key])])
return launch.LaunchDescription([