Skip to content

Commit

Permalink
Fixes for default parameters (#33)
Browse files Browse the repository at this point in the history
* add start_type_description_service default parameter

* add option to show default parameters

* formatting

Co-authored-by: Dominik <45536968+authaldo@users.noreply.github.com>

---------

Co-authored-by: Dominik <45536968+authaldo@users.noreply.github.com>
  • Loading branch information
ottojo and authaldo authored Feb 3, 2024
1 parent bf394a9 commit 8c3e5b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/service_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ServiceWrapper {

void checkForTimeouts();

void setIgnoreDefaultParameters(bool ignoreDefaultParameters);

private:
void threadFunc();
void handleRequest(const RequestPtr &request);
Expand Down
12 changes: 12 additions & 0 deletions src/rig_reconfigure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ int main(int argc, char *argv[]) {

bool shouldResetLayout = false;
bool showInfo = false;
bool ignoreDefaultParameters = true;
serviceWrapper.setIgnoreDefaultParameters(ignoreDefaultParameters);

// Main loop
while (!glfwWindowShouldClose(window)) {
Expand Down Expand Up @@ -295,6 +297,16 @@ int main(int argc, char *argv[]) {
ImGui::EndMenu();
}

if (ImGui::BeginMenu("Parameters")) {
bool propertyChanged = ImGui::MenuItem("Hide default parameters", nullptr, &ignoreDefaultParameters);
serviceWrapper.setIgnoreDefaultParameters(ignoreDefaultParameters);
if (propertyChanged && !curSelectedNode.empty()) {
// Reload parameters if menu item was toggled
serviceWrapper.pushRequest(std::make_shared<Request>(Request::Type::QUERY_NODE_PARAMETERS));
}
ImGui::EndMenu();
}

if (ImGui::BeginMenu("Info")) {
ImGui::MenuItem("Show info", nullptr, &showInfo);
ImGui::EndMenu();
Expand Down
11 changes: 9 additions & 2 deletions src/service_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "service_wrapper.hpp"
#include <chrono>
#include <regex>

using namespace std::chrono_literals;

Expand Down Expand Up @@ -230,9 +231,11 @@ void ServiceWrapper::nodeParametersReceived(const rclcpp::Client<rcl_interfaces:
auto valueRequest = std::make_shared<ParameterValueRequest>(future.get()->result.names);

if (ignoreDefaultParameters) {
// ignore node used for querying the services
// Hide default parameters "use_sim_time", "qos_overrides./*", "start_type_description_service"
static std::regex HIDDEN_PARAMETER_REGEX = std::regex(
"^use_sim_time$|^qos_overrides\\.\\/.*$|^start_type_description_service$");
std::erase_if(valueRequest->parameterNames, [](const std::string &s) {
return (s.starts_with("qos_overrides./") || s.starts_with("use_sim_time"));
return std::regex_match(s, HIDDEN_PARAMETER_REGEX);
});
}

Expand Down Expand Up @@ -285,3 +288,7 @@ void ServiceWrapper::parameterModificationResponseReceived(const rclcpp::Client<

responseQueue.push(response);
}

void ServiceWrapper::setIgnoreDefaultParameters(bool ignoreDefaultParameters_) {
this->ignoreDefaultParameters = ignoreDefaultParameters_;
}

0 comments on commit 8c3e5b1

Please sign in to comment.