-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(awviz_plugin): add support of `autoware_perception_msgs::msg::Pr…
…edictedObjects` Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
awviz_plugin/include/awviz_plugin/autoware_perception/predicted_objects_display.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 Kotaro Uetake. | ||
// | ||
// 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. | ||
|
||
#ifndef AWVIZ_PLUGIN__AUTOWARE_PERCEPTION__PREDICTED_OBJECTS_DISPLAY_HPP_ | ||
#define AWVIZ_PLUGIN__AUTOWARE_PERCEPTION__PREDICTED_OBJECTS_DISPLAY_HPP_ | ||
|
||
#include <awviz_common/display.hpp> | ||
#include <rerun.hpp> | ||
|
||
#include <autoware_perception_msgs/msg/predicted_objects.hpp> | ||
|
||
namespace awviz_plugin | ||
{ | ||
/** | ||
* @brief Display plugin of `autoware_perception_msgs::msg::PredictedObjects`. | ||
*/ | ||
class PredictedObjectsDisplay | ||
: public awviz_common::RosTopicDisplay<autoware_perception_msgs::msg::PredictedObjects> | ||
{ | ||
public: | ||
/** | ||
* @brief Construct a new object. | ||
*/ | ||
PredictedObjectsDisplay(); | ||
|
||
protected: | ||
/** | ||
* @todo Add support of colorizing each predicted path mode. | ||
*/ | ||
void log_message(autoware_perception_msgs::msg::PredictedObjects::ConstSharedPtr msg) override; | ||
}; | ||
} // namespace awviz_plugin | ||
|
||
#endif // AWVIZ_PLUGIN__AUTOWARE_PERCEPTION__PREDICTED_OBJECTS_DISPLAY_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
awviz_plugin/src/autoware_perception/predicted_objects_display.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2024 Kotaro Uetake. | ||
// | ||
// 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 "awviz_plugin/autoware_perception/predicted_objects_display.hpp" | ||
|
||
#include <vector> | ||
|
||
namespace awviz_plugin | ||
{ | ||
PredictedObjectsDisplay::PredictedObjectsDisplay() | ||
: awviz_common::RosTopicDisplay<autoware_perception_msgs::msg::PredictedObjects>() | ||
{ | ||
} | ||
|
||
void PredictedObjectsDisplay::log_message( | ||
autoware_perception_msgs::msg::PredictedObjects::ConstSharedPtr msg) | ||
{ | ||
stream_->set_time_seconds( | ||
TIMELINE_NAME, rclcpp::Time(msg->header.stamp.sec, msg->header.stamp.nanosec).seconds()); | ||
|
||
const auto entity_path = property_.entity(msg->header.frame_id); | ||
if (!entity_path) { | ||
stream_->log(property_.topic(), rerun::TextLog("There is no corresponding entity path")); | ||
return; | ||
} | ||
|
||
std::vector<rerun::Position3D> centers; | ||
std::vector<rerun::HalfSize3D> sizes; | ||
std::vector<rerun::Rotation3D> rotations; | ||
std::vector<rerun::components::ClassId> class_ids; | ||
std::vector<rerun::LineStrip3D> paths; | ||
for (const auto & object : msg->objects) { | ||
const auto & init_pose = object.kinematics.initial_pose_with_covariance.pose; | ||
const auto & dimensions = object.shape.dimensions; | ||
centers.emplace_back(init_pose.position.x, init_pose.position.y, init_pose.position.z); | ||
sizes.emplace_back(dimensions.x, dimensions.y, dimensions.z); | ||
rotations.emplace_back(rerun::Quaternion::from_wxyz( | ||
init_pose.orientation.w, init_pose.orientation.x, init_pose.orientation.y, | ||
init_pose.orientation.z)); | ||
class_ids.emplace_back(static_cast<uint16_t>(object.classification.front().label)); | ||
|
||
for (const auto & path : object.kinematics.predicted_paths) { | ||
std::vector<rerun::Vec3D> waypoints; | ||
for (const auto & point : path.path) { | ||
waypoints.emplace_back(point.position.x, point.position.y, point.position.z); | ||
} | ||
paths.emplace_back(rerun::LineStrip3D(waypoints)); | ||
} | ||
} | ||
|
||
stream_->log( | ||
entity_path.value(), | ||
rerun::Boxes3D::from_centers_and_half_sizes(centers, sizes) | ||
.with_rotations(rotations) | ||
.with_class_ids(class_ids), | ||
rerun::LineStrips3D(paths)); | ||
} | ||
} // namespace awviz_plugin | ||
|
||
#include <pluginlib/class_list_macros.hpp> | ||
PLUGINLIB_EXPORT_CLASS(awviz_plugin::PredictedObjectsDisplay, awviz_common::Display); |