Skip to content

The description and implementation of the function parameter_dict_from_yaml_file() are inconsistent. #1550

@Barry-Xu-2018

Description

@Barry-Xu-2018

Generated by Generative AI

No response

Operating System:

Linux cscsh-dev2 6.14.0-36-generic #36~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 15 15:45:17 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

ROS version or commit hash:

rolling,Kilted

RMW implementation (if applicable):

Unrelated to RMW

RMW Configuration (if applicable):

No response

Client library (if applicable):

rclpy

'ros2 doctor --report' output

ros2 doctor --report
   ACTION LIST
action                 : none
action server count    : 0
action client count    : 0

   ROS ENVIRONMENT
ROS environment variables        : ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET, ROS_DISTRO=rolling
rcutils environment variables    : 
rmw environment variables        : 

   NETWORK CONFIGURATION
inet         : 127.0.0.1
inet4        : ['127.0.0.1']
inet6        : ['::1']
netmask      : 255.0.0.0
device       : lo
flags        : UP,LOOPBACK,RUNNING
mtu          : 65536
inet         : 192.168.0.111
inet4        : ['192.168.0.111']
ether        : cc:96:e5:49:d0:a2
inet6        : ['2403:700:0:20b2:8b5:bce6:772:5c73', '2403:700:0:20b2:b498:9454:bf1e:5ff2', 'fe80::4eb0:1ab3:67e8:a64a%enp3s0']
netmask      : 255.255.255.0
device       : enp3s0
flags        : UP,BROADCAST,RUNNING,MULTICAST
mtu          : 1500
broadcast    : 192.168.0.255
inet         : 172.17.0.1
inet4        : ['172.17.0.1']
ether        : 56:d2:bf:5a:68:a1
netmask      : 255.255.0.0
device       : docker0
flags        : UP,BROADCAST,MULTICAST
mtu          : 1500
broadcast    : 172.17.255.255
ether        : 4c:d7:17:7d:c2:58
device       : enp0s31f6
flags        : UP,BROADCAST,MULTICAST
mtu          : 1500

   PACKAGE VERSIONS
ros2cli_common_extensions                 : latest=0.5.1, local=0.5.1
sros2                                     : latest=0.16.2, local=0.16.2
service_load_balancing                    : latest=0.1.3, local=0.1.3
ros_testing                               : latest=0.9.1, local=0.9.1
ros2topic                                 : latest=0.40.2, local=0.40.2
ros2test                                  : latest=0.9.1, local=0.9.1
ros2component                             : latest=0.40.2, local=0.40.2
ros2param                                 : latest=0.40.2, local=0.40.2
ros2lifecycle                             : latest=0.40.2, local=0.40.2
ros2service                               : latest=0.40.2, local=0.40.2
ros2run                                   : latest=0.40.2, local=0.40.2
ros2launch                                : latest=0.29.4, local=0.29.4
ros2pkg                                   : latest=0.40.2, local=0.40.2
ros2node                                  : latest=0.40.2, local=0.40.2
ros2multicast                             : latest=0.40.2, local=0.40.2
ros2lifecycle_test_fixtures               : latest=0.40.2, local=0.40.2
ros2interface                             : latest=0.40.2, local=0.40.2
ros2doctor                                : latest=0.40.2, local=0.40.2
ros2action                                : latest=0.40.2, local=0.40.2
ros2cli                                   : latest=0.40.2, local=0.40.2
launch_testing_ros                        : latest=0.29.4, local=0.29.4
ament_cmake_ros                           : latest=0.15.4, local=0.15.4
rmw_test_fixture_implementation           : latest=0.15.4, local=0.15.4
demo_nodes_cpp                            : latest=0.37.4, local=0.37.3
launch_ros                                : latest=0.29.4, local=0.29.4
demo_nodes_py                             : latest=0.37.4, local=0.37.3
bug_reproduce_py                          : latest=N/A, local=0.1.0
rclpy                                     : latest=10.0.2, local=10.0.2
rclcpp_lifecycle                          : latest=30.1.3, local=30.1.3
action_tutorials_cpp                      : latest=0.37.4, local=0.37.3
rclcpp_components                         : latest=30.1.3, local=30.1.3
rclcpp_action                             : latest=30.1.3, local=30.1.3
rclcpp                                    : latest=30.1.3, local=30.1.3
rcl_lifecycle                             : latest=10.2.6, local=10.2.6
rcl_action                                : latest=10.2.6, local=10.2.6
libstatistics_collector                   : latest=2.1.1, local=2.1.1
rcl                                       : latest=10.2.6, local=10.2.6
rmw_implementation                        : latest=3.1.3, local=3.1.3
rmw_zenoh_cpp                             : latest=0.10.2, local=0.10.2
zenoh_cpp_vendor                          : latest=0.10.2, local=0.10.2
test_msgs                                 : latest=2.4.2, local=2.4.2
std_srvs                                  : latest=5.9.1, local=5.9.1
geometry_msgs                             : latest=5.9.1, local=5.9.1
std_msgs                                  : latest=5.9.1, local=5.9.1
statistics_msgs                           : latest=2.4.2, local=2.4.2
rosgraph_msgs                             : latest=2.4.2, local=2.4.2
ros2cli_test_interfaces                   : latest=0.40.2, local=0.40.2
rmw_fastrtps_dynamic_cpp                  : latest=9.4.4, local=9.4.4
rmw_fastrtps_cpp                          : latest=9.4.4, local=9.4.4
rmw_fastrtps_shared_cpp                   : latest=9.4.4, local=9.4.4
rmw_cyclonedds_cpp                        : latest=4.1.3, local=4.1.3
rmw_connextddsmicro                       : latest=N/A, local=1.2.4
rmw_connextdds                            : latest=1.2.4, local=1.2.4
rmw_connextdds_common                     : latest=1.2.4, local=1.2.4
rmw_dds_common                            : latest=4.0.2, local=4.0.2
composition_interfaces                    : latest=2.4.2, local=2.4.2
rcl_interfaces                            : latest=2.4.2, local=2.4.2
lifecycle_msgs                            : latest=2.4.2, local=2.4.2
example_interfaces                        : latest=0.14.1, local=0.14.1
rosidl_default_runtime                    : latest=1.8.1, local=1.8.1
rosidl_default_generators                 : latest=1.8.1, local=1.8.1
action_msgs                               : latest=2.4.2, local=2.4.2
unique_identifier_msgs                    : latest=2.8.1, local=2.8.1
type_description_interfaces               : latest=2.4.2, local=2.4.2
service_msgs                              : latest=2.4.2, local=2.4.2
builtin_interfaces                        : latest=2.4.2, local=2.4.2
rosidl_core_runtime                       : latest=0.4.1, local=0.4.1
rosidl_core_generators                    : latest=0.4.1, local=0.4.1
rosidl_generator_py                       : latest=0.26.2, local=0.26.2
ament_lint_common                         : latest=0.20.3, local=0.20.2
ament_cmake_uncrustify                    : latest=0.20.3, local=0.20.2
ament_uncrustify                          : latest=0.20.3, local=0.20.2
uncrustify_vendor                         : latest=3.2.0, local=3.2.0
tracetools                                : latest=8.9.0, local=8.9.0
test_interface_files                      : latest=0.14.1, local=0.14.1
rcl_logging_spdlog                        : latest=3.3.2, local=3.3.2
spdlog_vendor                             : latest=1.8.0, local=1.8.0
rti_connext_dds_cmake_module              : latest=1.2.4, local=1.2.4
rpyutils                                  : latest=0.7.1, local=0.7.1
rosidl_typesupport_cpp                    : latest=3.4.1, local=3.4.1
rosidl_typesupport_introspection_cpp      : latest=5.1.1, local=5.1.1
rosidl_generator_rs                       : latest=0.4.9, local=0.4.9
rosidl_typesupport_c                      : latest=3.4.1, local=3.4.1
rosidl_typesupport_introspection_c        : latest=5.1.1, local=5.1.1
rosidl_typesupport_fastrtps_c             : latest=3.9.3, local=3.9.3
rosidl_typesupport_fastrtps_cpp           : latest=3.9.3, local=3.9.3
rosidl_generator_cpp                      : latest=5.1.1, local=5.1.1
rosidl_runtime_cpp                        : latest=5.1.1, local=5.1.1
rosidl_dynamic_typesupport_fastrtps       : latest=0.5.1, local=0.5.1
rmw_test_fixture                          : latest=0.15.4, local=0.15.4
rmw_security_common                       : latest=7.9.1, local=7.9.1
rcl_yaml_param_parser                     : latest=10.2.6, local=10.2.6
rmw                                       : latest=7.9.1, local=7.9.1
rosidl_dynamic_typesupport                : latest=0.4.0, local=0.4.0
rosidl_runtime_c                          : latest=5.1.1, local=5.1.1
rosidl_generator_c                        : latest=5.1.1, local=5.1.1
rosidl_typesupport_interface              : latest=5.1.1, local=5.1.1
rosidl_runtime_py                         : latest=0.15.1, local=0.15.1
rosidl_cmake                              : latest=5.1.1, local=5.1.1
rosidl_pycommon                           : latest=5.1.1, local=5.1.1
rosidl_generator_type_description         : latest=5.1.1, local=5.1.1
rosidl_parser                             : latest=5.1.1, local=5.1.1
rosidl_adapter                            : latest=5.1.1, local=5.1.1
rosidl_cli                                : latest=5.1.1, local=5.1.1
ros_environment                           : latest=4.4.1, local=4.4.1
rmw_implementation_cmake                  : latest=7.9.1, local=7.9.1
class_loader                              : latest=2.9.1, local=2.9.1
rcpputils                                 : latest=2.14.3, local=2.14.3
rcl_logging_noop                          : latest=3.3.2, local=3.3.2
rcl_logging_interface                     : latest=3.3.2, local=3.3.2
rcutils                                   : latest=7.0.4, local=7.0.4
performance_test_fixture                  : latest=0.4.1, local=0.4.1
mimick_vendor                             : latest=0.9.0, local=0.9.0
libyaml_vendor                            : latest=1.8.0, local=1.8.0
launch_testing_ament_cmake                : latest=3.9.5, local=3.9.5
launch_testing                            : latest=3.9.5, local=3.9.5
launch_yaml                               : latest=3.9.5, local=3.9.5
launch_xml                                : latest=3.9.5, local=3.9.5
launch                                    : latest=3.9.5, local=3.9.5
ament_cmake_gmock                         : latest=2.8.4, local=2.8.4
ament_cmake_gtest                         : latest=2.8.4, local=2.8.4
ament_cmake_google_benchmark              : latest=2.8.4, local=2.8.4
domain_coordinator                        : latest=0.15.4, local=0.15.4
console_bridge_vendor                     : latest=1.9.1, local=1.9.1
ament_cmake_xmllint                       : latest=0.20.3, local=0.20.2
ament_xmllint                             : latest=0.20.3, local=0.20.2
ament_pycodestyle                         : latest=0.20.3, local=0.20.2
ament_cmake_pep257                        : latest=0.20.3, local=0.20.2
ament_pep257                              : latest=0.20.3, local=0.20.2
ament_lint_auto                           : latest=0.20.3, local=0.20.2
ament_cmake                               : latest=2.8.4, local=2.8.4
ament_cmake_version                       : latest=2.8.4, local=2.8.4
ament_cmake_vendor_package                : latest=2.8.4, local=2.8.4
ament_cmake_pytest                        : latest=2.8.4, local=2.8.4
ament_cmake_mypy                          : latest=0.20.3, local=0.20.2
ament_cmake_lint_cmake                    : latest=0.20.3, local=0.20.2
ament_cmake_flake8                        : latest=0.20.3, local=0.20.2
ament_cmake_cpplint                       : latest=0.20.3, local=0.20.2
ament_cmake_cppcheck                      : latest=0.20.3, local=0.20.2
ament_cmake_copyright                     : latest=0.20.3, local=0.20.2
ament_cmake_test                          : latest=2.8.4, local=2.8.4
ament_cmake_target_dependencies           : latest=2.8.4, local=2.8.4
ament_cmake_ros_core                      : latest=0.15.4, local=0.15.4
ament_cmake_python                        : latest=2.8.4, local=2.8.4
ament_cmake_export_dependencies           : latest=2.8.4, local=2.8.4
ament_cmake_libraries                     : latest=2.8.4, local=2.8.4
ament_cmake_include_directories           : latest=2.8.4, local=2.8.4
ament_cmake_gen_version_h                 : latest=2.8.4, local=2.8.4
ament_cmake_export_targets                : latest=2.8.4, local=2.8.4
ament_cmake_export_link_flags             : latest=2.8.4, local=2.8.4
ament_cmake_export_libraries              : latest=2.8.4, local=2.8.4
ament_cmake_export_include_directories    : latest=2.8.4, local=2.8.4
ament_cmake_export_definitions            : latest=2.8.4, local=2.8.4
ament_cmake_core                          : latest=2.8.4, local=2.8.4
ament_package                             : latest=0.18.1, local=0.18.1
ament_mypy                                : latest=0.20.3, local=0.20.2
ament_lint_cmake                          : latest=0.20.3, local=0.20.2
ament_flake8                              : latest=0.20.3, local=0.20.2
ament_copyright                           : latest=0.20.3, local=0.20.2
ament_lint                                : latest=0.20.3, local=0.20.2
ament_index_python                        : latest=1.12.1, local=1.12.1
ament_index_cpp                           : latest=1.12.1, local=1.12.1
ament_cpplint                             : latest=0.20.3, local=0.20.2
ament_cppcheck                            : latest=0.20.3, local=0.20.2

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-6.14.0-36-generic-x86_64-with-glibc2.39
release          : 6.14.0-36-generic
processor        : x86_64

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : rolling
distribution type      : ros2
distribution status    : rolling
release platforms      : {'debian': ['bookworm'], 'rhel': ['9'], 'ubuntu': ['noble']}

   SERVICE LIST
