Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: operation mode debug panel #8933

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion visualization/tier4_adapi_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
ament_auto_add_library(${PROJECT_NAME} SHARED
src/route_tool.cpp
src/route_panel.cpp
src/state_panel.cpp
src/operation_mode_debug_panel.cpp
src/door_panel.cpp
)

Expand Down
2 changes: 2 additions & 0 deletions visualization/tier4_adapi_rviz_plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# tier4_adapi_rviz_plugin

This package contains tools for testing AD API. For general AD API usage, we recommend using [tier4_state_rviz_plugin](../tier4_state_rviz_plugin/README.md).

## RoutePanel

To use the panel, set the topic name from 2D Goal Pose Tool to `/rviz/routing/pose`.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<description>RoutePanel</description>
</class>

<class type="tier4_adapi_rviz_plugins::StatePanel" base_class_type="rviz_common::Panel">
<description>StatePanel</description>
<class type="tier4_adapi_rviz_plugins::OperationModeDebugPanel" base_class_type="rviz_common::Panel">
<description>OperationModeDebugPanel</description>
</class>

<class type="tier4_adapi_rviz_plugins::DoorPanel" base_class_type="rviz_common::Panel">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
//
// Copyright 2020 TIER IV, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "operation_mode_debug_panel.hpp"

#include <QGridLayout>
#include <QString>
#include <rviz_common/display_context.hpp>

#include <memory>
#include <string>

namespace tier4_adapi_rviz_plugins
{

OperationModeDebugPanel::OperationModeDebugPanel(QWidget * parent) : rviz_common::Panel(parent)

Check warning on line 29 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L29

Added line #L29 was not covered by tests
{
auto * layout = new QGridLayout;
setLayout(layout);

Check warning on line 32 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L31-L32

Added lines #L31 - L32 were not covered by tests

operation_mode_label_ptr_ = new QLabel("INIT");
operation_mode_label_ptr_->setAlignment(Qt::AlignCenter);
operation_mode_label_ptr_->setStyleSheet("border:1px solid black;");
layout->addWidget(operation_mode_label_ptr_, 0, 0, 2, 1);

Check warning on line 37 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L34-L37

Added lines #L34 - L37 were not covered by tests

auto_button_ptr_ = new QPushButton("AUTO");
connect(auto_button_ptr_, SIGNAL(clicked()), SLOT(onClickAutonomous()));
layout->addWidget(auto_button_ptr_, 0, 1);

Check warning on line 41 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L39-L41

Added lines #L39 - L41 were not covered by tests

stop_button_ptr_ = new QPushButton("STOP");
connect(stop_button_ptr_, SIGNAL(clicked()), SLOT(onClickStop()));
layout->addWidget(stop_button_ptr_, 0, 2);

Check warning on line 45 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L43-L45

Added lines #L43 - L45 were not covered by tests

local_button_ptr_ = new QPushButton("LOCAL");
connect(local_button_ptr_, SIGNAL(clicked()), SLOT(onClickLocal()));
layout->addWidget(local_button_ptr_, 1, 1);

Check warning on line 49 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L47-L49

Added lines #L47 - L49 were not covered by tests

remote_button_ptr_ = new QPushButton("REMOTE");
connect(remote_button_ptr_, SIGNAL(clicked()), SLOT(onClickRemote()));
layout->addWidget(remote_button_ptr_, 1, 2);

Check warning on line 53 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L51-L53

Added lines #L51 - L53 were not covered by tests

control_mode_label_ptr_ = new QLabel("INIT");
control_mode_label_ptr_->setAlignment(Qt::AlignCenter);
control_mode_label_ptr_->setStyleSheet("border:1px solid black;");
layout->addWidget(control_mode_label_ptr_, 2, 0);

Check warning on line 58 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L55-L58

Added lines #L55 - L58 were not covered by tests

enable_button_ptr_ = new QPushButton("Enable");
connect(enable_button_ptr_, SIGNAL(clicked()), SLOT(onClickAutowareControl()));
layout->addWidget(enable_button_ptr_, 2, 1);

Check warning on line 62 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L60-L62

Added lines #L60 - L62 were not covered by tests

disable_button_ptr_ = new QPushButton("Disable");
connect(disable_button_ptr_, SIGNAL(clicked()), SLOT(onClickDirectControl()));
layout->addWidget(disable_button_ptr_, 2, 2);
}

Check warning on line 67 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L64-L67

Added lines #L64 - L67 were not covered by tests

void OperationModeDebugPanel::onInitialize()

Check warning on line 69 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L69

Added line #L69 was not covered by tests
{
raw_node_ = this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();

Check warning on line 71 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L71

Added line #L71 was not covered by tests

sub_operation_mode_ = raw_node_->create_subscription<OperationModeState>(
"/api/operation_mode/state", rclcpp::QoS{1}.transient_local(),
std::bind(&OperationModeDebugPanel::onOperationMode, this, std::placeholders::_1));

Check warning on line 75 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L73-L75

Added lines #L73 - L75 were not covered by tests

client_change_to_autonomous_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/change_to_autonomous");

Check warning on line 78 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L78

Added line #L78 was not covered by tests

client_change_to_stop_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/change_to_stop");

Check warning on line 81 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L81

Added line #L81 was not covered by tests

client_change_to_local_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/change_to_local");

Check warning on line 84 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L84

Added line #L84 was not covered by tests

client_change_to_remote_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/change_to_remote");

Check warning on line 87 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L87

Added line #L87 was not covered by tests

client_enable_autoware_control_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/enable_autoware_control");

Check warning on line 90 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L90

Added line #L90 was not covered by tests

client_enable_direct_control_ =
raw_node_->create_client<ChangeOperationMode>("/api/operation_mode/disable_autoware_control");
}

Check warning on line 94 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L93-L94

Added lines #L93 - L94 were not covered by tests

template <typename T>
void callService(const rclcpp::Logger & logger, const typename rclcpp::Client<T>::SharedPtr client)

Check warning on line 97 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L97

Added line #L97 was not covered by tests
{
auto req = std::make_shared<typename T::Request>();

RCLCPP_DEBUG(logger, "client request");

Check warning on line 101 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L101

Added line #L101 was not covered by tests

if (!client->service_is_ready()) {
RCLCPP_DEBUG(logger, "client is unavailable");

Check warning on line 104 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L104

Added line #L104 was not covered by tests
return;
}

client->async_send_request(req, [logger](typename rclcpp::Client<T>::SharedFuture result) {
RCLCPP_DEBUG(

Check warning on line 109 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L108-L109

Added lines #L108 - L109 were not covered by tests
logger, "Status: %d, %s", result.get()->status.code, result.get()->status.message.c_str());
});
}

void OperationModeDebugPanel::onClickAutonomous()

Check warning on line 114 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L114

Added line #L114 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_change_to_autonomous_);
}

