irsim.lib.behavior#

Behavior system for IR-SIM simulation.

This package contains: - behavior: Base behavior class - behavior_registry: Behavior registration system - behavior_methods: Predefined behavior methods

Submodules#

Classes#

Behavior

Represents the behavior of an agent in the simulation.

Functions#

register_behavior(kinematics, action)

decorator to register a method in the behavior registry

Package Contents#

class irsim.lib.behavior.Behavior(object_info=None, behavior_dict=None)[source]#

Represents the behavior of an agent in the simulation.

Parameters:
  • object_info (object) – Object information from the object_base class ObjectInfo.

  • behavior_dict (dict) –

    Dictionary containing behavior parameters for different behaviors. Name Options include: ‘dash’, ‘rvo’. target_roles:

    • ’all’: all objects in the environment will be considered within this behavior.

    • ’obstacle’: only obstacles will be considered within this behavior.

    • ’robot’: only robots will be considered within this behavior.

Initializes the Behavior class with object information and behavior parameters.

Parameters:
  • object_info (object) – Information about the agent.

  • behavior_dict (dict) – Behavior parameters.

object_info = None#
behavior_dict#
gen_vel(ego_object, external_objects=[])[source]#

Generate velocity for the agent based on the behavior dictionary.

Parameters:
  • ego_object – the object itself

  • external_objects – all the other objects in the environment

Returns:

Generated velocity for the agent.

Return type:

np.array (2, 1)

load_behavior(behaviors: str = '.behavior_methods')[source]#

Load behavior parameters from the script.

Parameters:

behaviors (str) – name of the bevavior script.

invoke_behavior(kinematics: str, action: str, **kwargs: Any) Any[source]#

Invoke a specific behavior method based on kinematics model and action type.

This method looks up and executes the appropriate behavior function from the behavior registry based on the combination of kinematics model and action name.

Parameters:
  • kinematics (str) –

    Kinematics model identifier. Supported values:

    • ’diff’: Differential drive kinematics

    • ’omni’: Omnidirectional kinematics

    • ’acker’: Ackermann steering kinematics

  • action (str) –

    Behavior action name. Examples:

    • ’dash’: Direct movement toward goal

    • ’rvo’: Reciprocal Velocity Obstacles for collision avoidance

  • **kwargs – Additional keyword arguments passed to the behavior function. Common parameters include ego_object, external_objects, goal, etc.

Returns:

Generated velocity vector (2x1) in the format appropriate for the specified kinematics model.

Return type:

np.ndarray

Raises:

ValueError – If no behavior method is found for the given kinematics and action combination.

Example

>>> # Invoke differential drive dash behavior
>>> vel = behavior.invoke_behavior('diff', 'dash',
...                               ego_object=robot,
...                               external_objects=obstacles)
property logger#
irsim.lib.behavior.register_behavior(kinematics: str, action: str)[source]#

decorator to register a method in the behavior registry

Parameters:
  • kinematics – only support diff, omni, or acker

  • action – defined action for the kinematics