Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion autoware_system_designer.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,21 @@ Top-level entry point defining the complete system.
- `description`: (Optional) Description of the mode.
- `default`: (Optional) `true`/`false` to mark as default mode.
- `parameter_sets`: List of parameter set files. Can be an empty list `[]`.
- `communication_domains`: (Optional) Communication domains of the system. Compute units of one domain exchange topics directly; units of different domains exchange only what a domain bridge of the system carries. The design connects ports across domains as usual.
- `name`: Domain identifier referenced by `compute_units[].communication_domain` (e.g., `main`). Lowercase letters, digits and underscores, starting with a letter.
- `description`: (Optional) Brief explanation of the domain.
- `id`: (Optional) Identifier the middleware knows the domain by, a non-negative integer, distinct per domain. The generated launcher of a unit and the runtime hand it to the nodes they start; on ROS 2 it is the `ROS_DOMAIN_ID` (0 to 232). A domain without it is the one of the environment its units are launched in.
- `compute_units`: (Optional) Compute units the system is deployed on. A unit is one independently launched environment (an ECU, a container or a partition) with no copy-free IPC to other units; the hardware or execution environment hosting it is outside the system design. Components on different units communicate over the network only, so a node group cannot span units. Once declared, every component's `compute_unit` must name one of them, and each onboard unit gets a launcher in every mode even when no component of that mode runs on it.
- `name`: Unit identifier referenced by `components[].compute_unit` (e.g., `main_ecu`). Lowercase letters, digits and underscores, starting with a letter (`^[a-z][a-z0-9_]*$`); the name is used as the launcher directory and file name and as the runtime `--compute-unit` value.
- `kind`: (Optional) Where the unit exists relative to the deployed vehicle. `onboard` (default) runs on the vehicle and gets a launcher; `offboard` is a participant outside the vehicle (infrastructure, cloud, remote operation) whose components are declared for wiring only. Offboard units get no launcher and no launch-command entry; their components remain in the structure export.
- `description`: (Optional) Brief explanation of the unit.
- `requires`: (Optional) Capabilities the unit needs from the execution environment it is launched in (e.g., `[gpu]`, or `gpu` for one). Names are free (`^[a-z][a-z0-9_]*$`); an E/E architecture may bind the unit only to an environment whose `provides` holds every one of them.
- `communication_domain`: (Optional) Name of the `communication_domains` entry the unit's nodes run in. A unit without it takes part in no declared domain (a unit of non-ROS software, for example) and its nodes, if any, run in the domain of the environment it is launched in; the build reports such a unit once it connects to a unit in a domain.
- `domain_bridges`: (Optional) Bridges between communication domains. A bridge carries every connection whose two ends run in its two domains, in either direction, under its own name: a topic from the publisher's domain to the subscriber's, a service from the server's domain to the client's. The designer derives the topics and services from the connections, generates the configuration of the bridge process and launches it as a member of the bridge's compute unit. A connection crossing two domains no bridge joins is reported at build time. Services need a bridge process that reads `services` from its configuration.
- `name`: Bridge identifier (`^[a-z][a-z0-9_]*$`); the name of the bridge process, unique among the system's components.
- `type`: Bridge process. `ros2_domain_bridge` (the `domain_bridge` package) is the one type, declared in `config/domain_bridge_types.yaml`.
- `compute_unit`: Onboard unit the bridge process runs on.
- `domains`: The two `communication_domains` entries the bridge joins; one bridge per pair. Both need an `id`.
- `peripherals`: (Optional) Hardware outside the compute units that components talk to (sensors, actuators, vehicle controllers), by logical name. The system design names no device; an E/E architecture binds each name to one.
- `name`: Peripheral identifier (`^[a-z][a-z0-9_]*$`); the key an E/E architecture binds by.
- `node`: (Optional) Gateway node(s) of the peripheral: the nodes that talk to its hardware, one path or a list (e.g., `/sensing/lidar/lidar_top`, or the receiver and sender of a CAN channel). How the hardware's data maps to the nodes' topics is the device's and the driver's, not the system design's. The interfaces and addresses each gateway node's compute unit reaches the device by are derived from it.
Expand Down Expand Up @@ -256,7 +266,7 @@ Top-level entry point defining the complete system.
**Mode-Specific Overrides:**
Each mode can define overrides using the mode name as a key:

