0
$\begingroup$

Rosanswers logo

How do I publish a message from a file, found with rospack find, using rostopic pub -f from a launch file?

<node pkg="rostopic" type="rostopic" name="arbitrary_node_name" args="pub topic_name msg_type -l -f $(find package_name)/message_details.yaml" output="screen" />

doesn't publish anything.


Originally posted by noob_ros on ROS Answers with karma: 21 on 2020-08-29

Post score: 1


Original comments

Comment by noob_ros on 2020-08-31:
Correction: message is published but only partially (message_details specifies several ros messages separated by '---' but only first message is published)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

message is published but only partially (message_details specifies several ros messages separated by '---' but only first message is published)

it seems things are actually working as they should.

According to the wiki page (emphasis mine):

-f FILE

Read message fields from YAML file. YAML syntax is equivalent to output of rostopic echo. Messages are separated using YAML document separator ---. To use only the first message in a file, use the --latch option.

(this is the same info you'd get when running rostopic pub --help btw)

Note how it mentions the latch option and how that causes rostopic pub to only publish "the first message".

You have the -l command line option in your args attribute in the .launch file you show:

<node pkg="rostopic" type="rostopic" name="arbitrary_node_name" args="pub topic_name msg_type -l -f $(find package_name)/message_details.yaml" output="screen" />

That would be the short version of --latch.


Originally posted by gvdhoorn with karma: 86574 on 2020-09-01

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.