machines-in-motion / dynamic_graph_manager

BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

ros2 run dynamic_graph_manager remote_python_client <python script> hang. #28

Closed MaximilienNaveau closed 3 years ago

MaximilienNaveau commented 3 years ago

Running on Solo12 we have this issue. The following command hang.

ros2 run dynamic_graph_manager remote_python_client <python script>

With this output:

~/dev/blmc_testing/workspace/src/dg_demos/src/dg_demos/solo12/controllers$ ros2 run dynamic_graph_manager remote_python_client pd_controller.py
[INFO] [RosPythonInterpreterClient]: Waiting for service /dynamic_graph_manager/run_python_command ...
[INFO] [RosPythonInterpreterClient]: Successfully connected to /dynamic_graph_manager/run_python_command
[INFO] [RosPythonInterpreterClient]: Waiting for service /dynamic_graph_manager/run_python_file ...
[INFO] [RosPythonInterpreterClient]: Successfully connected to /dynamic_graph_manager/run_python_file
jviereck commented 3 years ago

Adding some debug logs, it seems the call from the client to the server happens. However, the server gets stuck in this method:

void RosPythonInterpreterServer::run_python_file(const std::string ifilename,
                                                 std::string& standard_error)
{
    interpreter_.runPythonFile(ifilename, standard_error);
}
/controllers$ ros2 run dynamic_graph_manager remote_python_client pd_controller.py
[INFO] [RosPythonInterpreterClient]: Waiting for service /dynamic_graph_manager/run_python_command ...
[INFO] [RosPythonInterpreterClient]: Successfully connected to /dynamic_graph_manager/run_python_command
[INFO] [RosPythonInterpreterClient]: Waiting for service /dynamic_graph_manager/run_python_file ...
[INFO] [RosPythonInterpreterClient]: Successfully connected to /dynamic_graph_manager/run_python_file
RosPythonInterpreterClient::run_python_script
RosPythonInterpreterClient::run_python_script. Got file
RosPythonInterpreterClient::run_python_script. Making async request.
RosPythonInterpreterClient::run_python_script. After making async request.
dg_blmc_robots# ./dg_main_solo12
[...]
RosPythonInterpreterServer::runPythonFileCallback. req->input=/home/jviereck/dev/blmc_testing/workspace/src/dg_demos/src/dg_demos/solo12/controllers/pd_controller.py
MaximilienNaveau commented 3 years ago

instead of calling the C++ run_scripts we could call the C++ run_python_command with a python command that parse the script?

jviereck commented 3 years ago

Loading the script first into content and then executing it gives the following result:

>>> exec(content)
[ERROR] [rclcpp]: Error while parsing command, retrying...
[ERROR] [rclcpp]: Error while parsing command, retrying...
[ERROR] [rclcpp]: Error while parsing command, retrying...
[ERROR] [rclcpp]: Error while parsing command, retrying...

where there is a new [ERROR] [rclcpp]: Error while parsing command, retrying... printed every second.

MaximilienNaveau commented 3 years ago

The problem came from the import from scipy. The huge import might get the real-time process in a racing condition.

MaximilienNaveau commented 3 years ago

After removing the import we can run the demos nicely.