- `override`: Dictionary containing mode-specific overrides. All system configuration fields can be overridden (e.g., `variables`, `variable_files`, `modes`, `parameter_sets`, `compute_units`, `components`, `connections`). The variant resolver applies the appropriate merge strategy for each field type (key-based replacement for fields with identifiers, append for lists without keys, dictionary merge for dictionaries).
- `override`: Dictionary containing mode-specific overrides. All system configuration fields can be overridden (e.g., `variables`, `variable_files`, `modes`, `parameter_sets`, `communication_domains`, `compute_units`, `domain_bridges`, `components`, `connections`). The variant resolver applies the appropriate merge strategy for each field type (key-based replacement for fields with identifiers, append for lists without keys, dictionary merge for dictionaries).
- `remove`: Dictionary specifying what to remove in this mode. All system configuration fields can be removed (e.g., `modes`, `parameter_sets`, `compute_units`, `components`, `variables`, `connections`). The variant resolver applies the appropriate removal strategy (key-based removal for fields with identifiers, full match for lists without keys). When components are removed, connections involving them are automatically filtered out.

### 4.4. Parameter Set Configuration (`.parameter_set.yaml`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Declared compute units of a resolved system and the component binding rule."""
"""Declared compute units and communication domains of a resolved system and their binding rules."""

from __future__ import annotations

import re
from typing import List
from typing import Any, Dict, List

from autoware_system_designer.common.exceptions import ValidationError
from autoware_system_designer.common.source_location import format_source, source_from_config
from autoware_system_designer.model import serde
from autoware_system_designer.model.config import COMPUTE_UNIT_NAME_PATTERN, SystemConfig


Expand All @@ -29,6 +30,49 @@ def compute_unit_names(system_config: SystemConfig) -> List[str]:
return [unit.name for unit in system_config.compute_units or []]


def compute_unit_records(system_config: SystemConfig) -> List[Dict[str, Any]]:
"""Export records of the declared units; a unit in a domain with an identifier carries it as ``domain_id``."""
ids = {domain.name: domain.id for domain in system_config.communication_domains or []}
records = []
for unit in system_config.compute_units or []:
record = serde.dump(unit)
if ids.get(unit.communication_domain) is not None:
record["domain_id"] = ids[unit.communication_domain]
records.append(record)
return records


def check_communication_domains(system_config: SystemConfig) -> None:
"""Declared domains are unique in name and identifier, and each unit's domain is a declared one.

Runs on the resolved config, like the component binding check.
"""
domains = system_config.communication_domains or []
names = [domain.name for domain in domains]
duplicates = sorted({name for name in names if names.count(name) > 1})
if duplicates:
src = source_from_config(system_config, "/communication_domains")
raise ValidationError(f"Duplicate communication domain declaration(s): {duplicates}{format_source(src)}")
by_id: Dict[int, str] = {}
for idx, domain in enumerate(domains):
if domain.id is None:
continue
if domain.id in by_id:
src = source_from_config(system_config, f"/communication_domains/{idx}/id")
raise ValidationError(
f"Communication domains '{by_id[domain.id]}' and '{domain.name}' share the identifier "
f"{domain.id}{format_source(src)}"
)
by_id[domain.id] = domain.name
for idx, unit in enumerate(system_config.compute_units or []):
if unit.communication_domain is not None and unit.communication_domain not in names:
src = source_from_config(system_config, f"/compute_units/{idx}/communication_domain")
raise ValidationError(
f"Compute unit '{unit.name}' references undeclared communication domain "
f"'{unit.communication_domain}'; declared communication domains: {names}{format_source(src)}"
)