Check warning on line 117 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L116-L117

Added lines #L116 - L117 were not covered by tests

void OperationModeDebugPanel::onClickStop()

Check warning on line 119 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L119

Added line #L119 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_change_to_stop_);
}

Check warning on line 122 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L121-L122

Added lines #L121 - L122 were not covered by tests

void OperationModeDebugPanel::onClickLocal()

Check warning on line 124 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L124

Added line #L124 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_change_to_local_);
}

Check warning on line 127 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L126-L127

Added lines #L126 - L127 were not covered by tests

void OperationModeDebugPanel::onClickRemote()

Check warning on line 129 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L129

Added line #L129 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_change_to_remote_);
}

Check warning on line 132 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L131-L132

Added lines #L131 - L132 were not covered by tests

void OperationModeDebugPanel::onClickAutowareControl()

Check warning on line 134 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L134

Added line #L134 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_enable_autoware_control_);
}

Check warning on line 137 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L136-L137

Added lines #L136 - L137 were not covered by tests

void OperationModeDebugPanel::onClickDirectControl()

Check warning on line 139 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L139

Added line #L139 was not covered by tests
{
callService<ChangeOperationMode>(raw_node_->get_logger(), client_enable_direct_control_);
}

Check warning on line 142 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L141-L142

Added lines #L141 - L142 were not covered by tests

void OperationModeDebugPanel::onOperationMode(const OperationModeState::ConstSharedPtr msg)

Check warning on line 144 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L144

