Skip to content

Commit 95de051

Browse files
[ros.cpp] Add macOS Support - Remove executor namespace for Humble
1 parent f9c0760 commit 95de051

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/ros.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@
77
* @date 2019-05-22
88
*/
99

10+
/// Standard includes
1011
#include <deque>
1112
#include <atomic>
1213
#include <fstream>
1314
#include <chrono>
1415
#include <thread>
1516

17+
/// ROS2 includes
18+
#include <rclcpp/executor.hpp>
19+
20+
/// Dynamic Bridge include
1621
#include "dynamic_graph_bridge/ros.hpp"
1722

23+
#ifdef __APPLE__
24+
#include <mach-o/dyld.h>
25+
#include <sys/param.h>
26+
#endif
27+
1828
namespace dynamic_graph_bridge
1929
{
2030
/*
@@ -49,7 +59,7 @@ static GlobalListOfRosNodeType GLOBAL_LIST_OF_ROS_NODE;
4959
class Executor
5060
{
5161
public:
52-
Executor() : ros_executor_(rclcpp::executor::ExecutorArgs(), 4)
62+
Executor() : ros_executor_(rclcpp::ExecutorOptions(), 4)
5363
{
5464
is_thread_running_ = false;
5565
is_spinning_ = false;
@@ -189,7 +199,7 @@ ExecutorPtr EXECUTOR = nullptr;
189199
/**
190200
* @brief Private function that allow us to get the current executable name.
191201
*
192-
* @return std::string the current executable name.
202+
* @Return std::string the current executable name.
193203
*/
194204
std::string executable_name()
195205
{
@@ -206,6 +216,11 @@ std::string executable_name()
206216
GetModuleFileNameA(nullptr, buf, MAX_PATH);
207217
return buf;
208218

219+
#elif defined(__APPLE__)
220+
uint32_t buf_length=MAXPATHLEN;
221+
char buf[MAXPATHLEN];
222+
_NSGetExecutablePath(buf,&buf_length);
223+
return buf;
209224
#else
210225

211226
static_assert(false, "unrecognized platform");

0 commit comments

Comments
 (0)