Skip to content

Commit

Permalink
Add a CreatePlanningClient factory to make a ZMQ client or complain.
Browse files Browse the repository at this point in the history
Note: #1 will
remote the need for this by just having a ZMQ client, but that's
more refactoring than strictly needed for the split, so we'll use
this factory function briefly.
  • Loading branch information
heman.gandhi committed Aug 25, 2023
1 parent 5801dbc commit 611d9df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/mujinplanningclient/mujinplanningclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct CropContainerMarginsXYZXYZ

typedef boost::shared_ptr<CropContainerMarginsXYZXYZ> CropContainerMarginsXYZXYZPtr;


class MUJINPLANNINGCLIENT_API MujinPlanningClient
{
public:
Expand Down Expand Up @@ -638,7 +639,9 @@ class MUJINPLANNINGCLIENT_API MujinPlanningClient
};
typedef boost::shared_ptr<MujinPlanningClient> MujinPlanningClientPtr;

class BinpickingTaskZmqResource;

MujinPlanningClientPtr CreatePlanningClient(const std::string& scenebasename, const std::string& tasktype, const std::string& baseuri, const std::string& userName);

namespace utils {
MUJINPLANNINGCLIENT_API std::string GetJsonString(const std::string& string);
Expand Down
12 changes: 12 additions & 0 deletions src/mujinplanningclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#ifdef MUJIN_USEZMQ
#include "mujinplanningclient/zmq.hpp"
#include "binpickingtaskzmq.h"
#endif

#ifdef _WIN32
Expand Down Expand Up @@ -1827,6 +1828,17 @@ void MujinPlanningClient::_HeartbeatMonitorThread(const double reinitializetimeo
#endif
}


MujinPlanningClientPtr CreatePlanningClient(const std::string& scenebasename, const std::string& tasktype, const std::string& baseuri, const std::string& userName)
{
#ifdef MUJIN_USEZMQ
return boost::make_shared<BinpickingTaskZmqResource>(scenebasename, tasktype, baseuri, userName);
#else
MUJIN_LOG_ERROR("You've compiled the planning client without ZMQ! This is only possible for backwards compatibility so is unsupported and will disappear soon. Please use ZMQ!");
return boost::make_shared<MujinPlanningClient>(scenebasename, tasktype, baseuri, userName);
#endif
}

#ifdef MUJIN_USEZMQ
std::string utils::GetHeartbeat(const std::string& endpoint) {
zmq::context_t zmqcontext(1);
Expand Down

0 comments on commit 611d9df

Please sign in to comment.