agents.rules.obstacles package
Submodules
agents.rules.obstacles.traffic_light_rules module
- class agents.rules.obstacles.traffic_light_rules.DriveSlowTowardsTrafficLight(phases: Phase | Iterable[Phase] | 'type[Any]' | Self | str | None | None = None, bases: tuple[type[Any], ...] | None = None, clsdict: dict[str, Any] | None = None, **kwargs: Any)[source]
Bases:
BlockingRuleWhen the agent is at a red traffic light and it is red drive forward slowly.
- Parameters:
condition (Optional[ConditionFunctionLikeT])
action (Optional[Union[CallableAction[Self, []], Dict[Any, CallableAction[Self, []]]]])
false_action (Optional[CallableAction[Self, []]])
gameframework (Optional[GameFramework])
description (str)
priority (RulePriority)
cooldown_reset_value (Optional[int])
group (Optional[str])
enabled (bool)
- priority: float | int | RulePriority = 2
Rules are executed in order of their priority, from high to low.
- MAX_TICKS = 2000
The amount of ticks that can be performed by this rule before it is automatically disabled. If the rule has looped for this amount of ticks if will then call
max_tick_callbackand raise anUnblockRuleExceptionafterwards.As a hack
max_tick_callbackcan changeticks_passedto prevent the exception and continue the rule.
- DEFAULT_COOLDOWN_RESET: ClassVar[int] = 500
Value the cooldown is reset to when
reset_cooldown()is called without a value.Used only when
cooldown_reset_valueis not set.
- overwrite_settings: dict[str, Any] = {'speed': {'follow_speed_limits': False}}
Settings that should overwrite the agent’s settings for this rule.
Note
The overwrite settings are primitive
dictobjects,omegaconf.DictConfigobjects are converted.
- class self_config(instance: 'object' = MISSING, max_brake: float = '${divide:${controls.max_brake},8}', max_throttle: float = '${divide:${controls.max_throttle},4}')[source]
Bases:
RuleConfig- max_brake: float = '${divide:${controls.max_brake},8}'
Max break that should be applied when above the target speed.
- __init__(phases: Phase | Iterable[Phase], condition: ConditionFunctionLikeT | None = None, action: CallableActionT | Dict[Any, CallableActionT] | None = None, false_action: CallableActionT | None = None, *, gameframework: GameFramework | None, actions: Dict[Any, CallableActionT] | None = None, description: str = 'What does this rule do?', overwrite_settings: Dict[str, Any] | None = None, self_config: Dict[str, Any] | None = None, priority: RulePriority = RulePriority.NORMAL, cooldown_reset_value: int | None = None, group: str | None = None, enabled: bool = True)
Initializes a Rule object.
- Parameters:
phases (Union[Phase, Iterable[Phase]]) – The phase(s) when the rule should be evaluated. An iterable of Phase objects or a single Phase object.
condition (Optional[ConditionFunctionLikeT]) – A function that takes a Context object as input and returns a Hashable value. If not provided, the class must implement a condition function.
action (Optional[Union[CallableActionT, Dict[Any, CallableActionT]]]) – A function or a dictionary of functions that take a Context object as input. If action behaves like actions. Only one of action and actions can be set.
false_action (Optional[CallableActionT]) – A function that takes a Context object as input and returns any value. It is used when action is a single function and represents the action to be taken when the condition is False.
actions (Optional[Dict[Any, CallableActionT]]) – A dictionary of action functions It should map the return values of condition to the corresponding action function. If action is None, actions must be provided.
description (str) – A string that describes what this rule does.
overwrite_settings (Optional[Dict[str, Any]]) – A dictionary of settings that will overwrite the agent’s setting for this Rule.
priority (RulePriority) – The priority of the rule. It can be a float, an integer, or a RulePriority enum value.
cooldown_reset_value (Optional[int]) – An optional integer value that represents the cooldown reset value for the rule. If not provided falls back to the class attribute
Rule.DEFAULT_COOLDOWN_RESET.group (Optional[str]) – An optional string that specifies the group to which this rule belongs.
enabled (bool) – A boolean value indicating whether the rule is enabled or not.
gameframework (Optional[GameFramework])
- Raises:
ValueError – If
phasesis empty or None, or ifphasescontains an object that is not of type Phase.TypeError – If
conditionis None and the class does not implement acondition()function, or if bothactionandactionsare None and the class does not have anactionsattribute or anaction()function.TypeError – if
actionsis not a Mapping object.ValueError – If both
actionandactionsare provided.ValueError – If
actionis a Mapping and eitherfalse_actionoractionsis not None.ValueError – If an
actionfunction is not callable.ValueError – If
descriptionis not a string.
- class agents.rules.obstacles.traffic_light_rules.PassYellowTrafficLightRule(phases: Phase | Iterable[Phase] | 'type[Any]' | Self | str | None | None = None, bases: tuple[type[Any], ...] | None = None, clsdict: dict[str, Any] | None = None, **kwargs: Any)[source]
Bases:
Rule- Parameters:
condition (Optional[ConditionFunctionLikeT])
action (Optional[Union[CallableActionT, Dict[Any, CallableActionT]]])
false_action (Optional[CallableActionT])
actions (Optional[Dict[Any, CallableActionT]])
description (str)
priority (RulePriority)
cooldown_reset_value (Optional[int])
group (Optional[str])
enabled (bool)
- priority: float | int | RulePriority = 8
Rules are executed in order of their priority, from high to low.
- class self_config(instance: 'object' = MISSING, try_to_pass: bool = False, passing_speed: float = '${max:${mul:${live_info.current_speed_limit},1.33},${speed.target_speed}}')[source]
Bases:
RuleConfig
- __init__(phases: Phase | Iterable[Phase], condition: ConditionFunctionLikeT | None = None, action: CallableActionT | Dict[Any, CallableActionT] | None = None, false_action: CallableActionT | None = None, *, actions: Dict[Any, CallableActionT] | None = None, description: str = 'What does this rule do?', overwrite_settings: Dict[str, Any] | None = None, self_config: Dict[str, Any] | None = None, priority: RulePriority = RulePriority.NORMAL, cooldown_reset_value: int | None = None, group: str | None = None, enabled: bool = True)
Initializes a Rule object.
- Parameters:
phases (Union[Phase, Iterable[Phase]]) – The phase(s) when the rule should be evaluated. An iterable of Phase objects or a single Phase object.
condition (Optional[ConditionFunctionLikeT]) – A function that takes a Context object as input and returns a Hashable value. If not provided, the class must implement a condition function.
action (Optional[Union[CallableActionT, Dict[Any, CallableActionT]]]) – A function or a dictionary of functions that take a Context object as input. If action behaves like actions. Only one of action and actions can be set.
false_action (Optional[CallableActionT]) – A function that takes a Context object as input and returns any value. It is used when action is a single function and represents the action to be taken when the condition is False.
actions (Optional[Dict[Any, CallableActionT]]) – A dictionary of action functions It should map the return values of condition to the corresponding action function. If action is None, actions must be provided.
description (str) – A string that describes what this rule does.
overwrite_settings (Optional[Dict[str, Any]]) – A dictionary of settings that will overwrite the agent’s setting for this Rule.
priority (RulePriority) – The priority of the rule. It can be a float, an integer, or a RulePriority enum value.
cooldown_reset_value (Optional[int]) – An optional integer value that represents the cooldown reset value for the rule. If not provided falls back to the class attribute
Rule.DEFAULT_COOLDOWN_RESET.group (Optional[str]) – An optional string that specifies the group to which this rule belongs.
enabled (bool) – A boolean value indicating whether the rule is enabled or not.
- Raises:
ValueError – If
phasesis empty or None, or ifphasescontains an object that is not of type Phase.TypeError – If
conditionis None and the class does not implement acondition()function, or if bothactionandactionsare None and the class does not have anactionsattribute or anaction()function.TypeError – if
actionsis not a Mapping object.ValueError – If both
actionandactionsare provided.ValueError – If
actionis a Mapping and eitherfalse_actionoractionsis not None.ValueError – If an
actionfunction is not callable.ValueError – If
descriptionis not a string.
- actions: dict[Any, CallableActionT] = {True: carla.TrafficLightState.Yellow}
Dictionary that maps rule results to the action that should be executed.