rclpy icon indicating copy to clipboard operation
rclpy copied to clipboard

rclpy should provide a method to check if initialized

Open wjwwood opened this issue 6 years ago • 9 comments

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.

wjwwood avatar Jun 08 '18 00:06 wjwwood

I can help on this. Do you want to assign this to me?

hemantku avatar Aug 14 '18 18:08 hemantku

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.

sloretz avatar Aug 14 '18 18:08 sloretz

#224

hemantku avatar Aug 15 '18 22:08 hemantku

@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

hemantku avatar Aug 24 '18 23:08 hemantku

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.

sloretz avatar Aug 27 '18 15:08 sloretz

I would like to help on this @sloretz

suab321321 avatar Aug 17 '19 13:08 suab321321

@wjwwood Hello, I'm new to open source and love working with ros. How can I approach this issue?

pr-db avatar Aug 12 '21 16:08 pr-db

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.

wjwwood avatar Oct 28 '21 05:10 wjwwood

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

sloretz avatar Nov 23 '21 23:11 sloretz

Yeah, I think @sloretz is right - worth closing this issue now?

EricCousineau-TRI avatar Nov 10 '23 02:11 EricCousineau-TRI

@EricCousineau-TRI it would be appreciated if you could review https://github.com/ros2/rclpy/pull/1198

fujitatomoya avatar Nov 13 '23 03:11 fujitatomoya

Closing this issue as complete

sloretz avatar Dec 15 '23 19:12 sloretz