dynamic_graph_manager
ros_interpreter.hh
Go to the documentation of this file.
1 
13 #ifndef DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
14 #define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
15 
16 #include <dynamic_graph_manager/RunCommand.h>
17 #include <dynamic_graph_manager/RunPythonFile.h>
18 #include <ros/ros.h>
19 #include <dynamic-graph/python/interpreter.hh>
20 
21 namespace dynamic_graph
22 {
30 {
31 public:
42  typedef boost::function<bool(dynamic_graph_manager::RunCommand::Request&,
43  dynamic_graph_manager::RunCommand::Response&)>
45 
56  typedef boost::function<bool(
57  dynamic_graph_manager::RunPythonFile::Request&,
58  dynamic_graph_manager::RunPythonFile::Response&)>
60 
66  explicit RosPythonInterpreter(ros::NodeHandle& node_handle);
67 
72 
81  void run_python_command(const std::string& command,
82  std::string& result,
83  std::string& out,
84  std::string& err);
85 
91  void run_python_file(const std::string ifilename,
92  std::string& standard_error);
93 
98  void start_ros_service();
99 
100 protected:
110  bool runCommandCallback(dynamic_graph_manager::RunCommand::Request& req,
111  dynamic_graph_manager::RunCommand::Response& res);
112 
123  dynamic_graph_manager::RunPythonFile::Request& req,
124  dynamic_graph_manager::RunPythonFile::Response& res);
125 
126 private:
130  dynamicgraph::python::Interpreter interpreter_;
135  ros::NodeHandle& ros_node_handle_;
144  ros::ServiceServer run_python_command_srv_;
153  ros::ServiceServer run_python_file_srv_;
154 };
155 } // namespace dynamic_graph
156 
157 #endif
bool runCommandCallback(dynamic_graph_manager::RunCommand::Request &req, dynamic_graph_manager::RunCommand::Response &res)
runCommandCallback is the "run_python_command" ros service callback function.
Definition: ros_interpreter.cpp:43
RosPythonInterpreter(ros::NodeHandle &node_handle)
RosPythonInterpreter is the unique constructor of the class.
Definition: ros_interpreter.cpp:16
void start_ros_service()
start_ros_service advertize the "run_python_command" and "run_python_scripts" ros services ...
Definition: ros_interpreter.cpp:30
boost::function< bool(dynamic_graph_manager::RunCommand::Request &, dynamic_graph_manager::RunCommand::Response &)> run_python_command_callback_t
run_python_command_callback_t define a boost::function to be used as callback to the ros::service...
Definition: ros_interpreter.hh:44
This class wraps the implementation of the runCommand service.
Definition: ros_interpreter.hh:29
dynamicgraph::python::Interpreter interpreter_
interpreter_ is the python interpreter itself
Definition: ros_interpreter.hh:130
this is this package namespace in order to avoid naming conflict
Definition: device.hh:22
ros::NodeHandle & ros_node_handle_
ros_node_handle_ is reference to the ros::NodeHandle used to advertize the ros::services ...
Definition: ros_interpreter.hh:135
ros::ServiceServer run_python_file_srv_
run_python_file_srv_ is the "run_python_script" ros::service c++ object
Definition: ros_interpreter.hh:153
~RosPythonInterpreter()
~RosPythonInterpreter is the default destructor of the class
Definition: ros_interpreter.cpp:24
boost::function< bool(dynamic_graph_manager::RunPythonFile::Request &, dynamic_graph_manager::RunPythonFile::Response &)> run_python_file_callback_t
run_python_file_callback_t define a boost::function to be used as callback to the ros::service...
Definition: ros_interpreter.hh:59
ros::ServiceServer run_python_command_srv_
run_python_command_srv_ is the "run_python_command" ros::service c++ object
Definition: ros_interpreter.hh:144
void run_python_file(const std::string ifilename, std::string &standard_error)
run_python_file executes the input scripts in the python interpreter
Definition: ros_interpreter.cpp:70
void run_python_command(const std::string &command, std::string &result, std::string &out, std::string &err)
run_python_command used the python interpreter to execute the input command
Definition: ros_interpreter.cpp:62
bool runPythonFileCallback(dynamic_graph_manager::RunPythonFile::Request &req, dynamic_graph_manager::RunPythonFile::Response &res)
runCommandCallback is the "run_python_script" ros service callback function.
Definition: ros_interpreter.cpp:52