Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- ~20% performance improvement on large images and strings with ROS1 and ROS1-zenoh backends by removing copies, and improving pre-allocation
- The macro for code generation will now search BOTH ROS1 and ROS2 package paths by default.
- Added code generation proc macros with shorter names: `generate_ros_types!` searches only explicit paths, `generate_ros_types_with_env!` searches explicit paths plus ROS environment paths, and the original macro names are deprecated aliases.

## 0.20.0 - March 2nd, 2026

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ All of this is backed by common traits for ROS messages, topics, and services. `
`roslibrust_codegen_macro` provides a convenient macro for generating these types:

```rust,ignore
// Will generate types from all packages in ROS_PACKAGE_PATH
roslibrust_codegen_macro::find_and_generate_ros_messages!();
// Will generate types from all packages in ROS_PACKAGE_PATH, AMENT_PREFIX_PATH, and COLCON_PREFIX_PATH
roslibrust_codegen_macro::generate_ros_types_with_env!();
```

If you want to see what the generated code looks like checkout [our generated messages in our test crate](https://github.com/RosLibRust/roslibrust/blob/master/roslibrust_test/src/ros1.rs).
Expand Down
7 changes: 2 additions & 5 deletions example_package_macro/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
use roslibrust::Publish;

// We're using the macro to generate our types
// We provide the macro with additional search paths beyond the ROS_PACKAGE_PATH
// We provide the macro with the exact paths to search, skipping environment discovery.
// The paths are assumed to be relative to the crate (or workspace) root
roslibrust::find_and_generate_ros_messages!(
"assets/ros1_test_msgs",
"assets/ros1_common_interfaces"
);
roslibrust::generate_ros_types!("assets/ros1_test_msgs", "assets/ros1_common_interfaces");

// Writing a simple behavior that uses the generic traits from roslibrust
// and the generated types from the macro above.
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/generic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Important to bring these traits into scope so we can use them

#[cfg(all(feature = "rosbridge", feature = "ros1"))]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces/std_msgs");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces/std_msgs");

#[cfg(all(feature = "rosbridge", feature = "ros1"))]
#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/generic_client_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! to create code that is generic of which communication backend it will use.

#[cfg(all(feature = "rosbridge", feature = "ros1"))]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

#[cfg(all(feature = "rosbridge", feature = "ros1"))]
#[tokio::main]
Expand Down
4 changes: 2 additions & 2 deletions roslibrust/examples/generic_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use roslibrust_common::RosMessageType;
/// We place the ros1 generated code into a module to prevent name collisions with the identically
/// named ros2 types.
mod ros1 {
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");
}

mod ros2 {
roslibrust_codegen_macro::find_and_generate_ros_messages_without_ros_package_path!(
roslibrust_codegen_macro::generate_ros_types!(
"assets/ros2_common_interfaces",
"assets/ros2_required_msgs/rcl_interfaces/builtin_interfaces"
);
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_async_service_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

/// This example shows how to perform async actions correctly in a service callback.
///
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_listener.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces/std_msgs");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces/std_msgs");

#[cfg(feature = "ros1")]
#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_publish_any.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

/// This example demonstrates ths usage of the .advertise_any() function
///
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_service_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

#[cfg(feature = "ros1")]
#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_service_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

#[cfg(feature = "ros1")]
#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/ros1_talker.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "ros1")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

#[cfg(feature = "ros1")]
#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/rosbridge_basic_publisher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "rosbridge")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces/std_msgs");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces/std_msgs");

/// This example creates a client, and publishes a message to the topic "talker"
/// Running this example at the same time as subscribe_and_log will have the two examples
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/rosbridge_calling_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "rosbridge")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces/rosapi");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces/rosapi");

/// This example shows calling a service
/// To run this example rosbridge and a roscore should be running
Expand Down
6 changes: 2 additions & 4 deletions roslibrust/examples/rosbridge_ros1_ros2_bridge_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
/// We place the ros1 generate code into a module to prevent name collisions with the identically
/// named ros2 types.
mod ros1 {
roslibrust_codegen_macro::find_and_generate_ros_messages!(
"assets/ros1_common_interfaces/std_msgs"
);
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces/std_msgs");
}

mod ros2 {
roslibrust_codegen_macro::find_and_generate_ros_messages_without_ros_package_path!(
roslibrust_codegen_macro::generate_ros_types!(
"assets/ros2_common_interfaces/std_msgs",
"assets/ros2_required_msgs/rcl_interfaces/builtin_interfaces"
);
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/rosbridge_service_server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// One way to import message definitions:
#[cfg(feature = "rosbridge")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

// A basic service server exampple, that logs the request is recieves and returns
// a canned response.
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/rosbridge_subscribe_and_log.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "rosbridge")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

/// A basic example of connecting and subscribing to data.
/// This example will log received messages if run at the same time as "basic_publisher".
Expand Down
2 changes: 1 addition & 1 deletion roslibrust/examples/tokio_stream_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use roslibrust_common::traits::*;
use tokio_stream::StreamExt;

roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
roslibrust_codegen_macro::generate_ros_types!("assets/ros1_common_interfaces");

async fn example_publisher_task(publisher: impl roslibrust::Publish<std_msgs::Header>) {
for seq in 0..50 {
Expand Down
4 changes: 4 additions & 0 deletions roslibrust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ pub use roslibrust_codegen as codegen;
pub use roslibrust_codegen_macro::find_and_generate_ros_messages;
#[cfg(feature = "macro")]
pub use roslibrust_codegen_macro::find_and_generate_ros_messages_without_ros_package_path;
#[cfg(feature = "macro")]
pub use roslibrust_codegen_macro::generate_ros_types;
#[cfg(feature = "macro")]
pub use roslibrust_codegen_macro::generate_ros_types_with_env;
3 changes: 2 additions & 1 deletion roslibrust_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,12 @@ impl PartialEq for ConstantInfo {
/// modified would trigger re-generation of the source. This function is designed to
/// be used either in a build.rs file or via the roslibrust_codegen_macro crate.
/// * `additional_search_paths` - A list of additional paths to search beyond those
/// found in ROS_PACKAGE_PATH environment variable.
/// found in ROS_PACKAGE_PATH, AMENT_PREFIX_PATH, and COLCON_PREFIX_PATH environment variables.
pub fn find_and_generate_ros_messages(
additional_search_paths: Vec<PathBuf>,
) -> Result<(TokenStream, Vec<PathBuf>), Error> {
let mut ros_package_paths = utils::get_search_paths();
ros_package_paths.extend(utils::get_ros2_search_paths());
ros_package_paths.extend(additional_search_paths);
find_and_generate_ros_messages_without_ros_package_path(ros_package_paths)
}
Expand Down
Loading
Loading