As a premise I must say I am very inexperienced with ROS.
I am trying to publish several ros messages but for every publish that I make I get the "publishing and latching message for 3.0 seconds", which looks like it is blocking for 3 seconds.
I'll leave you with an example of how I am publishing one single message:
rostopic pub -1 /heifu0/mavros/adsb/send mavros_msgs/ADSBVehicle "header: // then the rest of the message
I've also tried to use the following argument: -r 10, which sets the message frequency to 10Hz (which it does indeed) but only for the first message I.e. it keeps re-sending the first message 10 times a second.
Basically i want to publish a message without latching, if possible, so i can publish multiple messages a second. I have a constant stream of messages coming and i need to publish them all as fast as i can.
Part of the issue is that rostopic
CLI tools are really meant to be helpers for debugging/testing. It has certain limitations that you're seeing now. Unfortunately, you cannot remove that latching for 3 seconds message, even for 1-shot publications. Instead this is a job for an actual ROS node. It can be done in a couple of lines of Python like so:
import rospy
from mavros_msgs.msg import ADSBVehicle
class MyNode:
def __init__(self):
rospy.init_node('my_relay_node')
self.rate = rospy.Rate(10.0) #10Hz
self.status_pub = rospy.Publisher('/heifu0/mavros/adsb/send', ADSBVehicle, queue_size=10)
def check_and_send(self):
#Check for some condition here
if some_condition:
output_msg = ADSBVehicle()
#Fill in message fields here
self.status_pub.publish(output_msg)
def run_node(self):
while not rospy.is_shutdown():
self.check_and_send()
self.rate.sleep() #Run at 10Hz
if __name__ == '__main__':
node = myNode()
node.run_node()