ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to get ros2 param list to work with simple custom node?

asked 2021-08-31 09:51:05 -0600

Hakaishin gravatar image

I have following test.cpp:

#include <project/test.h>

void signalHandler(int signum){
    std::cerr << "Received signal" << std::endl;

int main(int argc, char * argv[])
    signal(SIGTERM, signalHandler);

    rclcpp::init(argc, argv);

    rclcpp::executors::SingleThreadedExecutor exe;

    std::shared_ptr<Foo> lc_node = std::make_shared<Foo>();

//    rclcpp::shutdown();
    std::cerr << "Closed" << std::endl;
    return 0;

with test.h just being:

#include <rclcpp/rclcpp.hpp>
#include <rclcpp_lifecycle/lifecycle_node.hpp>

class Foo : public rclcpp_lifecycle::LifecycleNode {
    Foo() : rclcpp_lifecycle::LifecycleNode("foo"){
        std::cerr << "Running test node" << std::endl;



now I can run the node successfully directly from clion and everything works, callbacks get called topics get published and I see my published markers in rviz. Now I wanted to integrate with rqt but when I try to click on the node it just freezes and gives me following error message:

[WARN] [1630415189.108735450] [rqt_reconfigure]: Failed to retrieve parameters from node: asynchronous service call failed: the target node may not be spinning

ros2 param list returns Exception while calling service of node '/foo': None

What am I missing? Why can't I get the parameters of my node?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-03 10:09:22 -0600

ChuiV gravatar image

Since you're using a lifecycle node, You'll need to configure then activate the node before it actually does anything. You can do this with ros2 lifecycle set /foo configure then ros2 lifecycle set /foo activate. After that, the node should be running normally. You might need to implement the transition callbacks in your Foo class, I can't remember off the top of my head though.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2021-08-31 09:51:05 -0600

Seen: 312 times

Last updated: Sep 03 '21