MROS-RobMoSys-ITP / Pilot-URJC

7 stars 4 forks source link

Add lifecycle manager #36

Closed jginesclavero closed 4 years ago

jginesclavero commented 4 years ago

This PR adds a lifecycle manager component to manage laser_resender and pointcloud_to_laser nodes:

fmrico commented 4 years ago

LGTM

chcorbato commented 4 years ago

This PR adds a lifecycle manager component to manage laser_resender and pointcloud_to_laser nodes:

  • This component sets the nodes in a configured state at the startup.
  • This component sets laser_resender in the activated state at the startup.
  • I have included this component in the launcher.

I am confused, the role of the Mode Manager is to manage the system modes, which is an extension of the nodes lifecycles, so to my understanding it is also managing the lifecycle and there is no need for another component to do that. Please correct me @norro

jginesclavero commented 4 years ago

@chcorbato When I tested the system_modes I received an error because a node must be in the configure state before to active/inactive it. Because of this I have included a lifecycle manager to configure the necessary nodes of the system. It is possible to set a node in the configure state from the system_modes? @norro

norro commented 4 years ago

@jginesclavero @chcorbato The mode manager can indeed set nodes into its configured state, as can be seen in the system modes examples. After launch (which starts the node processes), they can be configured and then set to active/inactive. So if this is the intention of the lifecycle_manager, this might be redundant.

However, what @jginesclavero said in his first answer is also true: trying to activate a node right after start/launch of the process will lead to an error due to the ROS 2 node lifecycle, which requires to transition to `configured' first before transitioning to (in)active. This can be done with the mode manager and it must be done first as defined by the ROS 2 default lifecycle (otherwise you receive the error).

For the latter case, I created an issue already to provide lifecycle servicing, i.e. bring a node to a target state/mode regardless of its current state/mode. If this is the intention and function of the lifecycle_manager, I would be interested to integrate it into the mode manager.

jginesclavero commented 4 years ago

OK! thank you so much @norro for clarify this, I will make the necessary changes to configure the nodes from the system_modes. @chcorbato thank you for your revisions in my PRs.

jginesclavero commented 4 years ago

Excuse me @norro, what is the label to set a node in a configure state? I don't see in the examples... I have tested with configure and configured but the I have received this output :

[mode_manager-2] [INFO] [1600326803.964987043] [__mode_manager]: changing mode of controller_server to __DEFAULT__

[mode_manager-2] [INFO] [1600326803.965019473] [__mode_manager]: changing state of pointcloud_to_laser: deactivate

norro commented 4 years ago

@jginesclavero Sorry, I used the wrong term. There is indeed no configured state. the inactive state is what is entered when configuring a node. Sorry for causing confusion.

As shown in the example linked above, section "Change System States and System Modes", the mode manager should give you all services to manipulate the complete lifecycle of nodes and systems, though. If anything is missing for you, please elaborate on this.

What I usually do (also visible in the example):

  1. launch the system from a launch file or terminal - all nodes start in the unconfigured state
  2. configure systems or nodes - this will make the nodes tranisition into inactive
  3. activate system or nodes - this will make the nodes transition into active, optionally into a certain mode

If you would like to directly being able to activate the node, without having to call configure first, then that is exactly what I mean with the issue linked above.

If you would like to have nodes automatically enter their inactive state right from the startm without need to call a service or the mode manager first, then launch is probably what you're looking for. There are launch action that manipulate the lifecycle, so that fireing up the launch file should bring all the nodes into the state you want them to be, see this discussion for example.

If you mean something else, please elaborate on what is not yet working for you.

jginesclavero commented 4 years ago

If you would like to have nodes automatically enter their inactive state right from the startm without need to call a service or the mode manager first, then launch is probably what you're looking for. There are launch action that manipulate the lifecycle, so that fireing up the launch file should bring all the nodes into the state you want them to be, see this discussion for example.

@norro Yes, this is that exactly I want to do. Thank you so much for the reference! I will test it.

fmrico commented 4 years ago

@jginesclavero , Is this PR necessary after merging #39?

jginesclavero commented 4 years ago

This PR was closed and merged 4 days ago.