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(tier4_localization_rviz_plugin): add visualization of pose with covariance history #8191

Merged
merged 8 commits into from
Aug 29, 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
2 changes: 2 additions & 0 deletions common/tier4_localization_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
src/pose_history/pose_history_display.cpp
src/pose_history_footprint/display.hpp
src/pose_history_footprint/display.cpp
src/pose_with_covariance_history/pose_with_covariance_history_display.hpp
src/pose_with_covariance_history/pose_with_covariance_history_display.cpp
)

target_link_libraries(${PROJECT_NAME}
Expand Down
45 changes: 39 additions & 6 deletions common/tier4_localization_rviz_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@

## Purpose

This plugin can display the history of the localization obtained by ekf_localizer or ndt_scan_matching.
This plugin can display the localization history obtained by ekf_localizer, ndt_scan_matching, and GNSS.
If the uncertainty of the estimated pose is given, it can also be displayed.

## Inputs / Outputs

### Input

| Name | Type | Description |
| ------------ | --------------------------------- | ---------------------------------------------------------------------------------------------- |
| `input/pose` | `geometry_msgs::msg::PoseStamped` | In input/pose, put the result of localization calculated by ekf_localizer or ndt_scan_matching |
### Pose History

| Name | Type | Description |
| ------------ | --------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `input/pose` | `geometry_msgs::msg::PoseStamped` | In input/pose, put the result of localization calculated by ekf_localizer, ndt_scan_matching, or GNSS |

### Pose With Covariance History

| Name | Type | Description |
| ---------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `input/pose_with_covariance` | `geometry_msgs::msg::PoseWithCovarianceStamped` | In input/pose_with_covariance, put the result of localization calculated by ekf_localizer, ndt_scan_matching, or GNSS |

## Parameters

### Core Parameters

### Pose History

| Name | Type | Default Value | Description |
| ----------------------- | ------ | ------------- | -------------------------- |
| `property_buffer_size_` | int | 100 | Buffer size of topic |
Expand All @@ -24,6 +35,26 @@ This plugin can display the history of the localization obtained by ekf_localize
| `property_line_alpha_` | float | 1.0 | Alpha of Line property |
| `property_line_color_` | QColor | Qt::white | Color of Line property |

### Pose With Covariance History

| Name | Type | Default Value | Description |
| ------------------------------- | ------ | -------------- | -------------------------------- |
| `property_buffer_size_` | int | 100 | Buffer size of topic |
| `property_path_view_` | bool | true | Use path property or not |
| `property_shape_type_` | string | Line | Line or Arrow |
| `property_line_width_` | float | 0.1 | Width of Line property [m] |
| `property_line_alpha_` | float | 1.0 | Alpha of Line property |
| `property_line_color_` | QColor | Qt::white | Color of Line property |
| `property_arrow_shaft_length` | float | 0.3 | Shaft length of Arrow property |
| `property_arrow_shaft_diameter` | float | 0.15 | Shaft diameter of Arrow property |
| `property_arrow_head_length` | float | 0.2 | Head length of Arrow property |
| `property_arrow_head_diameter` | float | 0.3 | Head diameter of Arrow property |
| `property_arrow_alpha_` | float | 1.0 | Alpha of Arrow property |
| `property_arrow_color_` | QColor | Qt::white | Color of Arrow property |
| `property_sphere_scale_` | float | 1.0 | Scale of Sphere property |
| `property_sphere_alpha_` | float | 0.5 | Alpha of Sphere property |
| `property_sphere_color_` | QColor | (204, 51, 204) | Color of Sphere property |

## Assumptions / Known limits

TBD.
Expand All @@ -32,7 +63,9 @@ TBD.

1. Start rviz and select Add under the Displays panel.
![select_add](./images/select_add.png)
2. Select tier4_localization_rviz_plugin/PoseHistory and press OK.
2. Select tier4_localization_rviz_plugin/PoseHistory or PoseWithCovarianceHistory. Next, press OK.
![select_localization_plugin](./images/select_localization_plugin.png)
3. Enter the name of the topic where you want to view the trajectory.
3. Enter the name of the topic where you want to view the trajectory and the covariance.
![select_topic_name](./images/select_topic_name.png)
4. You can view the trajectory and the covariance.
![ex_pose_with_covariance_history](./images/ex_pose_with_covariance_history.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions common/tier4_localization_rviz_plugin/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<license>Apache License 2.0</license>
<author email="isamu.takagi@tier4.jp">Takagi, Isamu</author>
<author email="takamasa.horibe@tier4.jp">Takamasa Horibe</author>
<author email="yuhei.oshikubo@tier4.jp">Yuhei Oshikubo</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
base_class_type="rviz_common::Display">
<description>Display footprint of geometry_msgs::Pose</description>
</class>
<class name="rviz_plugins::PoseWithCovarianceHistory"
type="rviz_plugins::PoseWithCovarianceHistory"
base_class_type="rviz_common::Display">
<description>Display geometry_msgs::PoseWithCovarianceStamped</description>
</class>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
// Copyright 2024 Tier IV, Inc.
//
// 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 "pose_with_covariance_history_display.hpp"

#include <rviz_common/properties/bool_property.hpp>
#include <rviz_common/properties/color_property.hpp>
#include <rviz_common/properties/enum_property.hpp>
#include <rviz_common/properties/float_property.hpp>
#include <rviz_common/properties/int_property.hpp>
#include <rviz_common/properties/parse_color.hpp>
#include <rviz_common/validate_floats.hpp>
#include <rviz_rendering/objects/arrow.hpp>
#include <rviz_rendering/objects/billboard_line.hpp>
#include <rviz_rendering/objects/shape.hpp>

#include <tf2/LinearMath/Quaternion.h>

namespace rviz_plugins
{
PoseWithCovarianceHistory::PoseWithCovarianceHistory() : last_stamp_(0, 0, RCL_ROS_TIME)

Check warning on line 32 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L32

Added line #L32 was not covered by tests
{
property_buffer_size_ = new rviz_common::properties::IntProperty("Buffer Size", 100, "", this);

Check warning on line 34 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L34

Added line #L34 was not covered by tests

property_path_view_ = new rviz_common::properties::BoolProperty("Path", true, "", this);
property_shape_type_ = new rviz_common::properties::EnumProperty(
"Shape Type", "Line", "", property_path_view_, SLOT(updateShapeType()));
property_shape_type_->addOption("Line", 0);
property_shape_type_->addOption("Arrow", 1);

Check warning on line 40 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L36-L40

Added lines #L36 - L40 were not covered by tests

property_line_width_ =
new rviz_common::properties::FloatProperty("Width", 0.1, "", property_shape_type_);
property_line_alpha_ =
new rviz_common::properties::FloatProperty("Alpha", 1.0, "", property_shape_type_);
property_line_alpha_->setMin(0.0);
property_line_alpha_->setMax(1.0);
property_line_color_ =
new rviz_common::properties::ColorProperty("Color", Qt::white, "", property_shape_type_);

Check warning on line 49 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L42-L49

Added lines #L42 - L49 were not covered by tests

property_arrow_shaft_length_ =
new rviz_common::properties::FloatProperty("Shaft Length", 0.3, "", property_shape_type_);
property_arrow_shaft_diameter_ =
new rviz_common::properties::FloatProperty("Shaft diameter", 0.15, "", property_shape_type_);
property_arrow_head_length_ =
new rviz_common::properties::FloatProperty("Head Length", 0.2, "", property_shape_type_);
property_arrow_head_diameter_ =
new rviz_common::properties::FloatProperty("Head diameter", 0.3, "", property_shape_type_);
property_arrow_alpha_ =
new rviz_common::properties::FloatProperty("Alpha", 1.0, "", property_shape_type_);
property_arrow_alpha_->setMin(0.0);
property_arrow_alpha_->setMax(1.0);
property_arrow_color_ =
new rviz_common::properties::ColorProperty("Color", Qt::white, "", property_shape_type_);

Check warning on line 64 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L51-L64

Added lines #L51 - L64 were not covered by tests

property_sphere_view_ = new rviz_common::properties::BoolProperty("Covariance", true, "", this);
property_sphere_scale_ =
new rviz_common::properties::FloatProperty("Scale", 1.0, "", property_sphere_view_);
property_sphere_alpha_ =
new rviz_common::properties::FloatProperty("Alpha", 0.5, "", property_sphere_view_);
property_sphere_alpha_->setMin(0.0);
property_sphere_alpha_->setMax(1.0);
property_sphere_color_ = new rviz_common::properties::ColorProperty(
"Color", QColor(204, 51, 204), "", property_sphere_view_);

Check warning on line 74 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L66-L74

Added lines #L66 - L74 were not covered by tests

property_buffer_size_->setMin(0);
property_buffer_size_->setMax(10000);
property_line_width_->setMin(0.0);
property_sphere_scale_->setMin(0.0);
property_sphere_scale_->setMax(1000);
property_arrow_shaft_length_->setMin(0.0);
property_arrow_shaft_diameter_->setMin(0.0);
property_arrow_head_length_->setMin(0.0);
property_arrow_head_diameter_->setMin(0.0);

Check warning on line 84 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L76-L84

Added lines #L76 - L84 were not covered by tests
}

PoseWithCovarianceHistory::~PoseWithCovarianceHistory() = default; // Properties are deleted by Qt

Check warning on line 87 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L87

Added line #L87 was not covered by tests

void PoseWithCovarianceHistory::onInitialize()

Check warning on line 89 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L89

Added line #L89 was not covered by tests
{
MFDClass::onInitialize();
lines_ = std::make_unique<rviz_rendering::BillboardLine>(scene_manager_, scene_node_);

Check warning on line 92 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L92

Added line #L92 was not covered by tests
}

void PoseWithCovarianceHistory::onEnable()

Check warning on line 95 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L95

Added line #L95 was not covered by tests
{
subscribe();

Check warning on line 97 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L97

Added line #L97 was not covered by tests
}

void PoseWithCovarianceHistory::onDisable()

Check warning on line 100 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L100

Added line #L100 was not covered by tests
{
unsubscribe();

Check warning on line 102 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L102

Added line #L102 was not covered by tests
}

void PoseWithCovarianceHistory::update(float wall_dt, float ros_dt)

Check warning on line 105 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L105

Added line #L105 was not covered by tests
{
(void)wall_dt;
(void)ros_dt;

if (!history_.empty()) {
lines_->clear();

Check warning on line 111 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L111

Added line #L111 was not covered by tests
arrows_.clear();
spheres_.clear();
updateShapeType();
updateShapes();

Check warning on line 115 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L114-L115

Added lines #L114 - L115 were not covered by tests
}
}

void PoseWithCovarianceHistory::subscribe()

Check warning on line 119 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L119

Added line #L119 was not covered by tests
{
MFDClass::subscribe();

Check warning on line 121 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L121

Added line #L121 was not covered by tests
}

void PoseWithCovarianceHistory::unsubscribe()

Check warning on line 124 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L124

Added line #L124 was not covered by tests
{
MFDClass::unsubscribe();

Check warning on line 126 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L126

Added line #L126 was not covered by tests

history_.clear();
lines_->clear();

Check warning on line 129 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L128-L129

Added lines #L128 - L129 were not covered by tests
arrows_.clear();
spheres_.clear();
}

void PoseWithCovarianceHistory::updateShapeType()

Check warning on line 134 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L134

Added line #L134 was not covered by tests
{
bool is_line = property_shape_type_->getOptionInt() == 0;
bool is_arrow = property_shape_type_->getOptionInt() == 1;

Check warning on line 137 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L136-L137

Added lines #L136 - L137 were not covered by tests

property_line_width_->setHidden(!is_line);
property_line_alpha_->setHidden(!is_line);
property_line_color_->setHidden(!is_line);

Check warning on line 141 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L139-L141

Added lines #L139 - L141 were not covered by tests

property_arrow_shaft_length_->setHidden(!is_arrow);
property_arrow_shaft_diameter_->setHidden(!is_arrow);
property_arrow_head_length_->setHidden(!is_arrow);
property_arrow_head_diameter_->setHidden(!is_arrow);
property_arrow_alpha_->setHidden(!is_arrow);
property_arrow_color_->setHidden(!is_arrow);

Check warning on line 148 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L143-L148

Added lines #L143 - L148 were not covered by tests
}

void PoseWithCovarianceHistory::processMessage(

Check warning on line 151 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L151

Added line #L151 was not covered by tests
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr message)
{
if (
!rviz_common::validateFloats(message->pose.pose) ||

Check warning on line 155 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L155

Added line #L155 was not covered by tests
!rviz_common::validateFloats(message->pose.covariance)) {
setStatus(

Check warning on line 157 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L157

Added line #L157 was not covered by tests
rviz_common::properties::StatusProperty::Error, "Topic",
"Message contained invalid floating point values (nans or infs)");
return;

Check warning on line 160 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L160

Added line #L160 was not covered by tests
}
if (target_frame_ != message->header.frame_id) {
history_.clear();

Check warning on line 163 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L163

Added line #L163 was not covered by tests
spheres_.clear();
target_frame_ = message->header.frame_id;

Check warning on line 165 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L165

Added line #L165 was not covered by tests
}
history_.emplace_back(message);
last_stamp_ = message->header.stamp;
updateHistory();

Check warning on line 169 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L167-L169

Added lines #L167 - L169 were not covered by tests
}

void PoseWithCovarianceHistory::updateHistory()

Check warning on line 172 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L172

Added line #L172 was not covered by tests
{
const auto buffer_size = static_cast<size_t>(property_buffer_size_->getInt());

Check warning on line 174 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L174

Added line #L174 was not covered by tests
while (buffer_size < history_.size()) {
history_.pop_front();

Check warning on line 176 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L176

Added line #L176 was not covered by tests
}
}

void PoseWithCovarianceHistory::updateShapes()

Check warning on line 180 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L180

Added line #L180 was not covered by tests
{
int shape_type = property_shape_type_->getOptionInt();

Check warning on line 182 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L182

Added line #L182 was not covered by tests
Ogre::ColourValue color_line =
rviz_common::properties::qtToOgre(property_line_color_->getColor());
color_line.a = property_line_alpha_->getFloat();

Check warning on line 185 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L184-L185

Added lines #L184 - L185 were not covered by tests
Ogre::ColourValue color_sphere =
rviz_common::properties::qtToOgre(property_sphere_color_->getColor());
color_sphere.a = property_sphere_alpha_->getFloat();

Check warning on line 188 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L187-L188

Added lines #L187 - L188 were not covered by tests
Ogre::ColourValue color_arrow =
rviz_common::properties::qtToOgre(property_arrow_color_->getColor());
color_arrow.a = property_arrow_alpha_->getFloat();

Check warning on line 191 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L190-L191

Added lines #L190 - L191 were not covered by tests

Ogre::Vector3 line_position;
Ogre::Quaternion line_orientation;

auto frame_manager = context_->getFrameManager();

Check warning on line 196 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L196

Added line #L196 was not covered by tests
if (!frame_manager->getTransform(target_frame_, last_stamp_, line_position, line_orientation)) {
setMissingTransformToFixedFrame(target_frame_);
return;

Check warning on line 199 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L198-L199

Added lines #L198 - L199 were not covered by tests
}

setTransformOk();
lines_->setMaxPointsPerLine(history_.size());
lines_->setLineWidth(property_line_width_->getFloat());
lines_->setPosition(line_position);
lines_->setOrientation(line_orientation);
lines_->setColor(color_line.r, color_line.g, color_line.b, color_line.a);

Check warning on line 207 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L202-L207

Added lines #L202 - L207 were not covered by tests

while (spheres_.size() < history_.size()) {
spheres_.emplace_back(std::make_unique<rviz_rendering::Shape>(
rviz_rendering::Shape::Sphere, scene_manager_, scene_node_));

Check warning on line 211 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L210-L211

Added lines #L210 - L211 were not covered by tests
}
while (arrows_.size() < history_.size()) {
arrows_.emplace_back(std::make_unique<rviz_rendering::Arrow>(scene_manager_, scene_node_));

Check warning on line 214 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L214

Added line #L214 was not covered by tests
}

for (size_t i = 0; i < history_.size(); ++i) {
const auto & message = history_[i];

Ogre::Vector3 position;
position.x = message->pose.pose.position.x;
position.y = message->pose.pose.position.y;
position.z = message->pose.pose.position.z;

Check warning on line 223 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L221-L223

Added lines #L221 - L223 were not covered by tests

Ogre::Quaternion orientation;
orientation.w = message->pose.pose.orientation.w;
orientation.x = message->pose.pose.orientation.x;
orientation.y = message->pose.pose.orientation.y;
orientation.z = message->pose.pose.orientation.z;

Check warning on line 229 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L226-L229

Added lines #L226 - L229 were not covered by tests

Eigen::Matrix3d covariance_3d_map;
covariance_3d_map(0, 0) = message->pose.covariance[0];
covariance_3d_map(0, 1) = message->pose.covariance[1 + 6 * 0];
covariance_3d_map(0, 2) = message->pose.covariance[2 + 6 * 0];
covariance_3d_map(1, 0) = message->pose.covariance[1 + 6 * 0];
covariance_3d_map(1, 1) = message->pose.covariance[1 + 6 * 1];
covariance_3d_map(1, 2) = message->pose.covariance[2 + 6 * 1];
covariance_3d_map(2, 0) = message->pose.covariance[0 + 6 * 2];
covariance_3d_map(2, 1) = message->pose.covariance[1 + 6 * 2];
covariance_3d_map(2, 2) = message->pose.covariance[2 + 6 * 2];

Check warning on line 240 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L232-L240

Added lines #L232 - L240 were not covered by tests

if (property_sphere_view_->getBool()) {
Eigen::Matrix3d covariance_3d_base_link;
Eigen::Translation3f translation(
message->pose.pose.position.x, message->pose.pose.position.y,
message->pose.pose.position.z);

Check warning on line 246 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L245-L246

Added lines #L245 - L246 were not covered by tests
Eigen::Quaternionf rotation(
message->pose.pose.orientation.w, message->pose.pose.orientation.x,
message->pose.pose.orientation.y, message->pose.pose.orientation.z);
Eigen::Matrix4f pose_matrix4f = (translation * rotation).matrix();
const Eigen::Matrix3d rot = pose_matrix4f.topLeftCorner<3, 3>().cast<double>();
covariance_3d_base_link = rot.transpose() * covariance_3d_map * rot;

Check warning on line 252 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L248-L252

Added lines #L248 - L252 were not covered by tests

auto & sphere = spheres_[i];
sphere->setPosition(position);
sphere->setOrientation(orientation);
sphere->setColor(color_sphere.r, color_sphere.g, color_sphere.b, color_sphere.a);
sphere->setScale(Ogre::Vector3(
property_sphere_scale_->getFloat() * 2 * std::sqrt(covariance_3d_base_link(0, 0)),
property_sphere_scale_->getFloat() * 2 * std::sqrt(covariance_3d_base_link(1, 1)),
property_sphere_scale_->getFloat() * 2 * std::sqrt(covariance_3d_base_link(2, 2))));

Check warning on line 261 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L255-L261

Added lines #L255 - L261 were not covered by tests
}

if (property_path_view_->getBool()) {
if (shape_type == 0) {
lines_->addPoint(position);

Check warning on line 266 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L266

Added line #L266 was not covered by tests
}
if (shape_type == 1) {
auto & arrow = arrows_[i];
arrow->set(
property_arrow_shaft_length_->getFloat(), property_arrow_shaft_diameter_->getFloat(),
property_arrow_head_length_->getFloat(), property_arrow_head_diameter_->getFloat());
arrow->setPosition(position);
Ogre::Quaternion y90(Ogre::Degree(-90), Ogre::Vector3::UNIT_Y);
arrow->setOrientation(orientation * y90);
arrow->setColor(color_arrow.r, color_arrow.g, color_arrow.b, color_arrow.a);

Check warning on line 276 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L270-L276

Added lines #L270 - L276 were not covered by tests
}
}
}
}

Check warning on line 280 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

PoseWithCovarianceHistory::updateShapes has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 280 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Bumpy Road Ahead

PoseWithCovarianceHistory::updateShapes has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

} // namespace rviz_plugins

#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(rviz_plugins::PoseWithCovarianceHistory, rviz_common::Display)

Check warning on line 285 in common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_localization_rviz_plugin/src/pose_with_covariance_history/pose_with_covariance_history_display.cpp#L285

Added line #L285 was not covered by tests
Loading
Loading