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

fix(tier4_calibration_rviz_plugin): fix to set service name and exception failure #6973

Merged
merged 4 commits into from
May 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@
AccelBrakeMapCalibratorButtonPanel::AccelBrakeMapCalibratorButtonPanel(QWidget * parent)
: rviz_common::Panel(parent)
{
topic_label_ = new QLabel("Topic name of update suggest ");
topic_label_ = new QLabel("topic: ");

Check warning on line 37 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L37

Added line #L37 was not covered by tests
topic_label_->setAlignment(Qt::AlignCenter);

topic_edit_ =
new QLineEdit("/vehicle/calibration/accel_brake_map_calibrator/output/update_suggest");
connect(topic_edit_, SIGNAL(textEdited(QString)), SLOT(editTopic()));

service_label_ = new QLabel("service: ");
service_label_->setAlignment(Qt::AlignCenter);

Check warning on line 45 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L44-L45

Added lines #L44 - L45 were not covered by tests

service_edit_ = new QLineEdit("/vehicle/calibration/accel_brake_map_calibrator/update_map_dir");
connect(service_edit_, SIGNAL(textEdited(QString)), SLOT(editService()));

Check warning on line 48 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L47-L48

Added lines #L47 - L48 were not covered by tests

calibration_button_ = new QPushButton("Wait for subscribe topic");
calibration_button_->setEnabled(false);
connect(calibration_button_, SIGNAL(clicked(bool)), SLOT(pushCalibrationButton()));
Expand All @@ -56,8 +62,13 @@
topic_layout->addWidget(topic_label_);
topic_layout->addWidget(topic_edit_);

auto * service_layout = new QHBoxLayout;
service_layout->addWidget(service_label_);
service_layout->addWidget(service_edit_);

Check warning on line 67 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L65-L67

Added lines #L65 - L67 were not covered by tests

auto * v_layout = new QVBoxLayout;
v_layout->addLayout(topic_layout);
v_layout->addLayout(service_layout);

Check warning on line 71 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L71

Added line #L71 was not covered by tests
v_layout->addWidget(calibration_button_);
v_layout->addWidget(status_label_);

Expand All @@ -75,7 +86,7 @@
&AccelBrakeMapCalibratorButtonPanel::callbackUpdateSuggest, this, std::placeholders::_1));

client_ = raw_node->create_client<tier4_vehicle_msgs::srv::UpdateAccelBrakeMap>(
"/vehicle/calibration/accel_brake_map_calibrator/update_map_dir");
service_edit_->text().toStdString());

Check warning on line 89 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L89

Added line #L89 was not covered by tests
}

void AccelBrakeMapCalibratorButtonPanel::callbackUpdateSuggest(
Expand All @@ -85,6 +96,12 @@
return;
}

if (!client_ || !client_->service_is_ready()) {
calibration_button_->setText("wait for service");
calibration_button_->setEnabled(false);
return;

Check warning on line 102 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L99-L102

Added lines #L99 - L102 were not covered by tests
}

if (msg->data) {
status_label_->setText("Ready");
status_label_->setStyleSheet("QLabel { background-color : white;}");
Expand All @@ -98,17 +115,34 @@

void AccelBrakeMapCalibratorButtonPanel::editTopic()
{
update_suggest_sub_.reset();
rclcpp::Node::SharedPtr raw_node =
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();
update_suggest_sub_ = raw_node->create_subscription<std_msgs::msg::Bool>(
topic_edit_->text().toStdString(), 10,
std::bind(
&AccelBrakeMapCalibratorButtonPanel::callbackUpdateSuggest, this, std::placeholders::_1));
try {
update_suggest_sub_.reset();
update_suggest_sub_ = raw_node->create_subscription<std_msgs::msg::Bool>(
topic_edit_->text().toStdString(), 10,
std::bind(

Check warning on line 124 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L122-L124

Added lines #L122 - L124 were not covered by tests
&AccelBrakeMapCalibratorButtonPanel::callbackUpdateSuggest, this, std::placeholders::_1));
} catch (const rclcpp::exceptions::InvalidTopicNameError & e) {
RCLCPP_WARN_STREAM(raw_node->get_logger(), e.what());
}

Check warning on line 128 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L126-L128

Added lines #L126 - L128 were not covered by tests
calibration_button_->setText("Wait for subscribe topic");
calibration_button_->setEnabled(false);
}

void AccelBrakeMapCalibratorButtonPanel::editService()

Check warning on line 133 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L133

Added line #L133 was not covered by tests
{
rclcpp::Node::SharedPtr raw_node =
this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node();

Check warning on line 136 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L136

Added line #L136 was not covered by tests
try {
client_.reset();
client_ = raw_node->create_client<tier4_vehicle_msgs::srv::UpdateAccelBrakeMap>(
service_edit_->text().toStdString());
} catch (const rclcpp::exceptions::InvalidServiceNameError & e) {
RCLCPP_WARN_STREAM(raw_node->get_logger(), e.what());
}
}

Check warning on line 144 in common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_calibration_rviz_plugin/src/accel_brake_map_calibrator_button_panel.cpp#L139-L144

Added lines #L139 - L144 were not covered by tests

void AccelBrakeMapCalibratorButtonPanel::pushCalibrationButton()
{
// lock button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AccelBrakeMapCalibratorButtonPanel : public rviz_common::Panel

public Q_SLOTS: // NOLINT for Qt
void editTopic();
void editService();
void pushCalibrationButton();

protected:
Expand All @@ -56,6 +57,8 @@ public Q_SLOTS: // NOLINT for Qt

QLabel * topic_label_;
QLineEdit * topic_edit_;
QLabel * service_label_;
QLineEdit * service_edit_;
QPushButton * calibration_button_;
QLabel * status_label_;
};
Expand Down
Loading