Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 committed Dec 25, 2024
1 parent 256693b commit 5c6b996
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 70 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,6 @@

Plugin for displaying 2D overlays over the RViz2 3D scene.

Based on the [jsk_visualization](https://github.com/jsk-ros-pkg/jsk_visualization)
package, under the 3-Clause BSD license.

## Purpose

This plugin provides a visual and easy-to-understand display of vehicle speed, turn signal, steering status and gears.

## Inputs / Outputs

### Input

| Name | Type | Description |
| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------ |
| `/vehicle/status/velocity_status` | `autoware_vehicle_msgs::msg::VelocityReport` | The topic is vehicle velocity |
| `/vehicle/status/turn_indicators_status` | `autoware_vehicle_msgs::msg::TurnIndicatorsReport` | The topic is status of turn signal |
| `/vehicle/status/hazard_status` | `autoware_vehicle_msgs::msg::HazardReport` | The topic is status of hazard |
| `/vehicle/status/steering_status` | `autoware_vehicle_msgs::msg::SteeringReport` | The topic is status of steering |
| `/vehicle/status/gear_status` | `autoware_vehicle_msgs::msg::GearReport` | The topic is status of gear |
| `/planning/scenario_planning/current_max_velocity` | `tier4_planning_msgs::msg::VelocityLimit` | The topic is velocity limit |
| `/perception/traffic_light_recognition/traffic_signals` | `autoware_perception_msgs::msg::TrafficLightGroupArray` | The topic is status of traffic light |

## Parameter

### Core Parameters

#### StringStampedOverlayDisplay

| Name | Type | Default Value | Description |
| ------------------------ | ------ | -------------------- | --------------------------------- |
| `property_width_` | int | 128 | Width of the plotter window [px] |
| `property_height_` | int | 128 | Height of the plotter window [px] |
| `property_left_` | int | 128 | Left of the plotter window [px] |
| `property_top_` | int | 128 | Top of the plotter window [px] |
| `property_signal_color_` | QColor | QColor(25, 255, 240) | Turn Signal color |

## Assumptions / Known limits

TBD.

## Usage

1. Start `rviz2` and click `Add` button under the `Displays` panel.

![select_add](./assets/images/select_add.png)

2. Under `By display type` tab, select `autoware_string_stamped_rviz_plugin/StringStampedOverlayDisplay` and press OK.

3. Enter the names of the topics if necessary.

![select_topic_name](./assets/images/select_topic_name.png)
This plugin displays the ROS message whose topic type is `autoware_internal_debug_msgs::msg::StringStamped` in rviz.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
RViz2 plugin for 2D overlays in the 3D view. Mainly a port of the JSK overlay plugin
(https://github.com/jsk-ros-pkg/jsk_visualization).
</description>
<maintainer email="khalil@leodrive.ai">Khalil Selyan</maintainer>
<maintainer email="takayuki.murooka@tier4.jp">Takayuki Murooka</maintainer>
<maintainer email="satoshi.ota@tier4.jp">Satoshi Ota</maintainer>

<license>BSD-3-Clause</license>
<license>Apache License 2.0</license>

<depend>ament_index_cpp</depend>
<depend>autoware_internal_debug_msgs</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_vehicle_msgs</depend>
<depend>boost</depend>
<depend>rviz_common</depend>
<depend>rviz_ogre_vendor</depend>
<depend>rviz_rendering</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ StringStampedOverlayDisplay::StringStampedOverlayDisplay()
property_max_letter_num_ = new rviz_common::properties::IntProperty(
"Max Letter Num", 100, "Max Letter Num", this, SLOT(updateVisualization()), this);
property_max_letter_num_->setMin(10);

property_last_diag_keep_time_ = new rviz_common::properties::FloatProperty(
"Time To Keep Last Diag", 1.0, "Time To Keep Last Diag", this, SLOT(updateVisualization()),
this);
property_last_diag_keep_time_->setMin(0);

property_last_diag_erase_time_ = new rviz_common::properties::FloatProperty(
"Time To Erase Last Diag", 2.0, "Time To Erase Last Diag", this, SLOT(updateVisualization()),
this);
property_last_diag_erase_time_->setMin(0.001);
}

StringStampedOverlayDisplay::~StringStampedOverlayDisplay()
Expand Down Expand Up @@ -141,14 +151,20 @@ void StringStampedOverlayDisplay::update(float wall_dt, float ros_dt)
}
}

// calculate text and alpha
const auto text_with_alpha = [&]() {
std::lock_guard<std::mutex> message_lock(mutex_);
if (last_msg_text_.empty()) {
const auto current_time = context_->getRosNodeAbstraction().lock()->get_raw_node()->now();
const auto duration = (current_time - last_non_empty_msg_ptr_->stamp).seconds();
if (duration < 1.0 + 2.0) {
const int dynamic_alpha =
static_cast<int>((1.0 - std::max(duration - 1.0, 0.0) / 2.0) * 255);
if (
duration <
property_last_diag_keep_time_->getFloat() + property_last_diag_erase_time_->getFloat()) {
const int dynamic_alpha = static_cast<int>(std::max(
(1.0 - std::max(duration - property_last_diag_keep_time_->getFloat(), 0.0) /
property_last_diag_erase_time_->getFloat()) *
255,
0.0));
return std::make_pair(last_non_empty_msg_ptr_->data, dynamic_alpha);
}
}
Expand Down Expand Up @@ -196,6 +212,8 @@ void StringStampedOverlayDisplay::processMessage(
{
std::lock_guard<std::mutex> message_lock(mutex_);
last_msg_text_ = msg_ptr->data;

// keep the non empty last message for visualization
if (!msg_ptr->data.empty()) {
last_non_empty_msg_ptr_ = msg_ptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ private Q_SLOTS:
rviz_common::properties::IntProperty * property_left_;
rviz_common::properties::IntProperty * property_top_;
rviz_common::properties::IntProperty * property_value_height_offset_;
rviz_common::properties::FloatProperty * property_value_scale_;
rviz_common::properties::IntProperty * property_font_size_;
rviz_common::properties::IntProperty * property_max_letter_num_;
// QImage hud_;
rviz_common::properties::FloatProperty * property_last_diag_keep_time_;
rviz_common::properties::FloatProperty * property_last_diag_erase_time_;

private:
static constexpr int line_width_ = 2;
Expand Down

0 comments on commit 5c6b996

Please sign in to comment.