Skip to content

Commit

Permalink
fix(tier4_planning_rviz_plugin): fix initialize planning_rviz_plugin (a…
Browse files Browse the repository at this point in the history
…utowarefoundation#1387)

* fix(tier4_planning_rviz_plugin): fix initialize planning_rviz_plugin

Signed-off-by: Takeshi Miura <m.takeshi1995@gmail.com>

* ci(pre-commit): autofix

* remove comment out

Signed-off-by: Takeshi Miura <m.takeshi1995@gmail.com>

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and yukke42 committed Oct 14, 2022
1 parent 1b6cb35 commit 7bfac21
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 7bfac21

Please sign in to comment.