def check_component_compute_units(system_config: SystemConfig) -> None:
"""Once a system declares compute units, their names are valid and unique and each component binds to one.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_launcher_data(self, instance: "Instance") -> Dict[str, Any]:
"""Build full launcher dict for this node instance (for generation/serialization)."""

cfg = self.launch_config
resolved_args = instance.parameter_manager.resolve_substitutions(cfg.args)
resolved_args = cfg.args if cfg.launch_time_args else instance.parameter_manager.resolve_substitutions(cfg.args)

launcher_data: Dict[str, Any] = {
"package": cfg.package_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
import logging
from typing import Callable, Dict

from autoware_system_designer.builder.compute_units import check_component_compute_units
from autoware_system_designer.builder.compute_units import check_communication_domains, check_component_compute_units
from autoware_system_designer.builder.domain_bridges import (
apply_bridge_names,
apply_domain_bridges,
check_domain_bridges,
scope_instances_by_domain,
)
from autoware_system_designer.builder.instances.instance_tree import set_instances
from autoware_system_designer.builder.instances.instances import Instance
from autoware_system_designer.builder.parameters.parameter_resolver import ParameterResolver
Expand Down Expand Up @@ -45,8 +51,12 @@ def set_system(
config_registry,
package_paths: Dict[str, str],
snapshot_callback: Callable[[str, Exception | None], None] | None = None,
domain_bridge_config_dir: str = "",
) -> None:
"""Set system for this deployment instance."""
"""Set system for this deployment instance.

*domain_bridge_config_dir* is where a launched domain bridge finds its generated configuration.
"""

def _snapshot(step: str, error: Exception | None = None) -> None:
if snapshot_callback:
Expand Down Expand Up @@ -83,8 +93,12 @@ def _snapshot(step: str, error: Exception | None = None) -> None:

# 1. set component instances
check_component_compute_units(system_config)
check_communication_domains(system_config)
check_domain_bridges(system_config)
logger.info(f"Instance '{self.name}': setting component instances")
set_instances(self, system_config.full_name, config_registry)
apply_domain_bridges(self, domain_bridge_config_dir)
scope_instances_by_domain(self)
self.check_duplicate_node_path()
_snapshot("1_parse")

Expand All @@ -95,6 +109,7 @@ def _snapshot(step: str, error: Exception | None = None) -> None:
current_step = "connections"
logger.info(f"Instance '{self.name}': setting connections")
self.link_manager.set_links()
apply_bridge_names(self)
self.check_duplicate_port_path()
self.check_ports()
_snapshot("2_connections")
Expand All @@ -113,18 +128,18 @@ def _snapshot(step: str, error: Exception | None = None) -> None:
raise

def check_duplicate_node_path(self) -> None:
"""Check for duplicate normalized (namespace + name) node paths.
"""Check for duplicate normalized (namespace + name) node paths within a communication domain.

Components/modules may share namespaces. Node instances must have unique
Components/modules may share namespaces. Node instances of one domain must have unique
normalized paths generated from namespace + node name.
"""
node_path_map: Dict[str, Instance] = {}
node_path_map: Dict[tuple, Instance] = {}
for inst in self.iter_tree():
if inst.entity_type != "node":
continue
node_path = Namespace(list(Namespace.from_path(inst.namespace)) + ([inst.name] if inst.name else []))
normalized_path = node_path.to_string()
other = node_path_map.setdefault(normalized_path, inst)
other = node_path_map.setdefault((inst.resolved_path.domain, normalized_path), inst)
if other is not inst:
raise ValidationError(
f"Duplicate node path found: '{normalized_path}'. "
Expand All @@ -133,15 +148,15 @@ def check_duplicate_node_path(self) -> None:
)

def check_duplicate_port_path(self) -> None:
"""Every port of the tree has its own path; ids and default topics derive from it.
"""Every port of a communication domain has its own path; ids and default topics derive from it.

Two instances placed on one path collide here when they define a port of the same name.
"""
owners: Dict[tuple, Instance] = {}
for inst in self.iter_tree():
manager = inst.link_manager
for port in (*manager.in_ports.values(), *manager.out_ports.values()):
key = (isinstance(port, InPort), tuple(port.namespace), port.name)
key = (inst.resolved_path.domain, isinstance(port, InPort), tuple(port.namespace), port.name)
other = owners.setdefault(key, inst)
if other is not inst:
raise ValidationError(
Expand Down
Loading
Loading