blueprints.agent module#
To make blueprints amneable for multi agent settings the Agent class provides easily structured
access to the relevant Things for observation (Sensors and Cameras)
and action (Actuators).
Agents are used similar to Bodies with some minor differences.
The child attributes for normal Things map only to direct children, but for an Agent instance
the attributes actuators, sensors and cameras
map to all descendants as a more intuitive shortcut.
All observations from Sensors and Cameras are bundeled in an observation attribute and
all actions can be applied through the force and activation attribute.
<sensors>
<force site='site_1'>
<force site='site_2'>
</sensors>
<actuators>
<general body='AGENT:body_1' dynprm='filter'>
<general body='body_2'>
</actuators>
<body name='AGENT:body_1'>
<body name='body_2'>
<site name='site_1'>
</body>
<site name='site_2'>
<camera name='cam'>
<joint name='joint'>
</body>
>>> agent.observation
{'<Camera>cam': np.ndarray([...], shape=(width, height)),
'<Force>_(0)': np.ndarray([0.]),
'<Force>_(1)': np.ndarray([0.])}
>>> agent.action_shape
{'force': 1,
'activation': 1}
>>> agent.force = np.darray([...])
>>> agent.activation = = np.darray([...])
Additionally shapes for observations and actions are available as attributes as well.
- class blueprints.agent.Agent[source]#
-
This class emulates a Body which serves as an interface for sensors, cameras and actuators of an Agent. It provides uniform access to the observation and action relevant Things.
- property name: str#
The returned name might differ from the user specification by an enumerations scheme that is applied if two Things of the same type in a kinematic tree share the same name.
- Returns:
possibly extended name of the Thing
- Return type:
str
- property cameras: ViewType#
Instead of returning just the children all descending Cameras are returned.
- Returns:
The view is routed to all cameras of the agent (instead of just those that follow directly in the kinematic hierarchy).
- Return type:
View
- property sensors: ViewType#
Instead of returning just the children all descending Sensors are returned.
- Returns:
The view is routed to all sensors of the agent (instead of just those that follow directly in the kinematic hierarchy).
- Return type:
View
- property actuators: ViewType#
Instead of returning just the children all descending Actuators are returned.
- Returns:
The view is routed to all actuators of the agent (instead of just those that follow directly in the kinematic hierarchy).
- Return type:
View
- property sensor_observation_shape: dict#
The dictionary contains the names of all sensors and their shapes.
- Return type:
dict
- property camera_observation_shape: dict#
The dictionary contains the names of all cameras and their shapes.
- Return type:
dict
- property observation_shape: dict#
The dictionary contains the names of all observables and their shapes.
- Return type:
dict
- property sensor_observation: dict#
The dictionary contains the name of all sensor observables and their data.
- Return type:
dict
- property camera_observation: dict#
The dictionary contains the name of all camera observables and their data.
- Return type:
dict
- property observation: dict#
The dictionary contains the name of all observables and their data.
- Return type:
dict
- property activation: list#
All activations of Actuators that have an activation state. Actuators with
'dyntype' == 'none'do not have an activation.- Return type:
list
- property force: list#
All forces of Actuators of the Agent
- Return type:
list
- property action_shape: dict#
The shapes of both action types (activations and forces)
- Return type:
dict