ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Node does not subscribed multipletopics

asked 2016-10-04 11:23:24 -0500

alby941 gravatar image

Hi all, I have the following situation: have a constructor

unionNode() {

//publish a marker of the reconstructed object
marker_pub= n.advertise<visualization_msgs::Marker>("final_marker_visual", 1);
sub_bounding=n.subscribe<yolo_cropper::bb>("/bounding_coordinates",10,&unionNode::bbCallback,this);
yolo_Img=n.subscribe<sensor_msgs::Image>("/yolo_show",10,&unionNode::yoloCallback,this);
sub_depth = n.subscribe<sensor_msgs::Image>("/dmde/depth",10,&unionNode::depthCallback,this);
f=400;
Cx=376;
Cy=240;

    std::cout<<"Constructor Builded"<<std::endl;}

where the node must subscribe itself to the three topics above described. I tried also with the Synchronizer message filter tools, but with the same problem.

When I run main:

int main(int argc, char **argv){
ros::init(argc, argv, "union");
unionNode();
ros::spin();}

I see "constructor builded" text... but if I open rqt_grap or rosnode_info I see my node Union is not subscribed to any topics... What should it be? The 3 topics are active , I v seen with rostopic echo... Thanks

edit retag flag offensive close merge delete

Comments

I don't see a ros::NodeHandle anywhere in your code, but you're obviously creating one somewhere. Note that if all of your NodeHandles go out of scope, roscpp will stop and all of your subscribers will stop.

ahendrix gravatar image ahendrix  ( 2016-10-04 17:44:45 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-04 15:46:50 -0500

GuillaumeB gravatar image

Hello,

your code seems correct.

You could try to print something in your callbacks something like:

    void unionNode::bbCallback(const yolo_cropper::bb::ConstPtr& msg){
      std::cout<<"bbCallback"<<std::endl;
    }

You could try to run

rosnode info /union

And see if the subscribers are declared

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-04 11:23:24 -0500

Seen: 112 times

Last updated: Oct 04 '16