Ros topic published string cannot be captured
Dear my friends,
Recently, I have encountered the following problem.
I want my ros node to publish a string message if other node is sending request for this message and I want to differentiate each message sent, which means for each request only one string is sent out: I use the following command to publish the string (python code)
pub=rospy.Publisher('/act',String)
action_str='hello'
pub.publish(action_str)
I also use rostopic echo /act
to see whether the string has been sent, but i see nothing when running the ros node
But if I repeatedly send publish the same string using for loop (about 2000 loops), now I can see the message on the screen, but this is not what i want, I just want to publish once not multiple times.
I guess the issue here is due to the communication latency of ros?
Any help and suggestions are much much appreciated!!!
Juekun