Added line #L144 was not covered by tests
{
const auto updateLabel = [](QLabel * label, QString text, QString style) {
label->setText(text);
label->setStyleSheet(style);
};

Check warning on line 149 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L147-L149

Added lines #L147 - L149 were not covered by tests

const auto updateButton = [](QPushButton * button, bool available) {

Check warning on line 151 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L151

Added line #L151 was not covered by tests
if (available) {
button->setStyleSheet("color: black;");

Check warning on line 153 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L153

Added line #L153 was not covered by tests
} else {
button->setStyleSheet("color: white;");

Check warning on line 155 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L155

Added line #L155 was not covered by tests
}
};

Check warning on line 157 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L157

Added line #L157 was not covered by tests

// Update current operation mode.

QString state = "";
QString style = "";

Check warning on line 162 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L161-L162

Added lines #L161 - L162 were not covered by tests

switch (msg->mode) {
case OperationModeState::AUTONOMOUS:
state = "AUTONOMOUS";
style = "background-color: #00FF00;"; // green

Check warning on line 167 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L164-L167

Added lines #L164 - L167 were not covered by tests
break;

case OperationModeState::LOCAL:
state = "LOCAL";
style = "background-color: #FFFF00;"; // yellow

Check warning on line 172 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L170-L172

Added lines #L170 - L172 were not covered by tests
break;

case OperationModeState::REMOTE:
state = "REMOTE";
style = "background-color: #FFFF00;"; // yellow

Check warning on line 177 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L175-L177

Added lines #L175 - L177 were not covered by tests
break;

case OperationModeState::STOP:
state = "STOP";
style = "background-color: #FFA500;"; // orange

Check warning on line 182 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L180-L182

Added lines #L180 - L182 were not covered by tests
break;

default:
state = "UNKNOWN (" + QString::number(msg->mode) + ")";
style = "background-color: #FF0000;"; // red

Check warning on line 187 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L186-L187

Added lines #L186 - L187 were not covered by tests
break;
}

if (msg->is_in_transition) {
state += "\n(TRANSITION)";

Check warning on line 192 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L192

Added line #L192 was not covered by tests
}

updateLabel(operation_mode_label_ptr_, state, style);

Check warning on line 195 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L195

Added line #L195 was not covered by tests

// Update current control mode.

if (msg->is_autoware_control_enabled) {
updateLabel(control_mode_label_ptr_, "Enable", "background-color: #00FF00;"); // green

Check warning on line 200 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L200

Added line #L200 was not covered by tests
} else {
updateLabel(control_mode_label_ptr_, "Disable", "background-color: #FFFF00;"); // yellow

Check warning on line 202 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L202

Added line #L202 was not covered by tests
}

// Update operation mode available.

updateButton(auto_button_ptr_, msg->is_autonomous_mode_available);
updateButton(stop_button_ptr_, msg->is_stop_mode_available);
updateButton(local_button_ptr_, msg->is_local_mode_available);
updateButton(remote_button_ptr_, msg->is_remote_mode_available);

Check warning on line 210 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L207-L210

Added lines #L207 - L210 were not covered by tests

// Update control mode available.

updateButton(enable_button_ptr_, true);
updateButton(disable_button_ptr_, true);
}

Check warning on line 216 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L214-L216

Added lines #L214 - L216 were not covered by tests

} // namespace tier4_adapi_rviz_plugins

#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(tier4_adapi_rviz_plugins::OperationModeDebugPanel, rviz_common::Panel)

Check warning on line 221 in visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/tier4_adapi_rviz_plugin/src/operation_mode_debug_panel.cpp#L221

Added line #L221 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// Copyright 2020 TIER IV, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#ifndef OPERATION_MODE_DEBUG_PANEL_HPP_
#define OPERATION_MODE_DEBUG_PANEL_HPP_

#include <QLabel>
#include <QPushButton>
#include <rclcpp/rclcpp.hpp>
#include <rviz_common/panel.hpp>

#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
#include <autoware_adapi_v1_msgs/srv/change_operation_mode.hpp>

namespace tier4_adapi_rviz_plugins
{

class OperationModeDebugPanel : public rviz_common::Panel
{
Q_OBJECT

public:
explicit OperationModeDebugPanel(QWidget * parent = nullptr);
void onInitialize() override;

public Q_SLOTS: // NOLINT for Qt
void onClickAutonomous();
void onClickStop();
void onClickLocal();
void onClickRemote();
void onClickAutowareControl();
void onClickDirectControl();

protected:
using OperationModeState = autoware_adapi_v1_msgs::msg::OperationModeState;
using ChangeOperationMode = autoware_adapi_v1_msgs::srv::ChangeOperationMode;

QLabel * operation_mode_label_ptr_{nullptr};
QPushButton * stop_button_ptr_{nullptr};
QPushButton * auto_button_ptr_{nullptr};
QPushButton * local_button_ptr_{nullptr};
QPushButton * remote_button_ptr_{nullptr};

QLabel * control_mode_label_ptr_{nullptr};
QPushButton * enable_button_ptr_{nullptr};
QPushButton * disable_button_ptr_{nullptr};

rclcpp::Node::SharedPtr raw_node_;
rclcpp::Subscription<OperationModeState>::SharedPtr sub_operation_mode_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_change_to_autonomous_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_change_to_stop_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_change_to_local_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_change_to_remote_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_enable_autoware_control_;
rclcpp::Client<ChangeOperationMode>::SharedPtr client_enable_direct_control_;

void onOperationMode(const OperationModeState::ConstSharedPtr msg);
void changeOperationMode(const rclcpp::Client<ChangeOperationMode>::SharedPtr client);
};

} // namespace tier4_adapi_rviz_plugins

#endif // OPERATION_MODE_DEBUG_PANEL_HPP_
Loading
Loading