diff --git a/crosbot/include/crosbot/controls/command.hpp b/crosbot/include/crosbot/controls/command.hpp index d0664c355c6f43969f9c331d363efddd24aba6d7..d5aa9721a7495b22df9885c0da52b94edff95fb6 100644 --- a/crosbot/include/crosbot/controls/command.hpp +++ b/crosbot/include/crosbot/controls/command.hpp @@ -43,9 +43,10 @@ private: bool send; bool receive; + bool listenGlobal; // Listen to commands on global namespace void _callback_receivedCommand(const crosbot_msgs::ControlCommandPtr command) { - if (command->cmd_namespace == "" || + if ((listenGlobal && command->cmd_namespace == "") || command->cmd_namespace == nspace) { callback->callback_receivedCommand(command); } @@ -82,11 +83,13 @@ public: */ CrosbotCommand(crosbot_msgs::ControlCommand::_cmd_namespace_type nspace = "", bool send = false, - CrosbotCommandCallbackPtr callback = NULL) : + CrosbotCommandCallbackPtr callback = NULL, + bool listenGlobal = true) : send(send), receive(false), nspace(nspace), - callback(callback) + callback(callback), + listenGlobal(listenGlobal) { // Node handle with "root" namespace ros::NodeHandle nh("");