Ask Your Question
2

Publisher and Subscriber together problem

asked 2011-10-31 07:20:57 -0600

adesh gravatar image

updated 2011-10-31 19:31:00 -0600

kwc gravatar image

Hi I am trying to subscribe and publish at the same time. I tried to follow the suggestions given for similar questions but am not able to publish the data that I am getting using the callback function. My publisher is created in the constructor of a class and is stored in a member variable. I am calling the member.publish method in the callback function. Is this right ? Also, do I need to run the publish command in a dedicated loop again inside the callback function or the looping because of callback function is enough ?

Here is the error message that I get

[FATAL] [1320088082. 162199274] : ASSERTION FAILED file = /opt/ros/electric/stacks/ros_comm/clients/cpp/rospp/include/ros/publisher.h line = 101 cond = false message =

drive_base /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr< <template-parameter-1-1&gt; &gt;::operator-="">() const [with T = ros::Publisher::Impl]: Assertion `px != 0' failed. Aborted

Can anybody help understand what is going wrong ?

edit retag flag offensive close merge delete

Comments

I suggest you post the code where this is failing.
fergs gravatar imagefergs ( 2011-10-31 12:31:03 -0600 )edit
Thanks. I got what was going wrong. I was calling a function while the callback was looping. Because of that, the publish part (after the function call ) was never getting executed. But I still wonder, why would it show this message in that case.
adesh gravatar imageadesh ( 2011-10-31 13:38:09 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-10-31 13:56:14 -0600

joq gravatar image

Sounds like you already found the problem.

In answer to your original question: yes, you can publish from a subscriber callback. No extra loop is required.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-10-31 07:20:57 -0600

Seen: 600 times

Last updated: Oct 31 '11