service          : none
service count    : 0
client count     : 0

   TOPIC LIST
topic               : none
publisher count     : 0
subscriber count    : 0

================================================================================
                                !!! WARNING !!!                                 
================================================================================
The report includes all ROS 2 endpoint information and system platform information.
Please review the report before sharing, as it may contain sensitive or private data.
================================================================================

Steps to reproduce issue

/tmp/test.yaml

gps_node:
  ros__parameters:
    port: "/dev/ttyACM0"
    baud: 9600
    frame_id: "gps"
    time_ref_source: "gps"
    useRMC: False
  1. Call rclpy.parameter.parameter_dict_from_yaml_file('parameter_file='/tmp/test.yaml', use_wildcard=False)
  2. Check output

Expected behavior

According to the function description as the below, there should be a return value.

def parameter_dict_from_yaml_file(
parameter_file: str,
use_wildcard: bool = False,
target_nodes: Optional[List[str]] = None,
namespace: str = ''
) -> Dict[str, ParameterMsg]:
"""
Build a dict of parameters from a YAML file.
Will load all parameters if ``target_nodes`` is None or empty.
:raises RuntimeError: if a target node is not in the file
:raises RuntimeError: if the is not a valid ROS parameter file
:param parameter_file: Path to the YAML file to load parameters from.
:param use_wildcard: Use wildcard matching for the target nodes.
:param target_nodes: List of nodes in the YAML file to load parameters from.
:param namespace: Namespace to prepend to all parameters.
:return: A dict of Parameter messages keyed by the parameter names
"""

{ 'baud': rcl_interfaces.msg.Parameter(name='baud', value=rcl_interfaces.msg.ParameterValue(type=2, bool_value=False, integer_value=9600, double_value=0.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])),
  'frame_id': rcl_interfaces.msg.Parameter(name='frame_id', value=rcl_interfaces.msg.ParameterValue(type=4, bool_value=False, integer_value=0, double_value=0.0, string_value='gps', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])),
  'port': rcl_interfaces.msg.Parameter(name='port', value=rcl_interfaces.msg.ParameterValue(type=4, bool_value=False, integer_value=0, double_value=0.0, string_value='/dev/ttyACM0', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])),
  'time_ref_source': rcl_interfaces.msg.Parameter(name='time_ref_source', value=rcl_interfaces.msg.ParameterValue(type=4, bool_value=False, integer_value=0, double_value=0.0, string_value='gps', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])),
  'useRMC': rcl_interfaces.msg.Parameter(name='useRMC', value=rcl_interfaces.msg.ParameterValue(type=1, bool_value=False, integer_value=0, double_value=0.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[]))}

Actual behavior

An exception received.
RuntimeError: Param file does not contain any valid parameters

Additional information

It worked normally in the Jazzy version, where there was additional handling when target_nodes was None or empty. However, in the rolling/kilted version, the original code has been completely changed, and there is no such handling in the new code.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions