Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load a message or request from a yaml file (or standard input) #842

Closed
ymd-stella opened this issue Jul 16, 2023 · 5 comments · Fixed by #844
Closed

Load a message or request from a yaml file (or standard input) #842

ymd-stella opened this issue Jul 16, 2023 · 5 comments · Fixed by #844

Comments

@ymd-stella
Copy link
Contributor

ymd-stella commented Jul 16, 2023

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

  • ros2 topic pub
  • ros2 service call
  • ros2 action send_goal

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>.

@fujitatomoya
Copy link
Collaborator

this sounds reasonable to me. it would be useful.

@ymd-stella
Copy link
Contributor Author

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>

@clalancette
Copy link
Contributor

Should we add an option like --stdin to keep the default behavior?

Yes, definitely.

@ymd-stella
Copy link
Contributor Author

ymd-stella commented Jul 25, 2023

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>.

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

@jrutgeer
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants