Skip to content

Commit

Permalink
Clearer logging as suggested by code review
Browse files Browse the repository at this point in the history
Co-authored-by: Geoffrey Biggs <gbiggs@killbots.net>
  • Loading branch information
LoyVanBeek and gbiggs authored Nov 22, 2021
1 parent 4796dcf commit bcaa063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 1, b: 2}"
If all is well, the output should contain `example_interfaces.srv.AddTwoInts_Response(sum=3)`

### Parametrizing Quality of Service
An advantage or ROS 2 over ROS 1 is the possibility to define different Quality of Service settings per topic.
The parameter bridge optionally allows for this as well:
An advantage of ROS 2 over ROS 1 is the possibility to define different Quality of Service settings per topic.
The parameter bridge optionally allows for this as well.
For some topics, like `/tf_static` this is actually required, as this is a latching topic in ROS 1.
In ROS 2 with the `parameter_bridge`, this requires that topic to be configured as such:

Expand Down
23 changes: 11 additions & 12 deletions src/parameter_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ rclcpp::QoS qos_from_params(XmlRpc::XmlRpcValue qos_params)
} catch (std::runtime_error & e) {
fprintf(
stderr,
"failed to create parametrize deadline: '%s'\n",
"failed to parse deadline: '%s'\n",
e.what());
} catch (XmlRpc::XmlRpcException & e) {
fprintf(
stderr,
"failed to create parametrize deadline: '%s'\n",
"failed to parse deadline: '%s'\n",
e.getMessage().c_str());
}
}
Expand All @@ -128,32 +128,31 @@ rclcpp::QoS qos_from_params(XmlRpc::XmlRpcValue qos_params)
} catch (std::runtime_error & e) {
fprintf(
stderr,
"failed to create parametrize lifespan: '%s'\n",
"failed to parse lifespan: '%s'\n",
e.what());
} catch (XmlRpc::XmlRpcException & e) {
fprintf(
stderr,
"failed to create parametrize lifespan: '%s'\n",
"failed to parse lifespan: '%s'\n",
e.getMessage().c_str());
}
}

if (qos_params.hasMember("liveliness")) {
if (qos_params["liveliness"].getType() == XmlRpc::XmlRpcValue::TypeInt) {
printf("liviness is an int\n");
try {
auto liveliness = static_cast<int>(qos_params["liveliness"]);
ros2_publisher_qos.liveliness(static_cast<rmw_qos_liveliness_policy_t>(liveliness));
printf("liveliness: %i, ", static_cast<int>(liveliness));
} catch (std::runtime_error & e) {
fprintf(
stderr,
"failed to create parametrize liveliness: '%s'\n",
"failed to parse liveliness: '%s'\n",
e.what());
} catch (XmlRpc::XmlRpcException & e) {
fprintf(
stderr,
"failed to create parametrize liveliness: '%s'\n",
"failed to parse liveliness: '%s'\n",
e.getMessage().c_str());
}
} else if (qos_params["liveliness"].getType() == XmlRpc::XmlRpcValue::TypeString) {
Expand Down Expand Up @@ -186,18 +185,18 @@ rclcpp::QoS qos_from_params(XmlRpc::XmlRpcValue qos_params)
} catch (std::runtime_error & e) {
fprintf(
stderr,
"failed to create parametrize liveliness: '%s'\n",
"failed to parse liveliness: '%s'\n",
e.what());
} catch (XmlRpc::XmlRpcException & e) {
fprintf(
stderr,
"failed to create parametrize liveliness: '%s'\n",
"failed to parse liveliness: '%s'\n",
e.getMessage().c_str());
}
} else {
fprintf(
stderr,
"failed to create parametrize liveliness, parameter was not a string or int \n");
"failed to parse liveliness, parameter was not a string or int \n");
}
}

Expand All @@ -211,12 +210,12 @@ rclcpp::QoS qos_from_params(XmlRpc::XmlRpcValue qos_params)
} catch (std::runtime_error & e) {
fprintf(
stderr,
"failed to create parametrize liveliness_lease_duration: '%s'\n",
"failed to parse liveliness_lease_duration: '%s'\n",
e.what());
} catch (XmlRpc::XmlRpcException & e) {
fprintf(
stderr,
"failed to create parametrize liveliness_lease_duration: '%s'\n",
"failed to parse liveliness_lease_duration: '%s'\n",
e.getMessage().c_str());
}
}
Expand Down

0 comments on commit bcaa063

Please sign in to comment.