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

Port to new plugin loading system #116

Merged
merged 3 commits into from
Apr 22, 2024
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
54 changes: 27 additions & 27 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ serde = "1.0.154"
serde_json = "1.0.94"
tracing = "0.1"
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = [
"unstable",
"unstable", "plugins"
] }
zenoh-collections = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh-core = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
Expand Down
31 changes: 10 additions & 21 deletions zenoh-bridge-ros2dds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use clap::Parser;
use ros_args::RosArgs;
use std::time::{Duration, SystemTime};
use zenoh::config::{Config, ModeDependentValue};
use zenoh::prelude::r#async::*;
use zenoh_plugin_trait::Plugin;

mod bridge_args;
mod ros_args;
Expand Down Expand Up @@ -55,6 +57,11 @@ fn parse_args() -> (Option<f32>, Config) {
.set_enabled(Some(ModeDependentValue::Unique(true)))
.unwrap();

// Enable admin space
config.adminspace.set_enabled(true).unwrap();
// Enable loading plugins
config.plugins_loading.set_enabled(true).unwrap();

(watchdog_opt, config)
}

Expand All @@ -67,35 +74,17 @@ async fn main() {
);

let (watchdog_period, config) = parse_args();
let rest_plugin = config.plugin("rest").is_some();

if let Some(period) = watchdog_period {
run_watchdog(period);
}

// create a zenoh Runtime (to share with plugins)
let runtime = zenoh::runtime::Runtime::new(config)
.await
.unwrap_or_else(|e| {
println!("{e}. Exiting...");
std::process::exit(-1);
});

// start REST plugin
if rest_plugin {
use zenoh_plugin_trait::Plugin;
zenoh_plugin_rest::RestPlugin::start("rest", &runtime).unwrap_or_else(|e| {
println!("{e}. Exiting...");
std::process::exit(-1);
});
}

// start DDS plugin
use zenoh_plugin_trait::Plugin;
zenoh_plugin_ros2dds::ROS2Plugin::start("ros2dds", &runtime).unwrap_or_else(|e| {
// create a zenoh session. Plugins are loaded during the open.
let _session = zenoh::open(config).res().await.unwrap_or_else(|e| {
println!("{e}. Exiting...");
std::process::exit(-1);
});

async_std::future::pending::<()>().await;
}

Expand Down