Closed ymd-stella closed 1 year ago
this sounds reasonable to me. it would be useful.
I noticed that the last argument is optional. For example, the following is valid.
ros2 topic pub foo std_msgs/Empty
Should we add an option like --stdin
to keep the default behavior?
cat foo.yaml | ros2 topic pub --stdin <topic_name> <msg_type>
Should we add an option like
--stdin
to keep the default behavior?
Yes, definitely.
This maybe conflicts with the functionality of https://github.com/ros2/ros2cli/pull/753. Similar functionality may be achieved with cat foo.yaml | vipe | tee foo.yaml | ros2 topic pub
.
Using vscode, this could be achieved with the following command.
export EDITOR="code --wait"
cat foo.yaml | vipe | tee tmp.yaml | ros2 topic pub foo std_msgs/Header --stdin; mv tmp.yaml foo.yaml
Interesting.
I have never used ROS 1, but according to the wiki it seems that rostopic pub
supported piped input, but also had a -f
flag to read from file:
$ rostopic echo chatter > chatter.bagy
Collect messages, then Ctrl-C
$ rostopic pub -f chatter.bagy bar std_msgs/String
Given the problem statement:
I want to load a message/request from a yaml file, not from the command line.
Would you consider to also add the -f
flag to ros2 topic pub
?
Feature request
Feature description
I want to load a message/request from a yaml file, not from the command line. The benefits of this would be similar to #753.
Targets are
In my opinion, it would be neat to be able to do the following
cat foo.yaml | ros2 topic pub <topic_name> <msg_type>
Implementation considerations
This maybe conflicts with the functionality of #753. Similar functionality may be achieved with
cat foo.yaml | vipe | tee foo.yaml | ros2 topic pub <topic_name> <msg_type>
.