Skip to content

Commit e4515f1

Browse files
committed
Updated error messages for dependencies
1 parent 35f283b commit e4515f1

7 files changed

Lines changed: 35 additions & 16 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ParameterError: The configuration cost_scaling_factor: double is missing from the component instance
22
ParameterError: The configuration inflation_radius: double is missing from the component instance
33
ParameterError: The configuration robot_radius: double is missing from the component instance
4-
ParameterDependencyError: node instance configurations for move_base do not respect the dependency defined in the node type: exists(inflation_radius) == exists(cost_scaling_factor) and robot_radius <= inflation_radius
4+
ParameterDependencyError: node instance configurations for move_base do not respect the dependency defined in the node type: robot_radius <= inflation_radius
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ParameterDependencyError: node instance configurations for planning_scene_warehouse_viewer do not respect the dependency defined in the node type: is_simulation -> use_monitor and is_simulation -> !(use_robot_data)
1+
ParameterDependencyError: node instance configurations for planning_scene_warehouse_viewer do not respect the dependency defined in the node type: is_simulation -> use_monitor
22
ConnectionError: Publisher not found for subscriber /joint_states in planning_scene_warehouse_viewer
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ParameterDependencyError: node instance configurations for amcl do not respect the dependency defined in the node type: odom_model_type == OmniCorrected -> exists(odom_alpha5) and odom_model_type == DiffCorrected -> odom_alpha1 <= 0.01 and odom_alpha2 <= 0.01 and odom_alpha3 <= 0.01 and odom_alpha4 <= 0.01
1+
ParameterDependencyError: node instance configurations for amcl do not respect the dependency defined in the node type: odom_model_type == DiffCorrected -> odom_alpha1 <= 0.01 and odom_alpha2 <= 0.01 and odom_alpha3 <= 0.01 and odom_alpha4 <= 0.01
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ParameterDependencyError: node instance configurations for navsat_transform_node do not respect the dependency defined in the node type: version >= V221 -> yaw_orientation == East -> yaw_offset == 0 and version >= V221 -> yaw_orientation != East -> yaw_offset != 0 and version <= V221 -> yaw_orientation == North -> yaw_offset == 0 and version <= V221 -> yaw_orientation != North -> yaw_offset != 0
1+
ParameterDependencyError: node instance configurations for navsat_transform_node do not respect the dependency defined in the node type: version >= V221 -> yaw_orientation == East -> yaw_offset == 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ParameterDependencyError: node instance configurations for amcl do not respect the dependency defined in the node type: exists(initial_pose) -> set_initial_pose and exists(initial_pose) and set_initial_pose -> always_reset_initial_pose
1+
ParameterDependencyError: node instance configurations for amcl do not respect the dependency defined in the node type: exists(initial_pose) -> set_initial_pose
22
ConnectionError: Publisher not found for subscriber initialpose in amcl

src/rospec/verification/definition_formation.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
)
4545
from rospec.verification.subtyping import is_subtype
4646
from rospec.verification.type_formation import ty_formation
47-
from rospec.verification.utils import convert_to_expression, check_policies
47+
from rospec.verification.utils import check_dependency, convert_to_expression, check_policies
4848
from rospec import errors
4949

5050

@@ -272,14 +272,10 @@ def d_node_instance(context: Context, node_instance: NodeInstance) -> Context:
272272
# ##################################################################################################################
273273
# PROPERTY: ALL DEPENDENCIES MUST BE SATISFIED
274274
if dependency is not None:
275-
if not interpret(internal_context, dependency):
276-
context = context.add_error(
277-
errors.DEPENDENCY_NOT_SATISFIED.format(
278-
component_instance_type="node",
279-
name=node_instance.name.name,
280-
dependency=dependency,
281-
)
282-
)
275+
result_errors = check_dependency(internal_context, node_instance, dependency)
276+
for error in result_errors:
277+
context = context.add_error(error)
278+
283279
# ##################################################################################################################
284280

285281
result_connections: list[Union[Publisher, Subscriber, Service, Action, TFTransform]] = copy.deepcopy(

src/rospec/verification/utils.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
FunctionCall,
66
Identifier,
77
Literal,
8+
NodeInstance,
89
Publisher,
910
Subscriber,
1011
Action,
@@ -24,7 +25,6 @@
2425
t_string,
2526
TType,
2627
StructType,
27-
ArrayType,
2828
OptionalType,
2929
BasicType,
3030
EnumType,
@@ -124,7 +124,6 @@ def convert_to_expression(context: Context, value: Any, ttype: TType) -> Express
124124
ttype=ttype,
125125
)
126126
elif isinstance(value, list):
127-
assert isinstance(ttype, ArrayType)
128127
return Array(elements=[convert_to_expression(context, item, ttype.ttype) for item in value], ttype=ttype)
129128
raise ValueError(errors.UNSUPPORTED_TYPE.format(type=type(value)))
130129

@@ -264,3 +263,27 @@ def aux_replace_enums(enum_type: EnumType, expr: Expression) -> Expression:
264263
return Array(elements=[aux_replace_enums(enum_type, e) for e in expr.elements], ttype=expr.ttype)
265264
else:
266265
raise ValueError(f"Unsupported expression type: {type(expr)}")
266+
267+
268+
def check_dependency(context: Context, node_instance: NodeInstance, dependency: Expression):
269+
expressions = []
270+
current_expression = dependency
271+
272+
# Split the dependency into a list of expressions, so that we can check each one of them
273+
while isinstance(current_expression, FunctionCall) and current_expression.operator.name == "and":
274+
expressions.append(current_expression.operands[0])
275+
current_expression = current_expression.operands[1]
276+
expressions.append(current_expression)
277+
278+
result_errors = []
279+
for expression in expressions:
280+
if not interpret(context, expression):
281+
result_errors.append(
282+
errors.DEPENDENCY_NOT_SATISFIED.format(
283+
component_instance_type="node",
284+
name=node_instance.name.name,
285+
dependency=expression,
286+
)
287+
)
288+
289+
return result_errors

0 commit comments

Comments
 (0)