Skip to content
Snippets Groups Projects
Commit 595edc41 authored by Timothy Wiley's avatar Timothy Wiley
Browse files

Add ability to send generic command message - not just strings

parent 86ef8842
No related branches found
No related tags found
No related merge requests found
......@@ -52,20 +52,30 @@ private:
}
};
/**
* Send command with the provided message
* Over-writes namespace and stamp
*/
void sendCommand(crosbot_msgs::ControlCommand::_cmd_namespace_type nspace,
crosbot_msgs::ControlCommand& msg) {
if (send) {
msg.header.stamp = ros::Time::now();
msg.cmd_namespace = nspace;
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) {
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);
}
}
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
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment