[ros-users] [Discourse.ros.org] [Next Generation ROS] Composition and Parameters: Best Practice Suggestions

dayoung99 ros.discourse at gmail.com
Tue Mar 28 23:12:18 UTC 2017




I saw that this was moved, but I believe I am running into an issue that is independent of the ParameterService starting by default.

I haven't seen an example of doing ros params not involving the "manual_composition" yet.  All the tutorials for parameters still appear to use clients/services.

Looking over the comments for the register_param_change_callback, it appears that the callback should be doing set_parameters_atomically, unless I am misreading that.

This is what I have:

    auto node = rclcpp::node::Node::make_shared(path_control_auditor::NODE_NAME);
    auto paramServer = make_shared<rclcpp::parameter_service::ParameterService>(node);
    node->set_parameters({ rcllcpp::parameter::ParameterVariant("someVar", ""), });
    node->register_param_change_callback(
    [node](const std::vector<rclcpp::parameter::ParameterVariant> params) {
        for (auto param : params)
        {
            std::cout << "Parameter name: " << param.get_name() << std::endl;
            std::cout << "Parameter value (" << param.get_type_name() << "): " <<
                param.value_to_string() << std::endl;
        }
        rcl_interfaces::msg::SetParametersResult result;
        result = node->set_parameters_atomically(params);
        return result;
    }
    );


Then when I use ros2params to set the parameter.  Callback occurs, but as soon as "set_paremeters_atomically" occurs, I get memory violations.  If I fail to call that I see no problems.  

So am I reading the comments correctly?  Should I be calling "set_parameters_atomically"

FYI, I am using Alpha 8 on Windows.

Thanks,






---
[Visit Topic](https://discourse.ros.org/t/composition-and-parameters-best-practice-suggestions/1001/10) or reply to this email to respond.




More information about the ros-users mailing list