18 #include "nav2_rviz_plugins/utils.hpp"
20 namespace nav2_rviz_plugins
24 rclcpp::Node::SharedPtr node,
bool & server_failed,
const std::string & server_name,
25 const std::string & plugin_type, QComboBox * combo_box)
28 if (combo_box->count() > 0) {
32 auto parameter_client = std::make_shared<rclcpp::SyncParametersClient>(node, server_name);
35 bool server_unavailable =
false;
36 while (!parameter_client->wait_for_service(std::chrono::seconds(1))) {
38 RCLCPP_ERROR(node->get_logger(),
"Interrupted while waiting for the service. Exiting.");
41 RCLCPP_INFO(node->get_logger(),
"%s service not available", server_name.c_str());
42 server_unavailable =
true;
49 if (server_unavailable) {
52 auto parameters = parameter_client->get_parameters({plugin_type});
53 auto str_arr = parameters[0].as_string_array();
54 combo_box->addItem(
"Default");
55 for (
auto str : str_arr) {
56 combo_box->addItem(QString::fromStdString(str));
58 combo_box->setCurrentText(
"Default");
61 QString getGoalStatusLabel(std::string title, int8_t status)
63 std::string status_str;
65 case action_msgs::msg::GoalStatus::STATUS_EXECUTING:
66 status_str =
"<font color=green>active</color>";
69 case action_msgs::msg::GoalStatus::STATUS_SUCCEEDED:
70 status_str =
"<font color=green>reached</color>";
73 case action_msgs::msg::GoalStatus::STATUS_CANCELED:
74 status_str =
"<font color=orange>canceled</color>";
77 case action_msgs::msg::GoalStatus::STATUS_ABORTED:
78 status_str =
"<font color=red>aborted</color>";
81 case action_msgs::msg::GoalStatus::STATUS_UNKNOWN:
82 status_str =
"unknown";
86 status_str =
"inactive";
91 "<table><tr><td width=150><b>" + title +
":</b></td><td>" +
92 status_str +
"</td></tr></table>").c_str());