From 595edc413099240043faa0f7ca0741892f30ecc9 Mon Sep 17 00:00:00 2001 From: Timothy Wiley Date: Sat, 11 Mar 2017 22:24:57 +1100 Subject: [PATCH] Add ability to send generic command message - not just strings --- crosbot/include/crosbot/controls/command.hpp | 36 ++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/crosbot/include/crosbot/controls/command.hpp b/crosbot/include/crosbot/controls/command.hpp index d5aa972..feb4b09 100644 --- a/crosbot/include/crosbot/controls/command.hpp +++ b/crosbot/include/crosbot/controls/command.hpp @@ -53,20 +53,30 @@ private: }; /** - * Send command with the provided args + * Send command with the provided message + * Over-writes namespace and stamp */ void sendCommand(crosbot_msgs::ControlCommand::_cmd_namespace_type nspace, - crosbot_msgs::ControlCommand::_command_type command, - const crosbot_msgs::ControlCommand::_args_type& args) { + crosbot_msgs::ControlCommand& msg) { if (send) { - crosbot_msgs::ControlCommand msg; msg.header.stamp = ros::Time::now(); msg.cmd_namespace = nspace; - msg.command = command; - msg.args = args; publisher.publish(msg); } } + + /** + * Send command with the provided args + */ + void sendCommand(crosbot_msgs::ControlCommand::_cmd_namespace_type nspace, + crosbot_msgs::ControlCommand::_command_type command, + const crosbot_msgs::ControlCommand::_args_type& args) { + crosbot_msgs::ControlCommand msg; + msg.header.stamp = ros::Time::now(); + msg.cmd_namespace = nspace; + msg.command = command; + msg.args = args; + } public: /** @@ -120,6 +130,13 @@ public: */ bool canReceive() { return receive; }; + /** + * Send command with the provided message + */ + void sendCommandAll(crosbot_msgs::ControlCommand& msg) { + sendCommand("", msg); + } + /** * Send command with arguments using "all" namespace */ @@ -136,6 +153,13 @@ public: sendCommandAll(command, args); } + /** + * Send command with the provided message + */ + void sendCommandNamespace(crosbot_msgs::ControlCommand& msg) { + sendCommand(nspace, msg); + } + /** * Send command with zero arguments using the configured namespace */ -- GitLab