Loading...
Searching...
No Matches
ros_interpreter.hh
Go to the documentation of this file.
1#ifndef DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
2#define DYNAMIC_GRAPH_BRIDGE_INTERPRETER_HH
3#pragma GCC diagnostic push
4#pragma GCC system_header
5#include <ros/ros.h>
6#pragma GCC diagnostic pop
7
8#include <dynamic_graph_bridge_msgs/RunCommand.h>
9#include <dynamic_graph_bridge_msgs/RunPythonFile.h>
10
11#include <dynamic-graph/python/interpreter.hh>
13
14namespace dynamicgraph {
22 public:
23 typedef boost::function<bool(
24 dynamic_graph_bridge_msgs::RunCommand::Request&,
25 dynamic_graph_bridge_msgs::RunCommand::Response&)>
27
28 typedef boost::function<bool(
29 dynamic_graph_bridge_msgs::RunPythonFile::Request&,
30 dynamic_graph_bridge_msgs::RunPythonFile::Response&)>
32
33 explicit Interpreter(ros::NodeHandle& nodeHandle);
34
37 void runCommand(const std::string& command, std::string& result,
38 std::string& out, std::string& err);
39
42 void runPythonFile(std::string ifilename);
43
46
47 protected:
49 bool runCommandCallback(dynamic_graph_bridge_msgs::RunCommand::Request& req,
50 dynamic_graph_bridge_msgs::RunCommand::Response& res);
51
54 dynamic_graph_bridge_msgs::RunPythonFile::Request& req,
55 dynamic_graph_bridge_msgs::RunPythonFile::Response& res);
56
57 private:
58 python::Interpreter interpreter_;
59 ros::NodeHandle& nodeHandle_;
60 ros::ServiceServer runCommandSrv_;
61 ros::ServiceServer runPythonFileSrv_;
62};
63} // end of namespace dynamicgraph.
64
65#endif
This class wraps the implementation of the runCommand service.
Definition: ros_interpreter.hh:21
void startRosService()
Initialize service run_command.
boost::function< bool(dynamic_graph_bridge_msgs::RunCommand::Request &, dynamic_graph_bridge_msgs::RunCommand::Response &)> runCommandCallback_t
Definition: ros_interpreter.hh:26
void runPythonFile(std::string ifilename)
Method to parse python scripts.
bool runCommandCallback(dynamic_graph_bridge_msgs::RunCommand::Request &req, dynamic_graph_bridge_msgs::RunCommand::Response &res)
Run a Python command and return result, stderr and stdout.
boost::function< bool(dynamic_graph_bridge_msgs::RunPythonFile::Request &, dynamic_graph_bridge_msgs::RunPythonFile::Response &)> runPythonFileCallback_t
Definition: ros_interpreter.hh:31
void runCommand(const std::string &command, std::string &result, std::string &out, std::string &err)
Method to start python interpreter and deal with messages.
bool runPythonFileCallback(dynamic_graph_bridge_msgs::RunPythonFile::Request &req, dynamic_graph_bridge_msgs::RunPythonFile::Response &res)
Run a Python file.
Interpreter(ros::NodeHandle &nodeHandle)
Definition: fwd.hh:14