Skip to content

Commit

Permalink
Merge pull request #76 from eclipse-zenoh/fix_75
Browse files Browse the repository at this point in the history
Fix overwritten 'mode' and 'domain' values from config file
  • Loading branch information
gabrik authored Jan 31, 2024
2 parents 9e68f8a + b961cee commit d5d6a95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
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

0 comments on commit d5d6a95

Please sign in to comment.