rclpy
rclpy copied to clipboard
rclpy should provide a method to check if initialized
Feature request
Feature description
rclpy
should provide a method to indicate if rclpy.init()
has been called since the program started or since the last time rclpy.shutdown()
was called.
Implementation considerations
This could also be served by provided a specific exception to raise when called too many times, currently it raises a generic RuntimeError
, but I think a func to tell without raising an exception would also be good to have.
Should work after calling rclpy.shutdown()
after originally calling rclpy.init()
the first time.
I can help on this. Do you want to assign this to me?
Thanks @hemantku
I'm not able to assign you to the ticket, but go ahead and start on it anyways. I would be happy to answer questions you may have if you encounter issues.
#224
@sloretz : Is there an reference architecture doc for rclpy just like launch: https://github.com/ros2/launch/blob/master/launch/doc/source/architecture.rst ? For example, How is the state stored in each node, using the lifecycle node? or is it something else
Is there an reference architecture doc for rclpy just like launch
Not that I know of. There are slides about the architecture leading up to rclpy py starting at slide 30 here: https://roscon.ros.org/2016/presentations/ROSCon%202016%20-%20ROS%202%20Update.pdf
For example, How is the state stored in each node, using the lifecycle node
What kind of state? There is a pycapsule holding a pointer to an rcl_node_t
on node._handle
.
I would like to help on this @sloretz
@wjwwood Hello, I'm new to open source and love working with ros. How can I approach this issue?
Sorry @pr-db, this got lost. If you, or anyone else, wants to work on this...
We need a function to check if rclpy is already initialized or not, or perhaps just a more specific exception being raise. You can see from here:
https://github.com/ros2/launch/pull/75#discussion_r195281980
That we're catching a generic exception and comparing the error string to see if it is the already initialized error, which is very fragile.
I think this feature already exists as rclpy.ok()
https://github.com/ros2/rclpy/blob/77949d2c54b8104e48a94d0ea83c7049e18a8809/rclpy/rclpy/init.py#L55
Implementation
https://github.com/ros2/rclpy/blob/77949d2c54b8104e48a94d0ea83c7049e18a8809/rclpy/rclpy/utilities.py#L49-L52
Yeah, I think @sloretz is right - worth closing this issue now?
@EricCousineau-TRI it would be appreciated if you could review https://github.com/ros2/rclpy/pull/1198
Closing this issue as complete