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

publish message one time only #6

Closed
Cokthemhok opened this issue Jul 1, 2021 · 2 comments
Closed

publish message one time only #6

Cokthemhok opened this issue Jul 1, 2021 · 2 comments

Comments

@Cokthemhok
Copy link

Firstly, thank you for this awesome project.

And I have one question, can I publish ros message one time only?

@Sashiri
Copy link
Owner

Sashiri commented Jul 1, 2021

Unfortunately there's no library way of publishing once.
As of now you'd need to create a publisher, stop it, and then publish it manually whenever you're ready

var config = RosConfig(
  'ros_nodes_example_node',
  'http://127.0.0.1:11311/',
  '127.0.0.1',
  24125,
);
var client = RosClient(config);
var topic = RosTopic('chatter', StdMsgsString());
var publisher = await client.register(topic);
publisher.stopPublishing();
await publisher.publishData();
await client.unregister(topic);

Or if you pull new change

var config = RosConfig(
  'ros_nodes_example_node',
  'http://127.0.0.1:11311/',
  '127.0.0.1',
  24125,
);
var client = RosClient(config);
var topic = RosTopic('chatter', StdMsgsString());
var publisher = await client.register(topic, startPublishing: false);
await publisher.publishData();
await client.unregister(topic);

The end effect would be publishing topic once and then stopping ;D
If you have any other idea how would or should it work, then let's talk about it

Also if you look for a ros library that's more similar to c++/nodejs version, checkout https://github.com/TimWhiting/dartros

@Cokthemhok
Copy link
Author

Thank you so much.
I understood. :)

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

No branches or pull requests

2 participants