From 38178017d6266bb976cb790850333a648d92935b Mon Sep 17 00:00:00 2001
From: Thomas Moulard <thomas.moulard@gmail.com>
Date: Tue, 28 Feb 2012 01:19:58 +0100
Subject: [PATCH] Add runCommand method to interpreter.

---
 include/dynamic_graph_bridge/ros_interpreter.hh |  3 +++
 src/ros_interpreter.cpp                         | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/dynamic_graph_bridge/ros_interpreter.hh b/include/dynamic_graph_bridge/ros_interpreter.hh
index ed6173e..271562c 100644
--- a/include/dynamic_graph_bridge/ros_interpreter.hh
+++ b/include/dynamic_graph_bridge/ros_interpreter.hh
@@ -23,6 +23,9 @@ namespace dynamicgraph
 
     explicit Interpreter (ros::NodeHandle& nodeHandle);
 
+    /// \brief Run a command and return result.
+    std::string runCommand (const std::string& command);
+
   protected:
     /// \brief Run a Python command and return result, stderr and stdout.
     bool runCommandCallback (dynamic_graph_bridge::RunCommand::Request& req,
diff --git a/src/ros_interpreter.cpp b/src/ros_interpreter.cpp
index fac3a75..d9a4ca9 100644
--- a/src/ros_interpreter.cpp
+++ b/src/ros_interpreter.cpp
@@ -17,11 +17,19 @@ namespace dynamicgraph
   }
 
   bool
-  Interpreter::runCommandCallback(dynamic_graph_bridge::RunCommand::Request& req,
-				  dynamic_graph_bridge::RunCommand::Response& res)
+  Interpreter::runCommandCallback
+  (dynamic_graph_bridge::RunCommand::Request& req,
+   dynamic_graph_bridge::RunCommand::Response& res)
   {
     interpreter_.python(req.input, res.result, res.stdout, res.stderr);
     return true;
   }
+
+  std::string
+  Interpreter::runCommand
+  (const std::string& command)
+  {
+    return interpreter_.python(command);
+  }
 } // end of namespace dynamicgraph.
 
-- 
GitLab