Node created at runtime will not start
I'm having some trouble getting a node that is created at run time to be "recognized". Here is the node class:
class node {
private:
ros::NodeHandle *n;
public:
node() { n = NULL; }
ros::NodeHandle getHandle() { return *n; }
init(int argc, char **argv, std::string s) {
ros::init(argc, argv, s);
}
void create() {
if (n == NULL) { n = new ros::NodeHandle(); }
}
};
I use the node class inside of a coorinator
class coordinator {
private:
node myNode;
/** Pub, Subs, etc go here */
public:
void setup(int argc, char **argv, std::string s) {
myNode.init(argc, argv, s);
myNode.create();
/* setup pubs, subs etc using myNode.getHandle() */
}
};
int main(int argc, char **arv) {
ros::init(argc, argc, "starter");
coordinator c;
c.init(argc, argv, "coordinator");
c.setup();
...
}
When I call c.setup()
from a main method of another node, the newly created node doesn't show up using rosnode list
and clients that requests its services wait forever. I can't use rosspawn
because I'm using ros fuerte.
EDIT: I even tried to pass the main methods node handle into the node constructor but it still doesn't get recognized.