Ask Your Question

Revision history [back]

Can I detect the currently active nodelet?

I have a helper function that I want to calls NODELET_INFO within:

void foo(int x) {
    NODELET_INFO_STREAM("X is " << x);
}

class MyNodelet : public ::nodelet::Nodelet {
    ...
    void some_callback(const SomeMsg::ConstPtr &msg) {
        foo(3)
    }
}

Obviously, this doesn't work, because the nodelet is not available within the helper function.

My next idea would be to somehow get the active nodelet:

void foo(int x) {
    nodelet::Nodelet *n = get_the_active_nodelet_somehow();
    ROS_INFO_STREAM_NAMED(n->getName(), "X is " << x);
}

Does a function like get_the_active_nodelet_somehow exist?

Can I detect the currently active nodelet?

I have a helper function that I want to calls NODELET_INFO within:

void foo(int x) {
    NODELET_INFO_STREAM("X is " << x);
}

class MyNodelet : public ::nodelet::Nodelet {
    ...
    void some_callback(const some_message_callback(const SomeMsg::ConstPtr &msg) {
        foo(3)
    }
}

Obviously, this doesn't work, because the nodelet is not available within the helper function.

My next idea would be to somehow get the active nodelet:

void foo(int x) {
    nodelet::Nodelet *n = get_the_active_nodelet_somehow();
    ROS_INFO_STREAM_NAMED(n->getName(), "X is " << x);
}

Does a function like get_the_active_nodelet_somehow exist?