Skip to content
Snippets Groups Projects
Commit 8eb39ab9 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Clean RosPublish commands.

parent 7f756489
No related branches found
No related tags found
No related merge requests found
...@@ -8,5 +8,10 @@ BOOST_PYTHON_MODULE(wrap) ...@@ -8,5 +8,10 @@ BOOST_PYTHON_MODULE(wrap)
{ {
bp::import("dynamic_graph"); bp::import("dynamic_graph");
dg::python::exposeEntity<dg::RosPublish, bp::bases<dg::Entity>, dg::python::AddCommands>() ; dg::python::exposeEntity<dg::RosPublish, bp::bases<dg::Entity>, dg::python::AddCommands>()
.def("clear", &dg::RosPublish::clear, "Remove all signals writing data to a ROS topic")
.def("rm", &dg::RosPublish::rm, "Remove a signal writing data to a ROS topic",
bp::args("signal_name"))
.def("list", &dg::RosPublish::list, "List signals writing data to a ROS topic")
;
} }
...@@ -28,23 +28,6 @@ const double RosPublish::ROS_JOINT_STATE_PUBLISHER_RATE = 0.01; ...@@ -28,23 +28,6 @@ const double RosPublish::ROS_JOINT_STATE_PUBLISHER_RATE = 0.01;
namespace command { namespace command {
namespace rosPublish { namespace rosPublish {
Clear::Clear(RosPublish& entity, const std::string& docstring)
: Command(entity, std::vector<Value::Type>(), docstring) {}
Value Clear::doExecute() {
RosPublish& entity = static_cast<RosPublish&>(owner());
entity.clear();
return Value();
}
List::List(RosPublish& entity, const std::string& docstring)
: Command(entity, std::vector<Value::Type>(), docstring) {}
Value List::doExecute() {
RosPublish& entity = static_cast<RosPublish&>(owner());
return Value(entity.list());
}
Add::Add(RosPublish& entity, const std::string& docstring) Add::Add(RosPublish& entity, const std::string& docstring)
: Command(entity, boost::assign::list_of(Value::STRING)(Value::STRING)(Value::STRING), docstring) {} : Command(entity, boost::assign::list_of(Value::STRING)(Value::STRING)(Value::STRING), docstring) {}
...@@ -88,16 +71,6 @@ Value Add::doExecute() { ...@@ -88,16 +71,6 @@ Value Add::doExecute() {
return Value(); return Value();
} }
Rm::Rm(RosPublish& entity, const std::string& docstring)
: Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
Value Rm::doExecute() {
RosPublish& entity = static_cast<RosPublish&>(owner());
std::vector<Value> values = getParameterValues();
const std::string& signal = values[0].value();
entity.rm(signal);
return Value();
}
} // namespace rosPublish } // namespace rosPublish
} // end of namespace command. } // end of namespace command.
...@@ -143,29 +116,6 @@ RosPublish::RosPublish(const std::string& n) ...@@ -143,29 +116,6 @@ RosPublish::RosPublish(const std::string& n)
" - topic: the topic name in ROS.\n" " - topic: the topic name in ROS.\n"
"\n"; "\n";
addCommand("add", new command::rosPublish::Add(*this, docstring)); addCommand("add", new command::rosPublish::Add(*this, docstring));
docstring =
"\n"
" Remove a signal writing data to a ROS topic\n"
"\n"
" Input:\n"
" - name of the signal to remove (see method list for the list of "
"signals).\n"
"\n";
addCommand("rm", new command::rosPublish::Rm(*this, docstring));
docstring =
"\n"
" Remove all signals writing data to a ROS topic\n"
"\n"
" No input:\n"
"\n";
addCommand("clear", new command::rosPublish::Clear(*this, docstring));
docstring =
"\n"
" List signals writing data to a ROS topic\n"
"\n"
" No input:\n"
"\n";
addCommand("list", new command::rosPublish::List(*this, docstring));
} }
RosPublish::~RosPublish() { aofs_.close(); } RosPublish::~RosPublish() { aofs_.close(); }
...@@ -187,13 +137,10 @@ void RosPublish::rm(const std::string& signal) { ...@@ -187,13 +137,10 @@ void RosPublish::rm(const std::string& signal) {
bindedSignal_.erase(signal); bindedSignal_.erase(signal);
} }
std::string RosPublish::list() const { std::vector<std::string> RosPublish::list() const {
std::string result("["); std::vector<std::string> result(bindedSignal_.size());
for (std::map<std::string, bindedSignal_t>::const_iterator it = bindedSignal_.begin(); it != bindedSignal_.end(); std::transform(bindedSignal_.begin(), bindedSignal_.end(),
it++) { result.begin(), [](const auto& pair) { return pair.first; });
result += "'" + it->first + "',";
}
result += "]";
return result; return result;
} }
......
...@@ -34,9 +34,6 @@ using ::dynamicgraph::command::Value; ...@@ -34,9 +34,6 @@ using ::dynamicgraph::command::Value;
} }
ROS_PUBLISH_MAKE_COMMAND(Add); ROS_PUBLISH_MAKE_COMMAND(Add);
ROS_PUBLISH_MAKE_COMMAND(Clear);
ROS_PUBLISH_MAKE_COMMAND(List);
ROS_PUBLISH_MAKE_COMMAND(Rm);
#undef ROS_PUBLISH_MAKE_COMMAND #undef ROS_PUBLISH_MAKE_COMMAND
...@@ -62,7 +59,7 @@ class RosPublish : public dynamicgraph::Entity { ...@@ -62,7 +59,7 @@ class RosPublish : public dynamicgraph::Entity {
void add(const std::string& signal, const std::string& topic); void add(const std::string& signal, const std::string& topic);
void rm(const std::string& signal); void rm(const std::string& signal);
std::string list() const; std::vector<std::string> list() const;
void clear(); void clear();
int& trigger(int&, int); int& trigger(int&, int);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment