-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'ros2 param load' fails when double parameter in parameter file is in…
… scientific notation ros2/ros2cli#834 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
- Loading branch information
1 parent
012f6b2
commit a970d3b
Showing
2 changed files
with
34 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_msgs/msg/string.hpp> | ||
|
||
int main(int argc, char *argv[]) { | ||
rclcpp::init(argc, argv); | ||
|
||
rclcpp::NodeOptions node_options = rclcpp::NodeOptions(); | ||
node_options.allow_undeclared_parameters(true); | ||
node_options.automatically_declare_parameters_from_overrides(true); | ||
|
||
auto node = rclcpp::Node::make_shared("param_test", node_options); | ||
RCLCPP_INFO(node->get_logger(), "/param_test node created..."); | ||
// check if already declared | ||
rclcpp::Parameter param; | ||
if (node->has_parameter("test_double")) { | ||
param = node->get_parameter("test_double"); | ||
RCLCPP_INFO(node->get_logger(), "test_double param is %f", param.get_value<double>()); | ||
} else { | ||
// double type 0.0 initialized | ||
node->declare_parameter("test_double", 0.0); | ||
} | ||
// set parameter type double | ||
node->set_parameter(rclcpp::Parameter("test_double", 3e-06)); | ||
param = node->get_parameter("test_double"); | ||
RCLCPP_INFO(node->get_logger(), "test_double param is %f", param.get_value<double>()); | ||
|
||
rclcpp::executors::SingleThreadedExecutor executor; | ||
executor.add_node(node); | ||
executor.spin(); | ||
rclcpp::shutdown(); | ||
|
||
return 0; | ||
} |