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#
Attributes#
Classes#
Represents the behavior of an agent in the simulation. |
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.
Initialize the behavior with object info and parameters.
- Parameters:
object_info – Information about the agent (from ObjectBase.ObjectInfo).
behavior_dict (dict | None) – Behavior parameters; if
None, defaults to an empty dict.
- object_info = None#
- behavior_dict#
- gen_vel(ego_object, external_objects=None)[source]#
Generate a velocity for the agent based on configured behavior.
- Parameters:
ego_object – The agent itself (object with needed attributes).
external_objects (list | None) – Other objects in the environment.
- Returns:
A 2x1 velocity vector appropriate for the agent kinematics.
- Return type:
numpy.ndarray
- load_behavior(behaviors: str = '.behavior_methods')[source]#
Load behavior parameters from the script.
- Parameters:
behaviors (str) – name of the behavior 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#
- irsim.lib.behavior.register_group_behavior#