Skip to content

Commit

Permalink
feat(rtc_manager_panel): add cooperateStatus state column (#104)
Browse files Browse the repository at this point in the history
* add another column

Signed-off-by: Go Sakayori <[email protected]>

* fix

Signed-off-by: Go Sakayori <[email protected]>

---------

Signed-off-by: Go Sakayori <[email protected]>
  • Loading branch information
go-sakayori authored Sep 12, 2024
1 parent 63eda19 commit 008d0b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
35 changes: 32 additions & 3 deletions common/rtc_manager_rviz_plugin/src/rtc_manager_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ RTCManagerPanel::RTCManagerPanel(QWidget * parent) : rviz_common::Panel(parent)
rtc_table_ = new QTableWidget();
rtc_table_->setColumnCount(column_size_);
rtc_table_->setHorizontalHeaderLabels(
{"ID", "Module", "AW Safe", "Received Cmd", "AutoMode", "StartDistance", "FinishDistance"});
{"ID", "Module", "AW\nSafe", "Recv\nCmd", "Auto\nMode", "State", "Start\nDistance",
"Finish\nDistance"});
rtc_table_->setVerticalHeader(vertical_header);
rtc_table_->setHorizontalHeader(horizontal_header);
rtc_table_layout->addWidget(rtc_table_);
Expand Down Expand Up @@ -438,13 +439,41 @@ void RTCManagerPanel::onRTCStatus(const CooperateStatusArray::ConstSharedPtr msg
rtc_table_->setCellWidget(cnt, 4, label);
}

// State
std::string module_state = "NONE";
{
switch (status.state.type) {
case State::WAITING_FOR_EXECUTION:
module_state = "Waiting";
break;
case State::RUNNING:
module_state = "Running";
break;
case State::ABORTING:
module_state = "Aborting";
break;
case State::SUCCEEDED:
module_state = "Succeeded";
break;
case State::FAILED:
module_state = "Failed";
break;
default:
break;
}
auto label = new QLabel(QString::fromStdString(module_state));
label->setAlignment(Qt::AlignCenter);
label->setText(QString::fromStdString(module_state));
rtc_table_->setCellWidget(cnt, 5, label);
}

// start distance
{
std::string start_distance = std::to_string(status.start_distance);
auto label = new QLabel(QString::fromStdString(start_distance));
label->setAlignment(Qt::AlignCenter);
label->setText(QString::fromStdString(start_distance));
rtc_table_->setCellWidget(cnt, 5, label);
rtc_table_->setCellWidget(cnt, 6, label);
}

// finish distance
Expand All @@ -453,7 +482,7 @@ void RTCManagerPanel::onRTCStatus(const CooperateStatusArray::ConstSharedPtr msg
auto label = new QLabel(QString::fromStdString(finish_distance));
label->setAlignment(Qt::AlignCenter);
label->setText(QString::fromStdString(finish_distance));
rtc_table_->setCellWidget(cnt, 6, label);
rtc_table_->setCellWidget(cnt, 7, label);
}

// add color for recognition
Expand Down
4 changes: 3 additions & 1 deletion common/rtc_manager_rviz_plugin/src/rtc_manager_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <tier4_rtc_msgs/msg/cooperate_status.hpp>
#include <tier4_rtc_msgs/msg/cooperate_status_array.hpp>
#include <tier4_rtc_msgs/msg/module.hpp>
#include <tier4_rtc_msgs/msg/state.hpp>
#include <tier4_rtc_msgs/srv/auto_mode.hpp>
#include <tier4_rtc_msgs/srv/cooperate_commands.hpp>
#endif
Expand All @@ -53,6 +54,7 @@ using tier4_rtc_msgs::msg::CooperateResponse;
using tier4_rtc_msgs::msg::CooperateStatus;
using tier4_rtc_msgs::msg::CooperateStatusArray;
using tier4_rtc_msgs::msg::Module;
using tier4_rtc_msgs::msg::State;
using tier4_rtc_msgs::srv::AutoMode;
using tier4_rtc_msgs::srv::CooperateCommands;
using unique_identifier_msgs::msg::UUID;
Expand Down Expand Up @@ -123,7 +125,7 @@ public Q_SLOTS:
QPushButton * wait_button_ptr_ = {nullptr};
QLabel * num_rtc_status_ptr_ = {nullptr};

size_t column_size_ = {7};
size_t column_size_ = {8};
std::string enable_auto_mode_namespace_ = "/planning/enable_auto_mode";
};

Expand Down

0 comments on commit 008d0b5

Please sign in to comment.