def evaluate_rules(poses_sequence, interval: SampledSequence[Timestamp], world: PlacedObject, ego_name: str) -> Dict[str, RuleEvaluationResult]: from duckietown_world.world_duckietown import create_lane_highlight lane_pose_seq = create_lane_highlight(poses_sequence, world) from duckietown_world.rules import DeviationFromCenterLine from duckietown_world.rules import InDrivableLane from duckietown_world.rules import DeviationHeading from duckietown_world.rules import DrivenLength from duckietown_world.rules import DrivenLengthConsecutive from duckietown_world.rules import SurvivalTime rules = {} rules["deviation-heading"] = DeviationHeading() rules["in-drivable-lane"] = InDrivableLane() rules["deviation-center-line"] = DeviationFromCenterLine() rules["driving-distance"] = DrivenLength() rules["driving-distance-consecutive"] = DrivenLengthConsecutive() rules["survival_time"] = SurvivalTime() context = RuleEvaluationContext( interval=interval, world=world, ego_name=ego_name, lane_pose_seq=lane_pose_seq, pose_seq=poses_sequence, ) evaluated = {} for name, rule in rules.items(): result = RuleEvaluationResult(rule) rule.evaluate(context, result) evaluated[name] = result return evaluated
def evaluate_rules(poses_sequence, interval, world, ego_name): from duckietown_world.world_duckietown import create_lane_highlight lane_pose_seq = create_lane_highlight(poses_sequence, world) from duckietown_world.rules import DeviationFromCenterLine from duckietown_world.rules import InDrivableLane from duckietown_world.rules import DeviationHeading from duckietown_world.rules import DrivenLength from duckietown_world.rules import DrivenLengthConsecutive rules = OrderedDict() rules['deviation-heading'] = DeviationHeading() rules['in-drivable-lane'] = InDrivableLane() rules['deviation-center-line'] = DeviationFromCenterLine() rules['driving-distance'] = DrivenLength() rules['driving-distance-consecutive'] = DrivenLengthConsecutive() context = RuleEvaluationContext(interval, world, ego_name=ego_name, lane_pose_seq=lane_pose_seq, pose_seq=poses_sequence) evaluated = OrderedDict() for name, rule in rules.items(): result = RuleEvaluationResult(rule) rule.evaluate(context, result) evaluated[name] = result return evaluated