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

Fix overwritten 'mode' and 'domain' values from config file #76

Merged
merged 1 commit into from
Jan 31, 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
8 changes: 5 additions & 3 deletions zenoh-bridge-ros2dds/src/bridge_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub struct BridgeArgs {
#[arg(short, long)]
pub namespace: Option<String>,
/// The DDS Domain ID. Default to $ROS_DOMAIN_ID environment variable if defined, or to 0 otherwise.
#[arg(short, long, default_value("0"), env("ROS_DOMAIN_ID"))]
pub domain: u32,
#[arg(short, long, env("ROS_DOMAIN_ID"))]
pub domain: Option<u32>,
/// Configure CycloneDDS to use only the localhost interface. If not set, a $ROS_LOCALHOST_ONLY=1 environment variable activates this option.
/// When this flag is not active, CycloneDDS will pick the interface defined in "$CYCLONEDDS_URI" configuration, or automatically choose one.
#[arg(
Expand Down Expand Up @@ -98,7 +98,9 @@ impl From<&BridgeArgs> for Config {

insert_json5_option(&mut config, "plugins/ros2dds/id", &args.id);
insert_json5_option(&mut config, "plugins/ros2dds/namespace", &args.namespace);
insert_json5(&mut config, "plugins/ros2dds/domain", &args.domain);
if let Some(domain) = args.domain {
insert_json5(&mut config, "plugins/ros2dds/domain", &domain);
}
insert_json5(
&mut config,
"plugins/ros2dds/ros_localhost_only",
Expand Down
11 changes: 6 additions & 5 deletions zenoh-bridge-ros2dds/src/zenoh_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pub struct CommonArgs {
#[arg(short, long)]
/// A configuration file.
pub config: Option<String>,
#[arg(short, long, default_value = "peer")]
/// The Zenoh session mode.
pub mode: Wai,
#[arg(short, long)]
/// The Zenoh session mode [default: peer].
pub mode: Option<Wai>,
#[arg(short = 'e', long)]
/// Endpoints to connect to.
pub connect: Vec<String>,
Expand All @@ -61,8 +61,9 @@ impl From<&CommonArgs> for Config {
None => Config::default(),
};
match value.mode {
Wai::Peer => config.set_mode(Some(zenoh::scouting::WhatAmI::Peer)),
Wai::Client => config.set_mode(Some(zenoh::scouting::WhatAmI::Client)),
Some(Wai::Peer) => config.set_mode(Some(zenoh::scouting::WhatAmI::Peer)),
Some(Wai::Client) => config.set_mode(Some(zenoh::scouting::WhatAmI::Client)),
None => Ok(None),
}
.unwrap();
if !value.connect.is_empty() {
Expand Down