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

Major re-org to crate / repository structure #215

Merged
merged 14 commits into from
Jan 6, 2025
Prev Previous commit
Next Next commit
REORG ALL THE THINGS
carter committed Dec 10, 2024
commit b4e87ee299c0ec520764fdcf7cc7cf06eb8f5295
88 changes: 25 additions & 63 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,12 +3,15 @@
members = [
"example_package",
"example_package_macro",
"roslibrust",
"roslibrust_codegen",
"roslibrust_codegen_macro",
"roslibrust_codegen",
"roslibrust_common",
"roslibrust_genmsg",
"roslibrust_test",
"roslibrust_mock",
"roslibrust_zenoh", "roslibrust_ros1", "roslibrust_common",
"roslibrust_ros1",
"roslibrust_rosbridge",
"roslibrust_test",
"roslibrust_zenoh",
"roslibrust",
]
resolver = "2"
55 changes: 19 additions & 36 deletions roslibrust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,66 +6,49 @@ edition = "2021"
license = "MIT"
readme = "../README.md"
description = "An library for interfacing with the ROS's rosbridge_server"
repository = "https://github.com/Carter12s/roslibrust"
repository = "https://github.com/roslibrust/roslibrust"
keywords = ["ROS", "robotics", "websocket", "json", "async"]
categories = ["science::robotics"]

[dependencies]
abort-on-drop = "0.2"
anyhow = "1.0"
dashmap = "5.3"
deadqueue = "0.2.4" # .4+ is required to fix bug with missing tokio dep
futures = "0.3"
futures-util = "0.3"
lazy_static = "1.4"
log = "0.4"
proc-macro2 = "1.0"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
smart-default = "0.6"
thiserror = "1.0"
tokio = { version = "1.20", features = [
"net",
"macros",
"time",
"rt-multi-thread",
] }
tokio-tungstenite = { version = "0.17" }
uuid = { version = "1.1", features = ["v4"] }
# TODO this crate shouldn't depend on codegen or codege_macro directly
roslibrust_codegen_macro = { path = "../roslibrust_codegen_macro", version = "0.11.1" }
roslibrust_codegen = { path = "../roslibrust_codegen", version = "0.11.1" }

# TODO version here
Carter12s marked this conversation as resolved.
Show resolved Hide resolved
roslibrust_common = { path = "../roslibrust_common" }
# TODO I think we should move rosapi into its own crate...
serde-big-array = { version = "0.5", optional = true } # Only used with rosapi
# TODO REAL VERSION HERE
roslibrust_ros1 = { path = "../roslibrust_ros1", optional = true }
roslibrust_rosbridge = { path = "../roslibrust_rosbridge", optional = true }
roslibrust_zenoh = { path = "../roslibrust_zenoh", optional = true }
roslibrust_mock = { path = "../roslibrust_mock", optional = true }

[dev-dependencies]
env_logger = "0.10"
env_logger = "0.11"
test-log = "0.2"
simple_logger = "5.0"
serde-big-array = "0.5"
log = "0.4"
tokio = { version = "1.20", features = ["macros", "rt-multi-thread"] }
Carter12s marked this conversation as resolved.
Show resolved Hide resolved
serde = { version = "1.0", features = ["derive"] }
Carter12s marked this conversation as resolved.
Show resolved Hide resolved
# Used to generate messages for the examples
roslibrust_codegen = { path = "../roslibrust_codegen" }
roslibrust_codegen_macro = { path = "../roslibrust_codegen_macro" }

[features]
default = []
# Note: all does not include running_bridge as that is only intended for CI
all = []
# Provides a rosapi rust interface
rosapi = ["serde-big-array"]
# TODO MAJOR remove this feature
Carter12s marked this conversation as resolved.
Show resolved Hide resolved
rosapi = []
# Intended for use with tests, includes tests that rely on a locally running rosbridge
Carter12s marked this conversation as resolved.
Show resolved Hide resolved
running_bridge = []
# For use with integration tests, indicating we are testing integration with a ros1 bridge
ros1_test = ["running_bridge", "ros1"]
# For use with integration tests, indicates we are testing integration with a ros2 bridge
ros2_test = ["running_bridge"]
# Provides access to experimental abstract trait topic_provider
topic_provider = []
# Provides a ros1 xmlrpc / TCPROS client
ros1 = ["roslibrust_ros1"]
# Provides a backend using the rosbridge websocket protocol
rosbridge = ["roslibrust_rosbridge"]
# Provides a backend using zenoh's ros1 format from zenoh-bridge-ros1
zenoh = ["roslibrust_zenoh"]
# Provides a mock backend useful for writing tests around nodes
mock = ["roslibrust_mock"]

[package.metadata.docs.rs]
features = ["ros1"]
20 changes: 11 additions & 9 deletions roslibrust/examples/basic_publisher.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use log::*;
use roslibrust::ClientHandle;

#[cfg(feature = "rosbridge")]
roslibrust_codegen_macro::find_and_generate_ros_messages!("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
/// pass messages between each other.
/// To run this example a rosbridge websocket server should be running at the deafult port (9090).
#[cfg(feature = "rosbridge")]
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), anyhow::Error> {
simple_logger::SimpleLogger::new()
.with_level(log::LevelFilter::Debug)
.without_timestamps() // required for running wsl2
.init()
.unwrap();
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use log::*;
lucasw marked this conversation as resolved.
Show resolved Hide resolved
use roslibrust::rosbridge::ClientHandle;
env_logger::init();

lucasw marked this conversation as resolved.
Show resolved Hide resolved
let client = ClientHandle::new("ws://localhost:9090").await?;
let publisher = client.advertise::<std_msgs::Header>("talker").await?;
@@ -33,3 +30,8 @@ async fn main() -> Result<(), anyhow::Error> {
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
}

#[cfg(not(feature = "rosbridge"))]
fn main() {
eprintln!("This example does nothing without compiling with the feature 'rosbridge'");
}
23 changes: 13 additions & 10 deletions roslibrust/examples/calling_service.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
use log::*;
use roslibrust::ClientHandle;

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

/// This example shows calling a service
/// To run this example rosbridge and a roscore should be running
/// As well as the rosapi node.
/// This node calls a service on the rosapi node to get the current ros time.
#[cfg(feature = "rosbridge")]
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), anyhow::Error> {
simple_logger::SimpleLogger::new()
.with_level(log::LevelFilter::Debug)
.without_timestamps() // Required for running in wsl2
.init()
.unwrap();
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use log::*;
use roslibrust::rosbridge::ClientHandle;

env_logger::init();

let client = ClientHandle::new("ws://localhost:9090").await?;

@@ -25,3 +23,8 @@ async fn main() -> Result<(), anyhow::Error> {
info!("Got time: {:?}", result);
Ok(())
}

#[cfg(not(feature = "rosbridge"))]
fn main() {
eprintln!("This example does nothing without compiling with the feature 'rosbridge'");
}
24 changes: 13 additions & 11 deletions roslibrust/examples/generic_client.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
//! Purpose of this example is to show how the TopicProvider trait can be use
//! to create code that is generic of which communication backend it will use.
#[cfg(feature = "topic_provider")]
use roslibrust::topic_provider::*;

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

#[cfg(feature = "topic_provider")]
#[cfg(all(feature = "rosbridge", feature = "ros1"))]
#[tokio::main]
async fn main() {
simple_logger::SimpleLogger::new()
.with_level(log::LevelFilter::Debug)
.without_timestamps() // required for running wsl2
.init()
.unwrap();
use roslibrust::{Publish, Subscribe, TopicProvider};
env_logger::init();

// TopicProvider cannot be an "Object Safe Trait" due to its generic parameters
// This means we can't do:
@@ -61,7 +59,7 @@ async fn main() {
}

// create a rosbridge handle and start node
let ros = roslibrust::ClientHandle::new("ws://localhost:9090")
let ros = roslibrust::rosbridge::ClientHandle::new("ws://localhost:9090")
.await
.unwrap();
let node = MyNode {
@@ -91,5 +89,9 @@ async fn main() {
// Note: this will not run without rosbridge running
}

#[cfg(not(feature = "topic_provider"))]
fn main() {}
#[cfg(not(all(feature = "rosbridge", feature = "ros1")))]
fn main() {
eprintln!(
"This example does nothing without compiling with the feature 'rosbridge' and 'ros1'"
);
}
Loading