-
Notifications
You must be signed in to change notification settings - Fork 522
Closed
Description
Bug report
Required Info:
- Operating System:
- Ubuntu22.04
- Installation type:
- source
- Version or commit hash:
- DDS implementation:
- Fast-RTPS
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
add test case in https://github.com/ros2/rclcpp/blob/edbfe1404b24d0bc85ff88e8ff1f006670788e46/rclcpp/test/rclcpp/test_node.cpp
TEST_F(TestNode, parameter_uninitialized_exception_even_if_allow_undeclared) {
rclcpp::NodeOptions no;
no.allow_undeclared_parameters(true);
auto node = std::make_shared<rclcpp::Node>("node", "ns", no);
{
auto param = node->declare_parameter("integer_override_not_given", rclcpp::PARAMETER_INTEGER);
EXPECT_EQ(rclcpp::PARAMETER_NOT_SET, param.get_type());
// Throws if not set before access
EXPECT_THROW(
node->get_parameter("integer_override_not_given"),
rclcpp::exceptions::ParameterUninitializedException);
}
}NOTE: refer to the test case without allow_undeclared_parameters(true) in the node.
Expected behavior
test case passed
Actual behavior
failed with log
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TestNode
[ RUN ] TestNode.parameter_uninitialized_exception_even_if_allow_undeclared
/home/chenlh/Projects/ROS2/ros2-master/src/ros2/rclcpp/rclcpp/test/rclcpp/test_node.cpp:3379: Failure
Expected: node->get_parameter("integer_override_not_given") throws an exception of type rclcpp::exceptions::ParameterUninitializedException.
Actual: it throws nothing.
[ FAILED ] TestNode.parameter_uninitialized_exception_even_if_allow_undeclared (44 ms)
[----------] 1 test from TestNode (44 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (57 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestNode.parameter_uninitialized_exception_even_if_allow_undeclared
1 FAILED TEST
Additional information
compared to rclpy, the logic of rclcpp
rclcpp/rclcpp/src/rclcpp/node_interfaces/node_parameters.cpp
Lines 933 to 945 in edbfe14
| if ( | |
| parameters_.end() != param_iter && | |
| (param_iter->second.value.get_type() != rclcpp::ParameterType::PARAMETER_NOT_SET || | |
| param_iter->second.descriptor.dynamic_typing)) | |
| { | |
| return rclcpp::Parameter{name, param_iter->second.value}; | |
| } else if (this->allow_undeclared_) { | |
| return rclcpp::Parameter{}; | |
| } else if (parameters_.end() == param_iter) { | |
| throw rclcpp::exceptions::ParameterNotDeclaredException(name); | |
| } else { | |
| throw rclcpp::exceptions::ParameterUninitializedException(name); | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels