Communication between Node and Nodelet [closed]

asked 2015-08-17 15:20:58 -0600

DaPhilz gravatar image

Hi,

I have a question. I created a nodelet and I want to initialize the nodelet with a specific name.

 ros::NodeHandle private_nh_;
 ros::Subscriber sub_;

 void callback(const std_msgs::StringConstPtr& str) {
 ROS_INFO("CALLBACK METHODE");
 }

 void onInit() {
    ROS_INFO("ON INIT CALLED");
   private_nh_ = getPrivateNodeHandle(); 
    sub_ = private_nh_.subscribe("myServo", 1,
        &callback, this);
}

I thought that the best way to do it is to build a subscriber.

I create the nodelet in a node shown below:

   int main(int argc, char **argv) {
     ros::init(argc, argv, "robotnodelet2");
     ros::NodeHandle nh;
 nodelet::Loader nodelet;
 nodelet::M_string remap(ros::names::getRemappings());
 nodelet::V_string nargv;
 nodelet.load("robotnodelet2/ServoImpl", "robotnodelet2/ServoImpl", remap,
        nargv);

ROS_INFO("PUBLISH SERVONAME");
pub = nh.advertise<std_msgs::String>("myServo", 1);//servo_name
std_msgs::StringPtr str(new std_msgs::String);
str->data = "servo1";
pub.publish(str);
   }

The Problem I have is that the callback methode is not called. I dont know why. Should I use the CallbackQueueManager or how I can interact and share informations between a node and the loaded nodelet. Thanks for any help. Philipp

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2018-09-24 12:13:11.379945