Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node ignores yaml configuration when in non-global namespace #569

Closed
christianrauch opened this issue Sep 1, 2018 · 2 comments · Fixed by ros2/ros2cli#146
Closed

Node ignores yaml configuration when in non-global namespace #569

christianrauch opened this issue Sep 1, 2018 · 2 comments · Fixed by ros2/ros2cli#146
Assignees
Labels
bug Something isn't working

Comments

@christianrauch
Copy link

Bug report

Moving a node into a namespace prevents setting parameters via the yaml configuration and blocks ros2 param list.

Required Info:

  • Operating System: Ubuntu 18.04
  • Installation type: binary
  • Version or commit hash: bouncy
  • DDS implementation: Fast-RTPS
  • Client library (if applicable): rclcpp

Steps to reproduce issue

  • move the talker example node (talker.cpp) into a namespace (e.g. talker_ns) via inheriting from Node("talker", "talker_ns"):
#include <chrono>
#include <cstdio>
#include <memory>
#include <string>

#include "rclcpp/rclcpp.hpp"

#include "std_msgs/msg/string.hpp"

using namespace std::chrono_literals;

class Talker : public rclcpp::Node
{
public:
  explicit Talker(const std::string & topic_name) : Node("talker", "talker_ns")
  {
    msg_ = std::make_shared<std_msgs::msg::String>();

    // get parameter from yaml
    int lala;
    bool ret = get_parameter("some_int", lala);
    std::cout << "some_int: " << lala << " ("<<ret<<")" << std::endl;

    auto publish_message =
      [this]() -> void {
        msg_->data = "Hello World: " + std::to_string(count_++);
        RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", msg_->data.c_str())
        pub_->publish(msg_);
      };

    rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default;
    custom_qos_profile.depth = 7;
    pub_ = this->create_publisher<std_msgs::msg::String>(topic_name, custom_qos_profile);
    timer_ = this->create_wall_timer(1s, publish_message);
  }

private:
  size_t count_ = 1;
  std::shared_ptr<std_msgs::msg::String> msg_;
  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
  rclcpp::TimerBase::SharedPtr timer_;
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  auto node = std::make_shared<Talker>("chatter");
  rclcpp::spin(node);
  rclcpp::shutdown();
  return 0;
}
  • save yaml configuration from: https://github.com/ros2/ros2/wiki/Node-arguments as demo_params.yaml
  • run node with configuration file: ros2 run demo_nodes_cpp talker __params:=demo_params.yaml
  • check parameters in another terminal: ros2 param list

Expected behavior

  • terminal with node should show: some_int: 42 (1)
  • ros2 param list should list parameters

Actual behavior

  • terminal with node shows: some_int: 0 (0)
  • ros2 param list blocks

Additional information

If the yaml configuration to set or the API call to retrieve the parameter needs to be adapted, this should be mentioned in the documentation. However, ros2 param list should not block in any case.

@christianrauch
Copy link
Author

I missed the documentation at: https://github.com/ros2/rcl/blob/master/rcl_yaml_param_parser/README.md.

The parameters of the yaml file need also be moved into the namespace:

talker_ns:
    talker:
        ros__parameters:
            some_int: 42
            a_string: "Hello world"
            some_lists:
                some_integers: [1, 2, 3, 4]
                some_doubles : [3.14, 2.718]

However, I guess that the blocking of ros2 param list is still unexpected behaviour.

@dirk-thomas
Copy link
Member

dirk-thomas commented Sep 1, 2018

You don't need a custom talker for this. You can just push the existing talker node into a namespace using a command line argument: __ns:=/talker_ns.

The problem of not considering the namespace of a node in various cases is being addressed: ros2/rmw#142 After these patches have been merged this can be rechecked if it is still blocking (I wouldn't expect it to).

@dirk-thomas dirk-thomas added bug Something isn't working duplicate This issue or pull request already exists and removed duplicate This issue or pull request already exists labels Sep 1, 2018
@dirk-thomas dirk-thomas self-assigned this Sep 6, 2018
@dirk-thomas dirk-thomas added the in progress Actively being worked on (Kanban column) label Sep 6, 2018
@dirk-thomas dirk-thomas removed the in progress Actively being worked on (Kanban column) label Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants