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)[源代码]#
Represents the behavior of an agent in the simulation.
- 参数:
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.
- 参数:
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)[源代码]#
Generate a velocity for the agent based on configured behavior.
- 参数:
ego_object -- The agent itself (object with needed attributes).
external_objects (list | None) -- Other objects in the environment.
- 返回:
A 2x1 velocity vector appropriate for the agent kinematics.
- 返回类型:
numpy.ndarray
- load_behavior(behaviors: str = '.behavior_methods')[源代码]#
Load behavior parameters from the script.
- 参数:
behaviors (str) -- name of the behavior script.
- invoke_behavior(kinematics: str, action: str, **kwargs: Any) Any[源代码]#
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.
- 参数:
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.
- 返回:
Generated velocity vector (2x1) in the format appropriate for the specified kinematics model.
- 返回类型:
np.ndarray
- 抛出:
ValueError -- If no behavior method is found for the given kinematics and action combination.
示例
>>> # Invoke differential drive dash behavior >>> vel = behavior.invoke_behavior('diff', 'dash', ... ego_object=robot, ... external_objects=obstacles)
- irsim.lib.behavior.register_behavior#
- irsim.lib.behavior.register_group_behavior#