Skip to content

Commit

Permalink
temp: includes #231, #232, #233, #234, #235
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <[email protected]>
  • Loading branch information
mojomex committed Nov 26, 2024
1 parent e5857ab commit ca6112b
Show file tree
Hide file tree
Showing 18 changed files with 1,110 additions and 116 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"nproc",
"nsec",
"ntoa",
"OVFL",
"pandar",
"PANDAR",
"PANDARAT",
Expand Down
14 changes: 6 additions & 8 deletions nebula_common/include/nebula_common/loggers/console_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

#include <cstdio>
#include <iostream>
#include <istream>
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>

Expand All @@ -33,20 +31,20 @@ class ConsoleLogger : public Logger
public:
explicit ConsoleLogger(std::string name) : name_(std::move(name)) {}

void debug(const std::string & message) override { printTagged(std::cout, "DEBUG", message); }
void info(const std::string & message) override { printTagged(std::cout, "INFO", message); }
void warn(const std::string & message) override { printTagged(std::cerr, "WARN", message); }
void error(const std::string & message) override { printTagged(std::cerr, "ERROR", message); }
void debug(const std::string & message) override { print_tagged(std::cout, "DEBUG", message); }
void info(const std::string & message) override { print_tagged(std::cout, "INFO", message); }
void warn(const std::string & message) override { print_tagged(std::cerr, "WARN", message); }
void error(const std::string & message) override { print_tagged(std::cerr, "ERROR", message); }

std::shared_ptr<Logger> child(const std::string & name) override
{
return std::make_shared<ConsoleLogger>(name_ + "." + name);
}

private:
const std::string name_;
std::string name_;

void printTagged(std::ostream & os, const std::string & severity, const std::string & message)
void print_tagged(std::ostream & os, const std::string & severity, const std::string & message)
{
// In multithreaded logging, building the string first (... + ...) and then shifting to the
// stream will ensure that no other logger outputs between string fragments
Expand Down
9 changes: 5 additions & 4 deletions nebula_common/include/nebula_common/loggers/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
#include <sstream>
#include <string>

#define NEBULA_LOG_STREAM(log_func, stream_args) \
{ \
auto msg = (std::stringstream{} << stream_args).str(); \
log_func(msg); \
#define NEBULA_LOG_STREAM(log_func, stream_args) \
{ \
std::stringstream ss{}; \
ss << stream_args; \
log_func(ss.str()); \
}

namespace nebula::drivers::loggers
Expand Down
38 changes: 32 additions & 6 deletions nebula_hw_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.14)
project(nebula_hw_interfaces)

# Default to C++17
if (NOT CMAKE_CXX_STANDARD)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif ()
endif()

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wunused-function)
endif ()
endif()

find_package(ament_cmake_auto REQUIRED)
find_package(boost_tcp_driver)
Expand Down Expand Up @@ -53,7 +53,6 @@ target_link_libraries(nebula_hw_interfaces_velodyne PUBLIC
${boost_tcp_driver_LIBRARIES}
${boost_udp_driver_LIBRARIES}
${velodyne_msgs_TARGETS}

)
target_include_directories(nebula_hw_interfaces_velodyne PUBLIC
${boost_udp_driver_INCLUDE_DIRS}
Expand All @@ -68,7 +67,6 @@ target_link_libraries(nebula_hw_interfaces_robosense PUBLIC
${boost_tcp_driver_LIBRARIES}
${boost_udp_driver_LIBRARIES}
${robosense_msgs_TARGETS}

)
target_include_directories(nebula_hw_interfaces_robosense PUBLIC
${boost_udp_driver_INCLUDE_DIRS}
Expand Down Expand Up @@ -113,6 +111,34 @@ install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gtest REQUIRED)
find_package(ament_cmake_gmock REQUIRED)

ament_add_gtest(test_udp
test/common/test_udp.cpp
)

target_include_directories(test_udp PUBLIC
${nebula_common_INCLUDE_DIRS}
include
test)

ament_add_gmock(hesai_test_ptc
test/hesai/test_ptc.cpp
)

target_include_directories(hesai_test_ptc PUBLIC
${nebula_common_INCLUDE_DIRS}
${nebula_hw_interfaces_hesai_INCLUDE_DIRS}
${boost_tcp_driver_INCLUDE_DIRS}
${boost_udp_driver_INCLUDE_DIRS}
include
test)

target_link_libraries(hesai_test_ptc
nebula_hw_interfaces_hesai
)
endif()

ament_export_include_directories("include/${PROJECT_NAME}")
Expand Down
Loading

0 comments on commit ca6112b

Please sign in to comment.