Skip to content

Commit

Permalink
reconfigurable transport scoped parameters for theora_image_transport
Browse files Browse the repository at this point in the history
- runtime reconfiguration for publisher and subscriber
- <image>.<transport>.<param> as future replacement of  <image>.<param>
- e.g. `image.theora.target_bitrate` instead of `image.target_bitrate`
- support both ways for now
- emit deprecation warnings on setting through non-transport scoped parameter
- synchronize deprecated changes to new ones
- this is necessary for dynamic reconfigure

The publisher is a bit more complex here
- in general we reload config on publish
- but some code paths (conditional compilation)
- would result in resetting context on every config reload
- so we flag to reload config only on parameter event change
- and reload it once on init to mimic ROS1 dynamic reconfigure setup

The subscriber is simple as it already had necessary checks.

Related to #140

(cherry picked from commit b7d409f)

# Conflicts:
#	theora_image_transport/src/theora_publisher.cpp
#	theora_image_transport/src/theora_subscriber.cpp
  • Loading branch information
bmegli authored and mergify[bot] committed May 2, 2023
1 parent 29e29e3 commit 56d4a65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions theora_image_transport/src/theora_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,20 @@ void TheoraPublisher::updateKeyframeFrequency() const
void TheoraPublisher::declareParameter(const std::string &base_name,
const ParameterDefinition &definition)
{
<<<<<<< HEAD
//transport scoped parameter (e.g. image_raw.theora.quality)
=======
//transport scoped parameter (e.g. image_raw.compressed.format)
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
const std::string transport_name = getTransportName();
const std::string param_name = base_name + "." + transport_name + "." + definition.descriptor.name;
parameters_.push_back(param_name);

<<<<<<< HEAD
//deprecated non-scoped parameter name (e.g. image_raw.quality)
=======
//deprecated non-scoped parameter name (e.g. image_raw.format)
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
const std::string deprecated_name = base_name + "." + definition.descriptor.name;
deprecatedParameters_.push_back(deprecated_name);

Expand Down Expand Up @@ -453,7 +461,11 @@ void TheoraPublisher::onParameterEvent(ParameterEvent::SharedPtr event, std::str

size_t baseNameIndex = name.find(base_name); //name was generated from base_name, has to succeed
size_t paramNameIndex = baseNameIndex + base_name.size();
<<<<<<< HEAD
//e.g. `color.image_raw.` + `theora` + `quality`
=======
//e.g. `color.image_raw.` + `compressed` + `format`
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
std::string recommendedName = name.substr(0, paramNameIndex + 1) + transport + name.substr(paramNameIndex);

rclcpp::Parameter recommendedValue = node_->get_parameter(recommendedName);
Expand Down
12 changes: 12 additions & 0 deletions theora_image_transport/src/theora_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,20 @@ void TheoraSubscriber::internalCallback(const theora_image_transport::msg::Packe
void TheoraSubscriber::declareParameter(const std::string &base_name,
const ParameterDefinition &definition)
{
<<<<<<< HEAD
//transport scoped parameter (e.g. image_raw.theora.post_processing_level)
=======
//transport scoped parameter (e.g. image_raw.compressed.format)
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
const std::string transport_name = getTransportName();
const std::string param_name = base_name + "." + transport_name + "." + definition.descriptor.name;
parameters_.push_back(param_name);

<<<<<<< HEAD
//deprecated non-scoped parameter name (e.g. image_raw.post_processing_level)
=======
//deprecated non-scoped parameter name (e.g. image_raw.format)
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
const std::string deprecated_name = base_name + "." + definition.descriptor.name;
deprecatedParameters_.push_back(deprecated_name);

Expand Down Expand Up @@ -341,7 +349,11 @@ void TheoraSubscriber::onParameterEvent(ParameterEvent::SharedPtr event, std::st

size_t baseNameIndex = name.find(base_name); //name was generated from base_name, has to succeed
size_t paramNameIndex = baseNameIndex + base_name.size();
<<<<<<< HEAD
//e.g. `color.image_raw.` + `theora` + `post_processing_level`
=======
//e.g. `color.image_raw.` + `compressed` + `format`
>>>>>>> b7d409f (reconfigurable transport scoped parameters for theora_image_transport)
std::string recommendedName = name.substr(0, paramNameIndex + 1) + transport + name.substr(paramNameIndex);

rclcpp::Parameter recommendedValue = node_->get_parameter(recommendedName);
Expand Down

0 comments on commit 56d4a65

Please sign in to comment.