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

Change on_get -> on_push callback method name #2

Merged
merged 2 commits into from
Nov 21, 2023
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
11 changes: 3 additions & 8 deletions examples/client/flexxlam_client_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@

#include "include/flexxlam_client_example.hpp"

#include <glog/logging.h>
#include <memory>

#include <communication/serial_communication.hpp>
#include <protocol/base_protocol.hpp>
#include <protocol/command/command_save_pcd_protocol.hpp>
#include <protocol/push/push_pointcloud_protocol.hpp>
#include <protocol/request/request_ethernet_communication_config.hpp>
#include <protocol/request/request_mavlink_communication_config.hpp>
#include <protocol/request/request_serial_communication_config.hpp>

namespace flexxlam {

Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions examples/client/include/flexxlam_client_example.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <vector>

#include <communication/flexxlam_parser.hpp>
#include <communication/serial_communication.hpp>
#include <communication/udp_communication.hpp>
#include <flexxlam_msgs/Odometry.hpp>
#include <flexxlam_msgs/PointCloud2.hpp>
Expand All @@ -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_;
Expand Down
6 changes: 3 additions & 3 deletions include/communication/flexxlam_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*`
Expand Down
2 changes: 1 addition & 1 deletion include/protocol/push/push_odometry_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PushOdometryProtocol : public BaseProtocol {
void handle_callback(
const vector<ParsedMessageInterface *> &callbacks) override {
for (auto callback : callbacks) {
callback->on_get_odometry(this->odom);
callback->on_push_odometry(this->odom);
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/protocol/push/push_pointcloud_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PushPointCloudProtocol : public BaseProtocol {
void handle_callback(
const vector<ParsedMessageInterface *> &callbacks) override {
for (auto callback : callbacks) {
callback->on_get_pointcloud(this->pointcloud_);
callback->on_push_pointcloud(this->pointcloud_);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flexxlam_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<flexxlam_msgs::Odometry> expected_odoms;
Expand Down