dynamic_graph_manager
dynamic_graph::RosPythonInterpreter Class Reference

This class wraps the implementation of the runCommand service. More...

#include <ros_interpreter.hh>

Public Types

typedef 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. More...
 
typedef 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. More...
 

Public Member Functions

 RosPythonInterpreter (ros::NodeHandle &node_handle)
 RosPythonInterpreter is the unique constructor of the class. More...
 
 ~RosPythonInterpreter ()
 ~RosPythonInterpreter is the default destructor of the class
 
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 More...
 
void run_python_file (const std::string ifilename, std::string &standard_error)
 run_python_file executes the input scripts in the python interpreter More...
 
void start_ros_service ()
 start_ros_service advertize the "run_python_command" and "run_python_scripts" ros services
 

Protected Member Functions

bool runCommandCallback (dynamic_graph_manager::RunCommand::Request &req, dynamic_graph_manager::RunCommand::Response &res)
 runCommandCallback is the "run_python_command" ros service callback function. More...
 
bool runPythonFileCallback (dynamic_graph_manager::RunPythonFile::Request &req, dynamic_graph_manager::RunPythonFile::Response &res)
 runCommandCallback is the "run_python_script" ros service callback function. More...
 

Private Attributes

dynamicgraph::python::Interpreter interpreter_
 interpreter_ is the python interpreter itself
 
ros::NodeHandle & ros_node_handle_
 ros_node_handle_ is reference to the ros::NodeHandle used to advertize the ros::services
 
ros::ServiceServer run_python_command_srv_
 run_python_command_srv_ is the "run_python_command" ros::service c++ object More...
 
ros::ServiceServer run_python_file_srv_
 run_python_file_srv_ is the "run_python_script" ros::service c++ object More...
 

Detailed Description

This class wraps the implementation of the runCommand service.

This takes as input a ROS node handle and do not handle the callback so that the service behavior can be controlled from the outside.

Member Typedef Documentation

◆ run_python_command_callback_t

typedef boost::function<bool(dynamic_graph_manager::RunCommand::Request&, dynamic_graph_manager::RunCommand::Response&)> dynamic_graph::RosPythonInterpreter::run_python_command_callback_t

run_python_command_callback_t define a boost::function to be used as callback to the ros::service.

The first argument of "runCommandCallback" (const std::string & command) is bound to (dynamic_graph_manager::RunCommand::Request). And the second argument (std::string &result) is bound to (dynamic_graph_manager::RunCommand::Response)

◆ run_python_file_callback_t

typedef boost::function<bool( dynamic_graph_manager::RunPythonFile::Request&, dynamic_graph_manager::RunPythonFile::Response&)> dynamic_graph::RosPythonInterpreter::run_python_file_callback_t

run_python_file_callback_t define a boost::function to be used as callback to the ros::service.

The first argument of "runPythonFileCallback" (std::string ifilename) is bound to (dynamic_graph_manager::RunCommand::Request). And a fake second argument is simulated in (dynamic_graph_manager::RunCommand::Response)

Constructor & Destructor Documentation

◆ RosPythonInterpreter()

dynamic_graph::RosPythonInterpreter::RosPythonInterpreter ( ros::NodeHandle &  node_handle)
explicit

RosPythonInterpreter is the unique constructor of the class.

Parameters
node_handleis the ros::nodeHandle used to advertize the ros::services

Member Function Documentation

◆ run_python_command()

void dynamic_graph::RosPythonInterpreter::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

Parameters
[in]commandis the user input string command.
[out]resultis the numerical result of the operation done.
[out]outis the string representation of the results.
[out]erris the output error string from python.

◆ run_python_file()

void dynamic_graph::RosPythonInterpreter::run_python_file ( const std::string  ifilename,
std::string &  standard_error 
)

run_python_file executes the input scripts in the python interpreter

Parameters
ifilenameis the path to the script to execute

◆ runCommandCallback()

bool dynamic_graph::RosPythonInterpreter::runCommandCallback ( dynamic_graph_manager::RunCommand::Request &  req,
dynamic_graph_manager::RunCommand::Response &  res 
)
protected

runCommandCallback is the "run_python_command" ros service callback function.

Parameters
reqis the request. it is defined as a string in the RunCommand.msg
resis the request. it is defined as a string in the RunCommand.msg
Returns
true

◆ runPythonFileCallback()

bool dynamic_graph::RosPythonInterpreter::runPythonFileCallback ( dynamic_graph_manager::RunPythonFile::Request &  req,
dynamic_graph_manager::RunPythonFile::Response &  res 
)
protected

runCommandCallback is the "run_python_script" ros service callback function.

Parameters
reqis the request. it is defined as a string in the RunCommand.msg
resis the request. it is defined as a string in the RunCommand.msg
Returns
true

Member Data Documentation

◆ run_python_command_srv_

ros::ServiceServer dynamic_graph::RosPythonInterpreter::run_python_command_srv_
private

run_python_command_srv_ is the "run_python_command" ros::service c++ object

This kind of ros object require NOT to be destroyed. otherwize the ros::service is cancelled. This is the reason why this object is an attribute of the class

◆ run_python_file_srv_

ros::ServiceServer dynamic_graph::RosPythonInterpreter::run_python_file_srv_
private

run_python_file_srv_ is the "run_python_script" ros::service c++ object

This kind of ros object require NOT to be destroyed. otherwize the ros::service is cancelled. This is the reason why this object is an attribute of the class


The documentation for this class was generated from the following files: