Can 1 node subsrcibe MSG from a topic and publish MSG to other topic at the same time?

14 views
Skip to first unread message

David Xiong

unread,
May 1, 2013, 11:30:23 PM5/1/13
to ros-by-...@googlegroups.com
Hi all,
    I downloaded the face_recognition demo and pi_tracker demo, and I want to combine the two which means that I want the turtlebot recognized me at first and move as I wish. However, it means that I must publish MSG to contract with pi_tracker after being recognized, so in the  face_rec_client.cpp, I added the code: if(strcmp(feedback->names[0].c_str(),"David")==0)
  {
    ros::NodeHandle n1;
    ros::Publisher chatter_pub = n1.advertise<std_msgs::String>("chatter1", 1000);
    std_msgs::String msg;
    std::stringstream ss;
    ss << "You are Master!";'t
    msg.data = ss.str();
    ROS_INFO("%s", msg.data.c_str());
    chatter_pub.publish(msg);
  }, which means that if the turtlebot recognized me(David), it should publish a msg on topic "chatter1"  as well as ROS_INFO the msg. NOW, THE QUESTION IS: it does print "You are Master" on screen, but I can't get it on topic "chatter1". so I think maybe I didn't publish the msg in the right way. anybody could help me? Thanks?

Patrick Goebel

unread,
May 2, 2013, 4:49:47 PM5/2/13
to ros-by-...@googlegroups.com
Hi David,

I saw that you posted your question on answers.ros.org and you seem to be getting good help there.

For others on the ros-by-example list, it is best to post general ROS questions to http://answers.ros.org since there is a huge database of existing question and answers there and many people tend to read and answer new questions.  (Don't forget to do a search on the answers.ros.org site first before asking a new question.)

The ros-by-example list is primarily for questions regarding the code used in the book.

--patrick
--
You received this message because you are subscribed to the Google Groups "ros-by-example" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-by-exampl...@googlegroups.com.
Visit this group at http://groups.google.com/group/ros-by-example?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages