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_planning_rviz_plugin): fix initialize planning_rviz_plugin #1387

Merged
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
10 changes: 6 additions & 4 deletions common/tier4_planning_rviz_plugin/src/tools/max_velocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void MaxVelocityDisplay::onInitialize()
overlay_->updateTextureSize(property_length_->getInt(), property_length_->getInt());
overlay_->setPosition(property_left_->getInt(), property_top_->getInt());
overlay_->setDimensions(overlay_->getTextureWidth(), overlay_->getTextureHeight());
processMessage(last_msg_ptr_);

// QColor background_color;
// background_color.setAlpha(0);
Expand Down Expand Up @@ -126,9 +127,6 @@ void MaxVelocityDisplay::unsubscribe() { max_vel_sub_.reset(); }
void MaxVelocityDisplay::processMessage(
const tier4_planning_msgs::msg::VelocityLimit::ConstSharedPtr msg_ptr)
{
if (!isEnabled()) {
return;
}
if (!overlay_->isVisible()) {
return;
}
Expand Down Expand Up @@ -172,8 +170,12 @@ void MaxVelocityDisplay::processMessage(
font.setBold(true);
painter.setFont(font);
std::ostringstream velocity_ss;
float velocity = 0.0;
if (msg_ptr != nullptr) {
velocity = msg_ptr->max_velocity;
}
velocity_ss << std::fixed << std::setprecision(0) << "limited" << std::endl
<< msg_ptr->max_velocity * 3.6 << "km/h";
<< velocity * 3.6 << "km/h";
painter.drawText(
static_cast<int>(line_width * 0.5), std::min(static_cast<int>(line_width * 0.5), h - 1), w,
std::max(h, 1), Qt::AlignCenter | Qt::AlignVCenter, velocity_ss.str().c_str());
Expand Down