| Crates.io | gz |
| lib.rs | gz |
| version | 0.9.0 |
| created_at | 2023-04-08 12:29:10.522294+00 |
| updated_at | 2025-04-25 15:34:37.575294+00 |
| description | Gazebo client library |
| homepage | |
| repository | https://github.com/eduidl/gz-rs |
| max_upload_size | |
| id | 833572 |
| size | 9,341 |
This crate contains following crates and re-exports them.
This crate is supporting following versions of Gazebo.
Gazebo version can be specified by a feature flag (fortress, garden, harmonic or ionic). If not specified, the version is determined by using pkg-config. When multiple versions are installed, the newer version takes precedence. If you want to use an older version, set the feature flag as above.
[dependencies]
gz = { version = "0.9.0", features = ["harmonic"] }
use gz::{msgs::stringmsg::StringMsg, transport::Node};
let mut node = Node::new().unwrap();
let mut publisher = node.advertise("topic_name").unwrap();
let topic = StringMsg {
data: "Hello, world!".to_string(),
..Default::default()
};
assert!(publisher.publish(&topic));
use gz::{msgs::stringmsg::StringMsg, transport::Node};
let mut node = Node::new().unwrap();
node.subscribe("topic_name", |msg: StringMsg| {
println!("Subscribed: {}", msg.data);
});
gz::transport::wait_for_shutdown();
subscribe_channel also uses callbacks internally. However, subscribe_channel may be easier to use when ownership is involved.
use gz::{msgs::stringmsg::StringMsg, transport::Node};
let mut node = Node::new().unwrap();
let rx = node.subscribe_channel::<StringMsg>("topic_name", 10).unwrap();
for msg in rx {
println!("Received: {}", msg.data);
}