10 releases

new 0.9.0 Apr 25, 2025
0.7.4 Dec 3, 2023
0.7.3 Oct 31, 2023
0.4.0 Jul 2, 2023

#58 in Robotics

Download history 1/week @ 2025-01-26 1/week @ 2025-02-02 1/week @ 2025-02-16 2/week @ 2025-02-23 15/week @ 2025-03-02 1/week @ 2025-03-30 2/week @ 2025-04-13 58/week @ 2025-04-20

61 downloads per month

Apache-2.0

13MB
275K SLoC

Rust 232K SLoC // 0.1% comments C++ 41K SLoC // 0.2% comments Bazel 1.5K SLoC // 0.1% comments Python 681 SLoC // 0.5% comments Shell 96 SLoC // 0.5% comments

gz

crates.io

This crate contains following crates and re-exports them.

  • gz-msgs: Rust implementation of Gazebo Messages
  • gz-transport: Rust wrapper of Gazebo Transport

Gazebo version

This crate is supporting following versions of Gazebo.

  • Fortress
  • Garden (EOL)
  • Harmonic
  • Ionic

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"] }

Dependencies

  • Gazebo
    • gz-msgs
    • gz-transport
  • pkg-config

Examples

Example: Publish

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));

Example: Subscribe (callback)

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();

Example: Subscribe (channel)

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);
}

Dependencies