From e35cce8df477b047b3a75212f1cff54fc28fb819 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Wed, 23 Apr 2025 20:35:08 +0900 Subject: [PATCH 1/3] need to initialize socket --- src/mujinzmq.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mujinzmq.cpp b/src/mujinzmq.cpp index fcfb814e..13dee2bf 100644 --- a/src/mujinzmq.cpp +++ b/src/mujinzmq.cpp @@ -178,6 +178,7 @@ void ZmqSubscriber::_DestroySocket() ZmqPublisher::ZmqPublisher(const unsigned int port) { _port = port; + _InitializeSocket(nullptr); } ZmqPublisher::~ZmqPublisher() From e1698ad7f002d1351eeb1d7b32f80563ca2448bf Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Wed, 23 Apr 2025 22:13:00 +0900 Subject: [PATCH 2/3] Enable to specify zmq publisher end point host name. if empty, used as wildcard --- include/mujincontrollerclient/mujinzmq.h | 4 ++-- src/mujinzmq.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mujincontrollerclient/mujinzmq.h b/include/mujincontrollerclient/mujinzmq.h index 07d59a82..3d0cae4c 100644 --- a/include/mujincontrollerclient/mujinzmq.h +++ b/include/mujincontrollerclient/mujinzmq.h @@ -52,7 +52,7 @@ class MUJINCLIENT_API ZmqSubscriber class MUJINCLIENT_API ZmqPublisher { public: - ZmqPublisher(const unsigned int port); + ZmqPublisher(const unsigned int port, const std::string& host = std::string()); virtual ~ZmqPublisher(); bool Publish(const std::string& messagestr); @@ -62,7 +62,7 @@ class MUJINCLIENT_API ZmqPublisher } protected: - void _InitializeSocket(boost::shared_ptr context); + void _InitializeSocket(boost::shared_ptr context, const std::string& host); void _DestroySocket(); boost::shared_ptr _context; diff --git a/src/mujinzmq.cpp b/src/mujinzmq.cpp index 13dee2bf..61ddc618 100644 --- a/src/mujinzmq.cpp +++ b/src/mujinzmq.cpp @@ -175,10 +175,10 @@ void ZmqSubscriber::_DestroySocket() } } -ZmqPublisher::ZmqPublisher(const unsigned int port) +ZmqPublisher::ZmqPublisher(const unsigned int port, const std::string& host) { _port = port; - _InitializeSocket(nullptr); + _InitializeSocket(nullptr, host); } ZmqPublisher::~ZmqPublisher() @@ -193,7 +193,7 @@ bool ZmqPublisher::Publish(const std::string& messagestr) return _socket->send(message); } -void ZmqPublisher::_InitializeSocket(boost::shared_ptr context) +void ZmqPublisher::_InitializeSocket(boost::shared_ptr context, const std::string& host) { if (!!context) { _context = context; @@ -212,7 +212,7 @@ void ZmqPublisher::_InitializeSocket(boost::shared_ptr context) _socket->setsockopt(ZMQ_LINGER, 100); // ms std::ostringstream port_stream; port_stream << _port; - _socket->bind (("tcp://*:" + port_stream.str()).c_str()); + _socket->bind (("tcp://" + (host.empty() ? "*" : host) + ":" + port_stream.str()).c_str()); } void ZmqPublisher::_DestroySocket() From 752d6d32ad325d1d2f8be5219bb6022cc010b193 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Wed, 23 Apr 2025 22:43:35 +0900 Subject: [PATCH 3/3] Bump minor version and update changelog. --- CHANELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANELOG.md b/CHANELOG.md index 2332d69d..260da376 100644 --- a/CHANELOG.md +++ b/CHANELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.82.0 (2025-04-23) + +- Initialize sockets in ZMQPulisher and add host name argument. + ## 0.81.1 (2025-04-14) - Use only ZMQ for BinPickingTask when compiled with ZMQ. diff --git a/CMakeLists.txt b/CMakeLists.txt index e116ab0f..116dc668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) # Define here the needed parameters # make sure to change the version in docs/Makefile set (MUJINCLIENT_VERSION_MAJOR 0) -set (MUJINCLIENT_VERSION_MINOR 81) -set (MUJINCLIENT_VERSION_PATCH 1) +set (MUJINCLIENT_VERSION_MINOR 82) +set (MUJINCLIENT_VERSION_PATCH 0) set (MUJINCLIENT_VERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}.${MUJINCLIENT_VERSION_PATCH}) set (MUJINCLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}) set (CLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR})