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: update msg name and add topic option update #13

Merged
merged 1 commit into from
Jul 16, 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
30 changes: 15 additions & 15 deletions awviz/config/awviz.param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,47 @@

topic_options:
/sensing/lidar/concatenated/pointcloud:
type: PointCloud
type: sensor_msgs/msg/PointCloud2
entity: /topics/sensing/lidar/concatenated/pointcloud
/sensing/camera/camera0/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera0/image_rect_color/compressed
/sensing/camera/camera0/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera0/image_rect_color/compressed
/sensing/camera/camera1/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera1/image_rect_color/compressed
/sensing/camera/camera1/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera1/image_rect_color/compressed
/sensing/camera/camera2/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera2/image_rect_color/compressed
/sensing/camera/camera2/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera2/image_rect_color/compressed
/sensing/camera/camera3/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera3/image_rect_color/compressed
/sensing/camera/camera3/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera3/image_rect_color/compressed
/sensing/camera/camera4/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera4/image_rect_color/compressed
/sensing/camera/camera4/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera4/image_rect_color/compressed
/sensing/camera/camera5/image_rect_color/compressed:
type: CompressedImage
type: sensor_msgs/msg/CompressedImage
entity: /topics/sensing/camera/camera5/image_rect_color/compressed
/sensing/camera/camera5/camera_info:
type: CameraInfo
type: sensor_msgs/msg/CameraInfo
entity: /topics/sensing/camera/camera5/image_rect_color/compressed
/perception/object_recognition/detection/objects:
type: DetectedObjects
type: autoware_perception_msgs/msg/DetectedObjects
entity: /topics/perception/object_recognition/detection/objects
/perception/object_recognition/tracking/objects:
type: TrackedObjects
type: autoware_perception_msgs/msg/TrackedObjects
entity: /topics/perception/object_recognition/tracking/objects
16 changes: 8 additions & 8 deletions awviz/include/awviz/topic_option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace awviz
*/
enum MsgType {
Unknown,
PointCloud,
PointCloud2,
CameraInfo,
Image,
CompressedImage,
Expand All @@ -44,17 +44,17 @@ enum MsgType {
*/
MsgType nameToMsgType(const std::string & name)
{
if (name == "PointCloud") {
return MsgType::PointCloud;
} else if (name == "CameraInfo") {
if (name == "sensor_msgs/msg/PointCloud2") {
return MsgType::PointCloud2;
} else if (name == "sensor_msgs/msg/CameraInfo") {
return MsgType::CameraInfo;
} else if (name == "Image") {
} else if (name == "sensor_msgs/msg/Image") {
return MsgType::Image;
} else if (name == "CompressedImage") {
} else if (name == "sensor_msgs/msg/CompressedImage") {
return MsgType::CompressedImage;
} else if (name == "DetectedObjects") {
} else if (name == "autoware_perception_msgs/msg/DetectedObjects") {
return MsgType::DetectedObjects;
} else if (name == "TrackedObjects") {
} else if (name == "autoware_perception_msgs/msg/TrackedObjects") {
return MsgType::TrackedObjects;
} else {
return MsgType::Unknown;
Expand Down
17 changes: 15 additions & 2 deletions awviz/src/rerun_logger_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "rclcpp/subscription.hpp"
#include "tf2/exceptions.h"

#include <algorithm>
#include <chrono>

namespace awviz
Expand All @@ -41,15 +42,27 @@ RerunLoggerNode::RerunLoggerNode(const rclcpp::NodeOptions & node_options)
100ms, [&]() -> void { createSubscriptions(); }, parallel_callback_group_);
}

void RerunLoggerNode::updateTopicOptions()
{
for (const auto & [topic_name, topic_types] : get_topic_names_and_types()) {
const auto topic_type = nameToMsgType(topic_types.front());
if (std::find_if(topic_options_.cbegin(), topic_options_.cend(), [&](const auto & option) {
return option.topic() == topic_name && option.type() == topic_type;
}) == topic_options_.cend()) {
topic_options_.emplace_back(topic_name, topic_type);
}
}
}

void RerunLoggerNode::createSubscriptions()
{
// TODO(ktro2828): use rclcpp::Node::get_topic_names_and_types()
updateTopicOptions();
for (const auto & option : topic_options_) {
if (topic_to_subscription_.find(option.topic()) != topic_to_subscription_.end()) {
continue;
}

if (option.type() == MsgType::PointCloud) {
if (option.type() == MsgType::PointCloud2) {
topic_to_subscription_[option.topic()] = createPointCloudSubscription(option);
} else if (option.type() == MsgType::CameraInfo) {
topic_to_subscription_[option.topic()] = createCameraInfoSubscription(option);
Expand Down
5 changes: 5 additions & 0 deletions awviz/src/rerun_logger_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class RerunLoggerNode : public rclcpp::Node
explicit RerunLoggerNode(const rclcpp::NodeOptions & node_options);

private:
/**
* @brief Update topic option container if the topic has not registered yet.
*/
void updateTopicOptions();

/**
* @brief Create subscribers.
*/
Expand Down
Loading