Rclpy.get_default_context().on_shutdown(example36.on_shutdown) error

when I shutdown the program for example 36 I got error from context and couldn’t see the custom interface messages at the end.

[example36-1] [INFO] [1672084944.555655846] [example36]: I receive: “0.2692549526691437”
[example36-1] [INFO] [1672084945.055789044] [example36]: I receive: “0.2517356276512146”
[example36-1] [INFO] [1672084945.555737332] [example36]: I receive: “0.25415506958961487”
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[example36-1] Traceback (most recent call last):
[example36-1] File “/home/user/ros2_ws/install/example36_pkg/lib/example36_pkg/example36”, line 33, in
[example36-1] sys.exit(load_entry_point(‘example36-pkg==0.0.0’, ‘console_scripts’, ‘example36’)())
[example36-1] File “/home/user/ros2_ws/install/example36_pkg/lib/python3.10/site-packages/example36_pkg/example36.py”, line 75, in main
[example36-1] rclpy.shutdown()
[example36-1] File “/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/init.py”, line 126, in shutdown
[example36-1] _shutdown(context=context)
[example36-1] File “/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/utilities.py”, line 58, in shutdown
[example36-1] return context.shutdown()
[example36-1] File “/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/context.py”, line 102, in shutdown
[example36-1] self.__context.shutdown()
[example36-1] rclpy._rclpy_pybind11.RCLError: failed to shutdown: rcl_shutdown already called on the given context, at ./src/rcl/init.c:241

Hey @mistymoon3

Please provide more details so we can understand what you were doing and why the error happened.

Hello @mistymoon3 ,

I’ve seen that this example is no longer working in the Humble course. Probably something changed in the context usage.
Anyways, I’ve modified the example for the custom interfaces in the Humble course. Now it publishes the custom interface directly into a topic. Let me know if you can reproduce it properly now.

Best,

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.