From 9db5f77f76265891ee742db5b97be2d32c1d5f27 Mon Sep 17 00:00:00 2001 From: Jongkuk Lim Date: Tue, 21 Nov 2023 15:57:06 +0900 Subject: [PATCH 1/2] Change on_get -> on_push callback method name --- examples/client/flexxlam_client_example.cpp | 11 +++-------- examples/client/include/flexxlam_client_example.hpp | 6 +++--- include/communication/flexxlam_parser.hpp | 6 +++--- include/protocol/push/push_odometry_protocol.hpp | 2 +- include/protocol/push/push_pointcloud_protocol.hpp | 2 +- tests/test_flexxlam_parser.cpp | 4 ++-- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/examples/client/flexxlam_client_example.cpp b/examples/client/flexxlam_client_example.cpp index d49bf0c..aaea3b8 100644 --- a/examples/client/flexxlam_client_example.cpp +++ b/examples/client/flexxlam_client_example.cpp @@ -7,13 +7,8 @@ #include -#include -#include -#include +#include #include -#include -#include -#include namespace flexxlam { @@ -29,14 +24,14 @@ FlexXlamClientExample::FlexXlamClientExample() FlexXlamClientExample::~FlexXlamClientExample() {} -void FlexXlamClientExample::on_get_odometry( +void FlexXlamClientExample::on_push_odometry( const flexxlam_msgs::Odometry &odom) { LOG(INFO) << "[odom] x: " << odom.pose.position.x << ", y: " << odom.pose.position.y << ", z: " << odom.pose.position.z; } -void FlexXlamClientExample::on_get_pointcloud( +void FlexXlamClientExample::on_push_pointcloud( const flexxlam_msgs::PointCloud2 &pointcloud) { LOG(INFO) << "pointcloud: " << pointcloud.data.size(); flexxlam::PushPointCloudProtocol protocol(pointcloud, diff --git a/examples/client/include/flexxlam_client_example.hpp b/examples/client/include/flexxlam_client_example.hpp index a5b92a2..7f627fa 100644 --- a/examples/client/include/flexxlam_client_example.hpp +++ b/examples/client/include/flexxlam_client_example.hpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -34,12 +33,13 @@ class FlexXlamClientExample : public ParsedMessageInterface { /// @param odom Odometry message /// /// This function is called when odometry message is received. - void on_get_odometry(const flexxlam_msgs::Odometry &odom) override; + void on_push_odometry(const flexxlam_msgs::Odometry &odom) override; /// @brief Callback function for pointcloud message /// @param pointcloud Pointcloud message /// @details This function is called when pointcloud message is received. - void on_get_pointcloud(const flexxlam_msgs::PointCloud2 &pointcloud) override; + void on_push_pointcloud( + const flexxlam_msgs::PointCloud2 &pointcloud) override; /// @brief UDP port number int udp_port_; diff --git a/include/communication/flexxlam_parser.hpp b/include/communication/flexxlam_parser.hpp index 7c4e077..763b465 100644 --- a/include/communication/flexxlam_parser.hpp +++ b/include/communication/flexxlam_parser.hpp @@ -22,13 +22,13 @@ struct ParsedMessageInterface { /// @brief Get odometry callback /// @param odom odometry /// @details This function is called when odometry is parsed. - virtual void on_get_odometry(const flexxlam_msgs::Odometry &odom) {} + virtual void on_push_odometry(const flexxlam_msgs::Odometry &odom) {} /// @brief Get pointcloud callback /// @param pointcloud pointcloud /// @details This function is called when pointcloud is parsed. - virtual void on_get_pointcloud(const flexxlam_msgs::PointCloud2 &pointcloud) { - } + virtual void on_push_pointcloud( + const flexxlam_msgs::PointCloud2 &pointcloud) {} /// @brief Request communication config callback /// @param type communication type. Please refer to `protocol::kCommType*` diff --git a/include/protocol/push/push_odometry_protocol.hpp b/include/protocol/push/push_odometry_protocol.hpp index a8f5bc2..7c191c8 100644 --- a/include/protocol/push/push_odometry_protocol.hpp +++ b/include/protocol/push/push_odometry_protocol.hpp @@ -45,7 +45,7 @@ class PushOdometryProtocol : public BaseProtocol { void handle_callback( const vector &callbacks) override { for (auto callback : callbacks) { - callback->on_get_odometry(this->odom); + callback->on_push_odometry(this->odom); } } diff --git a/include/protocol/push/push_pointcloud_protocol.hpp b/include/protocol/push/push_pointcloud_protocol.hpp index 95f7c73..6a3bb5c 100644 --- a/include/protocol/push/push_pointcloud_protocol.hpp +++ b/include/protocol/push/push_pointcloud_protocol.hpp @@ -43,7 +43,7 @@ class PushPointCloudProtocol : public BaseProtocol { void handle_callback( const vector &callbacks) override { for (auto callback : callbacks) { - callback->on_get_pointcloud(this->pointcloud_); + callback->on_push_pointcloud(this->pointcloud_); } } diff --git a/tests/test_flexxlam_parser.cpp b/tests/test_flexxlam_parser.cpp index 037d35f..f6101c6 100644 --- a/tests/test_flexxlam_parser.cpp +++ b/tests/test_flexxlam_parser.cpp @@ -47,7 +47,7 @@ TEST(FlexXlamParser, PushOdometryProtocolParse) { flexxlam::FlexXlamParser parser; struct TestParsedMessageInterface : public flexxlam::ParsedMessageInterface { - void on_get_odometry(const flexxlam_msgs::Odometry &odom) override { + void on_push_odometry(const flexxlam_msgs::Odometry &odom) override { is_odometry_same(expected_odom, odom); } flexxlam_msgs::Odometry expected_odom; @@ -105,7 +105,7 @@ TEST(FlexXlamParser, PushOdometryProtocolParseBatch) { flexxlam::FlexXlamParser parser(102400); struct TestParsedMessageInterface : public flexxlam::ParsedMessageInterface { - void on_get_odometry(const flexxlam_msgs::Odometry &odom) override { + void on_push_odometry(const flexxlam_msgs::Odometry &odom) override { is_odometry_same(expected_odoms[odom_idx++], odom); } vector expected_odoms; From 55a192427322e06a786ef151e2e3848b98192613 Mon Sep 17 00:00:00 2001 From: Jongkuk Lim Date: Tue, 21 Nov 2023 15:59:17 +0900 Subject: [PATCH 2/2] Fix include order. --- examples/client/flexxlam_client_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/client/flexxlam_client_example.cpp b/examples/client/flexxlam_client_example.cpp index aaea3b8..990b72a 100644 --- a/examples/client/flexxlam_client_example.cpp +++ b/examples/client/flexxlam_client_example.cpp @@ -5,9 +5,9 @@ #include "include/flexxlam_client_example.hpp" +#include #include -#include #include namespace flexxlam {