Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawner check for currently running controllers on shutdown #364

Open
wants to merge 6 commits into
base: kinetic-devel
Choose a base branch
from

Conversation

megantuttle
Copy link

This PR improves controller shutdown by getting the list of currently running controllers before attempting to stop and unload them. Previously, shutdown simply stopped and unloaded the controllers that were spawned on launch. This behavior caused errors if a different controller was running at the time shutdown was requested.

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the general idea with the PR but it is a little off. The spawner should only be responsible for stopping/unloading the controllers it loaded/started.

You should take the intersection of currently running vs loaded/started controller and only act on those.

Copy link
Contributor

@mathias-luedtke mathias-luedtke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spawner should not deal with any controller that it was not configured for.

Previously, shutdown simply stopped and unloaded the controllers that were spawned on launch. This behavior caused errors if a different controller was running at the time shutdown was requested.

If this really causes errors, there is a bug that needs to be fixed.
The current PR would start controllers that have been stopped (or even unloaded) in between.

@megantuttle
Copy link
Author

megantuttle commented Oct 18, 2018

Error output from the original issue I was trying to resolve:
[ros_control_controller_spawner-2] killing on exit
[INFO] [1539901011.740469]: Shutting down spawner. Stopping and unloading controllers...
[INFO] [1539901011.741018]: Stopping all controllers...
[ERROR] [1539901011.743983745]: Could not stop controller 'pos_based_pos_traj_controller' since it is not running
[INFO] [1539901011.744493]: Unloading all loaded controllers...
[INFO] [1539901011.744950]: Trying to unload pos_based_pos_traj_controller
[INFO] [1539901011.782248]: Succeeded in unloading pos_based_pos_traj_controller
[INFO] [1539901011.782680]: Trying to unload force_torque_sensor_controller
[ERROR] [1539901011.785208211]: Could not unload controller with name force_torque_sensor_controller because it is still running
[INFO] [1539901011.785470]: Succeeded in unloading force_torque_sensor_controller
[INFO] [1539901011.785781]: Trying to unload joint_state_controller
[ERROR] [1539901011.788846453]: Could not unload controller with name joint_state_controller because it is still running
[INFO] [1539901011.789072]: Succeeded in unloading joint_state_controller

I am running Kinetic on Ubuntu 16.04, and using the ur_modern_driver package to control a UR3. I switch from the pos_based_pos_traj_controller (started by default) to the vel_based_pos_traj_controller using the switch_controllers service shortly after starting up the system by calling ur3_ros_control.launch and ur3_moveit_planning_execution.launch.

Why is spawner only intended to shut down the controllers it started? Why shouldn't it stop any controllers that are running when shutdown is requested?

controller_manager/scripts/spawner Outdated Show resolved Hide resolved
@@ -191,9 +200,6 @@ def main():

rospy.loginfo("Controller Spawner: Loaded controllers: %s" % ', '.join(loaded))

if rospy.is_shutdown():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whiy did you remove this block?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed redundant since a shutdown hook is defined, and rospy.spin() simply keeps python from exiting until rospy.core.is_shutdown() is set (see rospy/client.py).

@mathias-luedtke
Copy link
Contributor

Why is spawner only intended to shut down the controllers it started? Why shouldn't it stop any controllers that are running when shutdown is requested?

The intended use case for spawner is to provide node that manages a (sub)set of controllers.
So the life cycle of the controllers is bound to the lifecycle of the node.
For example, a user could prepare different launch file for different control set-ups.
spawner "owns" the controllers, so these should better not stopped manually.

Instead of adding the list call, it might be easier to just use BEST_EFFORT for the stopping call.

@bmagyar
Copy link
Member

bmagyar commented Oct 19, 2018 via email

@bmagyar
Copy link
Member

bmagyar commented Feb 6, 2019

@megantuttle will you have time to revamps this or would you prefer to close this PR?
IMHO this PR still has the potential to make shutdown more robust to changes (if the spawned controller was stopped elsewhere).

@megantuttle
Copy link
Author

@megantuttle will you have time to revamps this or would you prefer to close this PR?
IMHO this PR still has the potential to make shutdown more robust to changes (if the spawned controller was stopped elsewhere).

@bmagyar I believe I've addressed all of the comments here, am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants