Skip to content

Commit ee6bd35

Browse files
author
Roger Strain
committed
Split of functionality into traits
Distro A; OPSEC #2893 Signed-off-by: Roger Strain <[email protected]>
1 parent 7b5f244 commit ee6bd35

File tree

1 file changed

+88
-45
lines changed

1 file changed

+88
-45
lines changed

articles/execute_process_refactor.md

Lines changed: 88 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ It would not inherit from any other class, and would have a subset of the fields
347347

348348
#### Constructor
349349

350-
These parameters are drawn from the shared parameters of the current `launch_ros.actions.Node` and `launch_ros.descriptions.ComposableNode`.
350+
These parameters are drawn from the shared parameters of the current `launch_ros.actions.Node` and `launch_ros.descriptions.ComposableNode`, and introduces a new collection of `traits`, described in following classes.
351351

352352
| Argument | Description |
353353
| -------------- | ------------------------------------------------------------ |
@@ -357,10 +357,11 @@ These parameters are drawn from the shared parameters of the current `launch_ros
357357
| parameters | List of either paths to yaml files or dictionaries of parameters |
358358
| remappings | List of from/to pairs for remapping names |
359359
| arguments | Container specific arguments to be passed to the node |
360+
| traits | Additional features of the node, specifically Lifecycle or Composable information|
360361

361362
#### Properties
362363

363-
Accessors would be provided for the various constructor parameters: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, and `arguments`.
364+
Accessors would be provided for the various constructor parameters: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, `arguments`, and `traits`.
364365

365366
#### Methods
366367

@@ -369,26 +370,75 @@ To support better isolation of class functionality, substitutions will be perfor
369370

370371
| Name | Description |
371372
| ------- | ------------------------------------------------------------ |
372-
| prepare | Takes a given LaunchContext and Action, and performs actions necessary to prepare the node for execution in that context. This will primarily consist of expanding various substitutions, but may additionally add event handlers related to the Action which will be invoked. |
373+
| prepare | Takes a given LaunchContext and Action, and performs actions necessary to prepare the node for execution in that context. This will primarily consist of expanding various substitutions, but may additionally add event handlers related to the Action which will be invoked. Additionally, this will call the `prepare()` method of any defined traits. |
373374

374375
This function would match that of the current `launch_ros.actions.Node` internal method `_perform_substitutions`.
375376

376377
#### Events
377378

378379
No events would be handled or emitted.
379380

380-
### launch_ros.descriptions.LifecycleNode
381+
### launch_ros.descriptions.ComposableNode
381382

382-
This class would extend the `launch_ros.descriptions.Node` class, and provide the additional functionality required for managing lifecycle node events that are currently defined in `launch_ros.actions.LifecycleNode`.
383+
This class would extend the `launch_ros.descriptions.Node` class, and provide the additional information required for defining a node which can be launched in a composable context.
383384

384385
#### Constructor
385386

386-
No additional constructor parameters are defined in this class.
387-
All parameters which are handled by `launch_ros.descriptions.Node` may be passed to the constructor: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, and `arguments`.
387+
Most parameters would be passed to the superclass.
388+
389+
|Argument|Description|
390+
|---|---|
391+
|node_plugin|Name of the plugin to be loaded|
392+
393+
Additional parameters that may be passed, which are handled by `launch_ros.descriptions.NodeBase`: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, `arguments`, `traits`.
388394

389395
#### Properties
390396

391-
Constructor properties available from ``launch_ros.descriptions.Node`` are inherited: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, and `arguments`.
397+
Accessors would be provided for the additional constructor parameter: `node_plugin`.
398+
Inherited accessors would also be available: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, `arguments`, and `traits`.
399+
400+
#### Methods
401+
402+
No methods would be defined or overridden.
403+
404+
#### Events
405+
406+
No events would be handled or emitted.
407+
408+
### launch_ros.traits.NodeTrait
409+
This abstract class would not extend any others, and would provide a common interface to allow definition of traits which apply to `launch_ros.descriptions.Node` objects.
410+
411+
#### Constructor
412+
413+
This constructor would take no parameters, and should not be used directly.
414+
415+
#### Properties
416+
417+
This object would expose no properties.
418+
419+
#### Methods
420+
421+
To allow a trait to perform its actions, the `prepare()` method will be called prior to execution.
422+
423+
| Name | Description |
424+
| ------- | ------------------------------------------------------------ |
425+
| prepare | Abstract method which takes a given Node, LaunchContext, and Action, and performs actions necessary to prepare the node for execution in that context.|
426+
427+
#### Events
428+
429+
No events would be handled or emitted.
430+
431+
### launch_ros.traits.HasLifecycle
432+
433+
This class would extend the `launch_ros.traits.NodeTrait` class, and provide the additional functionality required for managing lifecycle node events that are currently defined in `launch_ros.actions.LifecycleNode`.
434+
435+
#### Constructor
436+
437+
The constructor for this trait would take no parameters, as it serves only to assert that the ROS2 Lifecycle events are implemented by the `launch_ros.descriptions.Node`, and appropriate events should be managed.
438+
439+
#### Properties
440+
441+
This object would expose no properties.
392442

393443
#### Methods
394444

@@ -410,57 +460,47 @@ Constructor properties available from ``launch_ros.descriptions.Node`` are inher
410460
| ----------------------------------------- | ------------------------------------------------------------ |
411461
| `launch.events.lifecycle.StateTransition` | This event is emitted when a message is published to the "`/<node_name>/transition_event`" topic, indicating the lifecycle node represented by this action changed state |
412462

413-
### launch_ros.descriptions.ExecutableNode
463+
### launch_ros.traits.ComposesNodes
414464

415-
This class would represent the information required to define a node which might be run as a single executable.
416-
It would inherit from `launch.descriptions.Executable`, contain a `launch_ros.descriptions.Node`, and populate its fields in the same manner as the current `launch_ros.actions.Node`.
465+
This class would extend the `launch_ros.traits.NodeTrait` class, and provide the additional information required for launching composable nodes that are currently defined in `launch_ros.descriptions.ComposableNode`.
417466

418467
#### Constructor
419468

420-
These parameters are drawn from the current `launch_ros.actions.Node`.
421-
422-
REQUEST FOR COMMENT: Currently, this calls out the node as a `launch_ros.descriptions.Node` object parameter; would this be better styled by accepting a flat list to make the inner Node less visible to users?
423-
424-
| Argument | Description |
425-
| --------------- | ------------------------------------------------------------ |
426-
| node_executable | The name of the executable to find if a package is provided or otherwise a path to the executable to run. |
427-
| node | The `launch_ros.descriptions.Node` (or subclass thereof) which is being run. |
469+
Most parameters would be passed to the new superclass.
428470

429-
Most parameters which are handled by `launch.descriptions.Executable` may be passed to the constructor: `name`, `cwd`, `env`, and `additional_env`.
430-
Note that the `cmd` parameter would *not* be passed through; the command would be constructed per ROS Node execution context.
471+
|Argument|Description|
472+
|---|---|
473+
|nodes|Collection of `launch_ros.descriptions.ComposableNode` objects that should be launched inside the `launch_ros.descriptions.Node` with this trait.|
431474

432475
#### Properties
433476

434-
Accessors would be provided for the various constructor parameters: `node_executable` and `node`.
435-
Inherited accessors would also be available: `cmd`, `name`, `cwd`, `env`, and `additional_env`.
477+
Accessors would be provided for the constructor parameter: `nodes`.
436478

437479
#### Methods
438480

439-
This class would override the `apply_context` method of `launch.descriptions.Executable` to additionally invoke the `apply_context` method of the `launch_ros.descriptions.Node`, then invoke the superclass method itself.
440-
This function would match that of the current `launch_ros.actions.Node` internal method `_perform_substitutions`.
481+
| Name | Description |
482+
| ------- | ------------------------------------------------------------ |
483+
| prepare | Overridden. Adds an event handler to launch the defined composable nodes in the container once the container is started. |
441484

442485
#### Events
443486

444487
No events would be handled or emitted.
445488

446-
### launch_ros.descriptions.ComposableNode
489+
### launch_ros.traits.IsExecutable
447490

448-
This class would be modified to inherit from `launch_ros.descriptions.Node`.
491+
This class would extend the `launch_ros.traits.NodeTrait` class, and provide the additional information required for launching executable nodes that are currently defined in `launch_ros.actions.Node`.
449492

450493
#### Constructor
451494

452495
Most parameters would be passed to the new superclass.
453496

454497
|Argument|Description|
455498
|---|---|
456-
|node_plugin|Name of the plugin to be loaded|
457-
458-
Additional parameters that may be passed, which are handled by `launch_ros.descriptions.Node`: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, `arguments`.
499+
|node_executable|Name of the executable to find|
459500

460501
#### Properties
461502

462-
Accessors would be provided for the additional constructor parameter: `node_plugin`.
463-
Inherited accessors would also be available: `package`, `node_name`, `node_namespace`, `parameters`, `remappings`, and `arguments`.
503+
Accessors would be provided for the constructor parameter: `node_exectuable`.
464504

465505
#### Methods
466506

@@ -470,33 +510,36 @@ No custom methods would be defined or overridden.
470510

471511
No events would be handled or emitted.
472512

473-
### launch_ros.descriptions.ExecutableNodeContainer
513+
### launch_ros.descriptions.RosExecutable
474514

475-
This class would extend the `launch_ros.descriptions.ExecutableNode` class, and provide the additional functionality required for loading multiple nodes into a single container.
515+
This class would represent the information required to run a ROS-aware process and inherit from `launch.descriptions.Executable`.
516+
It would not include execution-time details, nor provide monitoring of the process after launch.
476517

477518
#### Constructor
478519

479-
The description of the composable node container itself should be provided as the parameters passed to ``launch_ros.descriptions.ExecutableNode``; child nodes would be provided as an additional constructor parameter.
480-
481-
| Argument | Description |
482-
| ------------------------------ | ------------------------------------------------------ |
483-
| composable\_node\_descriptions | Optional descriptions of composable nodes to be loaded |
520+
| Argument | Description |
521+
| --------------- | ------------------------------------------------------------ |
522+
| nodes | A list of `launch_ros.descriptions.Node` objects which are part of the executable. |
484523

485-
All parameters which are handled by ``launch_ros.descriptions.ExecutableNode`` may be passed to the constructor: `node_executable`, `node`, `name`, `cwd`, `env`, and `additional_env`.
524+
Additional parameters that may be passed, which are handled by `launch.actions.ExecuteProcess`: `cmd`, `name`, `cwd`, `env`, `additional_env`.
525+
NOTE: To allow ROS to determine the appropriate executable based on the package and executable name, the `cmd` parameter should *NOT* be specified. When `cmd` is not specified, this class will determine the appropriate executable if and only if exactly one of the nodes it contains has the `launch_ros.traits.IsExecutable` trait.
486526

487527
#### Properties
488528

489-
Properties available from ``launch_ros.descriptions.ExecutableNode`` are inherited: `process_details`, along with constructor parameters for `process_description`, `shell`, and `output`.
529+
Accessors would be provided for the constructor parameter: `nodes`.
530+
Inherited accessors would also be available: `cmd`, `name`, `cwd`, `env`, and `additional_env`.
490531

491532
#### Methods
492533

493-
| Name | Description |
494-
| ------- | ------------------------------------------------------------ |
495-
| prepare | Overridden. Calls the superclass to prepare node-related information, calls `prepare` on each composable node, and adds actions to the target Action to load the contained nodes once the process is started, then calls the superclass to execute the parsed command. |
534+
| Name | Description |
535+
| ------------- | ------------------------------------------------------------ |
536+
| apply\_context | Overridden. Calls `prepare()` on each `launch_ros.descriptions.Node`, and determines the appropriate executable if necessary. |
537+
538+
In constructing the command line parameters for execution, if more than one node is defined, all appropriate parameters will be prefixed with the node name as necessary.
496539

497540
#### Events
498541

499-
Inherits events from `launch.actions.ExecuteLocalProcess`, but does not define any additional events.
542+
No events would be handled nor emitted.
500543

501544
## Future Extension
502545

0 commit comments

Comments
 (0)