0
$\begingroup$

Rosanswers logo

Hello,

I have a python program that has a GUI.

I want when a user clicks on a button to execute a ROS package. Also, I have another button, when the user clicks, I want to close the running package.

I do not know how to do that.

I know how to open the program:


    # calibration command
        calib_command_str = "rosrun camera_calibration cameracalibrator.py --size {}x{} {} {} --square {} right:={} left:={} left_camera:={} right_camera:={}".format(interior_corner_hor_axis, interior_corner_ver_axis, camera_service_check_value, approx_str, square_len, right_camera_image_topic, left_camera_image_topic, left_camera_image_super_topic, right_camera_image_super_topic)
    
        os.system(calib_command_str)

However, I do not how to close it.


Originally posted by farhad-bat on ROS Answers with karma: 13 on 2022-07-24

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

In ROS, killing a node is as follows

rosnode kill node_name

What the rosnode kill does is send a SIGINT to the NodeHandle, and what the node should do is deconstruct its classes and free the NodeHandle (in correctly written code).

You can use os.system with it too.

For Custom SIGINT Handler (in C++) you can use this tutorial:


Originally posted by ljaniec with karma: 3064 on 2022-07-25

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ljaniec on 2022-07-25:
If this answers your question, you can mark it as correct, so it will be visible in the question queue :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.