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(hesai_hw_interface): use dependency-injected logger, get rid of RCLCPP dependency #232

Merged
merged 4 commits into from
Nov 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Have to define macros to silence warnings about deprecated headers being used by
// boost/property_tree/ in some versions of boost.
// See: https://github.com/boostorg/property_tree/issues/51
#include "nebula_common/nebula_status.hpp"
#include <nebula_common/nebula_status.hpp>

#include <boost/version.hpp>

Expand All @@ -28,15 +28,15 @@
#if (BOOST_VERSION / 100 == 1074) // Boost 1.74
#define BOOST_ALLOW_DEPRECATED_HEADERS
#endif
#include "boost_tcp_driver/http_client_driver.hpp"
#include "boost_tcp_driver/tcp_driver.hpp"
#include "boost_udp_driver/udp_driver.hpp"
#include "nebula_common/hesai/hesai_common.hpp"
#include "nebula_common/hesai/hesai_status.hpp"
#include "nebula_common/util/expected.hpp"
#include "nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp"

#include <rclcpp/rclcpp.hpp>
#include <boost_tcp_driver/http_client_driver.hpp>
#include <boost_tcp_driver/tcp_driver.hpp>
#include <boost_udp_driver/udp_driver.hpp>
#include <nebula_common/hesai/hesai_common.hpp>
#include <nebula_common/hesai/hesai_status.hpp>
#include <nebula_common/loggers/logger.hpp>
#include <nebula_common/util/expected.hpp>

#include <boost/algorithm/string.hpp>
#include <boost/property_tree/json_parser.hpp>
Expand Down Expand Up @@ -136,6 +136,7 @@ class HesaiHwInterface

using ptc_cmd_result_t = nebula::util::expected<std::vector<uint8_t>, ptc_error_t>;

std::shared_ptr<loggers::Logger> logger_;
std::unique_ptr<::drivers::common::IoContext> cloud_io_context_;
std::shared_ptr<boost::asio::io_context> m_owned_ctx;
std::unique_ptr<::drivers::udp_driver::UdpDriver> cloud_udp_driver_;
Expand Down Expand Up @@ -165,20 +166,6 @@ class HesaiHwInterface
/// @param str Received string
void str_cb(const std::string & str);

std::shared_ptr<rclcpp::Logger> parent_node_logger;
/// @brief Printing the string to RCLCPP_INFO_STREAM
/// @param info Target string
void PrintInfo(std::string info);
/// @brief Printing the string to RCLCPP_ERROR_STREAM
/// @param error Target string
void PrintError(std::string error);
/// @brief Printing the string to RCLCPP_DEBUG_STREAM
/// @param debug Target string
void PrintDebug(std::string debug);
/// @brief Printing the bytes to RCLCPP_DEBUG_STREAM
/// @param bytes Target byte vector
void PrintDebug(const std::vector<uint8_t> & bytes);

/// @brief Convert an error code to a human-readable string
/// @param error_code The error code, containing the sensor's error code (if any), along with
/// flags such as TCP_ERROR_UNRELATED_RESPONSE etc.
Expand All @@ -202,7 +189,7 @@ class HesaiHwInterface

public:
/// @brief Constructor
HesaiHwInterface();
explicit HesaiHwInterface(const std::shared_ptr<loggers::Logger> & logger);
/// @brief Destructor
~HesaiHwInterface();
/// @brief Initializing tcp_driver for TCP communication
Expand Down Expand Up @@ -460,10 +447,6 @@ class HesaiHwInterface
/// @brief Whether to use HTTP for getting LidarMonitor
/// @return Use HTTP
bool UseHttpGetLidarMonitor();

/// @brief Setting rclcpp::Logger
/// @param node Logger
void SetLogger(std::shared_ptr<rclcpp::Logger> node);
};
} // namespace nebula::drivers

Expand Down
Loading
Loading