Skip to content

Commit 4e7fb8c

Browse files
committed
chore: Remove glog deps
1 parent 3f6ba4f commit 4e7fb8c

File tree

9 files changed

+64
-11
lines changed

9 files changed

+64
-11
lines changed

README.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Install deb dependencies
6868

6969
```bash
7070
# assume you have sourced ROS environment, same blow
71-
sudo apt install libgflags-dev nlohmann-json3-dev libgoogle-glog-dev \
71+
sudo apt install libgflags-dev nlohmann-json3-dev \
7272
ros-$ROS_DISTRO-image-transport ros-$ROS_DISTRO-image-publisher ros-$ROS_DISTRO-camera-info-manager \
7373
ros-$ROS_DISTRO-diagnostic-updater ros-$ROS_DISTRO-diagnostic-msgs
7474
```

orbbec_camera/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ foreach (dep IN LISTS dependencies)
4848
endforeach ()
4949

5050
find_package(PkgConfig REQUIRED)
51-
pkg_search_module(GLOG REQUIRED libglog)
5251

53-
if (NOT GLOG_FOUND)
54-
message(FATAL_ERROR "glog is not found")
55-
endif ()
5652

5753
if (USE_RK_HW_DECODER)
5854
pkg_search_module(RK_MPP REQUIRED rockchip_mpp)
@@ -106,14 +102,12 @@ set(COMMON_INCLUDE_DIRS
106102
$<INSTALL_INTERFACE:include>
107103
${ORBBEC_INCLUDE_DIR}
108104
${OpenCV_INCLUDED_DIRS}
109-
${GLOG_INCLUDED_DIRS}
110105
)
111106

112107
set(COMMON_LIBRARIES
113108
${ORBBEC_SDK_LIBRARIES}
114109
${OpenCV_LIBS}
115110
Eigen3::Eigen
116-
${GLOG_LIBRARIES}
117111
-lOrbbecSDK
118112
-L${ORBBEC_LIBS_DIR}
119113
Threads::Threads

orbbec_camera/include/orbbec_camera/jpeg_decoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string>
1919
#include <vector>
2020
#include "libobsensor/ObSensor.hpp"
21+
#include "utils.h"
2122

2223
namespace orbbec_camera {
2324

orbbec_camera/include/orbbec_camera/ob_camera_node.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#pragma once
1818

19-
#include <glog/logging.h>
2019
#include <nlohmann/json.hpp>
2120

2221
#include <memory>

orbbec_camera/include/orbbec_camera/rk_mpp_decoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <rockchip/mpp_rc_defs.h>
2525
#include <rockchip/mpp_task.h>
2626
#include <rockchip/rk_mpi.h>
27+
#include "utils.h"
28+
2729
#if defined(USE_LIBYUV)
2830
#include <libyuv.h>
2931
#else

orbbec_camera/include/orbbec_camera/synced_imu_publisher.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#pragma once
1818
#include <rclcpp/rclcpp.hpp>
19-
#include <glog/logging.h>
2019
#include <sensor_msgs/msg/imu.hpp>
2120
#include <queue>
2221
#include <mutex>

orbbec_camera/include/orbbec_camera/utils.h

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#pragma once
1818
#include <ostream>
19-
#include <glog/logging.h>
2019
#include <Eigen/Dense>
2120
#include <tf2/LinearMath/Quaternion.h>
2221
#include <rclcpp/rclcpp.hpp>
@@ -28,6 +27,64 @@
2827
#include "magic_enum/magic_enum.hpp"
2928
#include <sensor_msgs/msg/point_cloud2.hpp>
3029

30+
31+
namespace orbbec_camera {
32+
inline void LogFatal(const char *file, int line, const std::string &message) {
33+
std::cerr << "Check failed at " << file << ":" << line << ": " << message << std::endl;
34+
std::abort();
35+
}
36+
} // namespace orbbec_camera
37+
38+
// Macros for checking conditions and comparing values
39+
#define CHECK(condition) \
40+
(!(condition) ? LogFatal(__FILE__, __LINE__, "Check failed: " #condition) : (void)0)
41+
42+
template <typename T1, typename T2>
43+
void CheckOp(const char *expr, const char *file, int line, T1 val1, T2 val2, bool result) {
44+
if (!result) {
45+
std::ostringstream os;
46+
os << "Check failed: " << expr << " (" << val1 << " vs. " << val2 << ")";
47+
orbbec_camera::LogFatal(file, line, os.str());
48+
}
49+
}
50+
51+
#define CHECK_OP(opname, op, val1, val2) \
52+
CheckOp(#val1 " " #op " " #val2, __FILE__, __LINE__, val1, val2, (val1)op(val2))
53+
54+
#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
55+
#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
56+
#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
57+
#define CHECK_LT(val1, val2) CHECK_OP(_LT, <, val1, val2)
58+
#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
59+
#define CHECK_GT(val1, val2) CHECK_OP(_GT, >, val1, val2)
60+
61+
// Overload for raw pointers
62+
template <typename T>
63+
T *CheckNotNull(T *ptr, const char *file, int line) {
64+
if (ptr == nullptr) {
65+
std::ostringstream os;
66+
os << "Null pointer passed to CheckNotNull at " << file << ":" << line;
67+
orbbec_camera::LogFatal(file, line, os.str());
68+
}
69+
return ptr;
70+
}
71+
72+
// Template for smart pointers like std::shared_ptr, std::unique_ptr
73+
template <typename T>
74+
T &CheckNotNull(T &ptr, const char *file, int line) {
75+
if (ptr == nullptr) {
76+
std::ostringstream os;
77+
os << "Null pointer passed to CheckNotNull at " << file << ":" << line;
78+
orbbec_camera::LogFatal(file, line, os.str());
79+
}
80+
return ptr;
81+
}
82+
83+
#if defined(CHECK_NOTNULL)
84+
#undef CHECK_NOTNULL
85+
#endif
86+
#define CHECK_NOTNULL(val) CheckNotNull(val, __FILE__, __LINE__)
87+
3188
namespace orbbec_camera {
3289
sensor_msgs::msg::CameraInfo convertToCameraInfo(OBCameraIntrinsic intrinsic,
3390
OBCameraDistortion distortion, int width);

orbbec_camera/src/ob_camera_node_driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <rclcpp_components/register_node_macro.hpp>
2323
#include <csignal>
2424
#include <sys/mman.h>
25+
#include <unistd.h>
26+
2527

2628
namespace orbbec_camera {
2729
OBCameraNodeDriver::OBCameraNodeDriver(const rclcpp::NodeOptions &node_options)

orbbec_camera/src/rk_mpp_decoder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "orbbec_camera/rk_mpp_decoder.h"
1818
#include <rclcpp/rclcpp.hpp>
19-
#include <glog/logging.h>
2019
#include <magic_enum/magic_enum.hpp>
2120

2221
namespace orbbec_camera {

0 commit comments

Comments
 (0)