0
$\begingroup$

Rosanswers logo

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< >::operator->() const [with T = ros::Publisher::Impl]: Assertion `px != 0' failed. Aborted

Can anybody help understand what is going wrong ?


Originally posted by adesh on ROS Answers with karma: 36 on 2011-10-31

Post score: 2


Original comments

Comment by adesh on 2011-10-31:
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.

Comment by fergs on 2011-10-31:
I suggest you post the code where this is failing.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by joq with karma: 25443 on 2011-10-31

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.