Navground Components#
Behaviors#
navground.learning.behaviors
PolicyBehavior#
- class PolicyBehavior(kinematics: core.Kinematics | None = None, radius: float = 0.0, policy: AnyPolicyPredictor | None = None, action_config: ControlActionConfig = ControlActionConfig(), observation_config: DefaultObservationConfig = DefaultObservationConfig(), deterministic: bool = False)#
Bases:
Behavior
A navigation behavior that evaluates a ML policy
Registered properties:
policy_path
(str)flat
(bool)history
(int)fix_orientation
(bool)include_target_direction
(bool)include_target_distance
(bool)include_target_speed
(bool)include_target_angular_speed
(bool)include_velocity
(bool)include_radius
(bool)use_wheels
(bool)use_acceleration_action
(bool)max_acceleration
(float)max_angular_acceleration
(float)deterministic
(bool)
State:
core.SensingState
- Parameters:
kinematics (core.Kinematics | None) – The agent kinematics
radius (float) – The agent radius
policy (AnyPolicyPredictor | None) – The policy
config – How to use the policy (default if not specified)
action_config (ControlActionConfig)
observation_config (DefaultObservationConfig)
deterministic (bool)
- clone() → PolicyBehavior#
Creates a new policy behavior with same properties but a separate state.
- Returns:
Copy of this object.
- Return type:
- classmethod clone_behavior(behavior: core.Behavior, policy: AnyPolicyPredictor | PathLike | None, action_config: ControlActionConfig, observation_config: DefaultObservationConfig, deterministic: bool = False) → Self#
Configure a new policy behavior from a behavior.
- Parameters:
behavior (core.Behavior) – The behavior to replicate
policy (AnyPolicyPredictor | PathLike | None) – The policy
config – The configuration
deterministic (bool) – Whether or not to output deterministic actions
action_config (ControlActionConfig)
observation_config (DefaultObservationConfig)
- Returns:
The configured policy behavior
- Return type:
Self
- property include_target_direction_validity: bool#
See
DefaultObservationConfig.include_target_direction_validity
- property include_target_distance_validity: bool#
See
DefaultObservationConfig.include_target_distance_validity
Scenarios#
navground.learning.scenarios
CorridorWithObstacle#
- class CorridorWithObstacle(length: float = 10.0, width: float = 1.0, min_radius: float = 0.1, max_radius: float = 0.5)#
Bases:
Scenario
Simple worlds with
one agent that starts at
(0, ~U(0, width))
and wants to travel towards+x
two long horizontal walls at
y = 0
andy = width
one circular obstacle at
~(length, U(0, width))
with radius~U(min_radius, max_radius)
The simulation finishes when the agent reaches
x >= 2 length
- Parameters:
Forward#
- class ForwardScenario(width: float = 2.0, length: float = 6.0, min_number_of_obstacles: int = 0, max_number_of_obstacles: int = 0, min_obstacle_radius: float = 0.2, max_obstacle_radius: float = 0.2, margin: float = 0.0, periodic_x: bool = True, periodic_y: bool = True)#
Bases:
Scenario
Periodic worlds with agents traveling in (constant) random target directions between random obstacles:
- Parameters:
width (float) – The width of the (periodic) cell
length (float) – The length of the (periodic) cell
min_number_of_obstacles (int) – The minimum number of obstacles
max_number_of_obstacles (int) – The maximum number of obstacles
min_obstacle_radius (float) – The minimal obstacles radius
max_obstacle_radius (float) – The maximal obstacles radius
margin (float) – The margin between agents at init
periodic_x (bool) – Whether the world is periodic along the x-axis
periodic_y (bool) – Whether the world is periodic along the y-axis
Probes#
navground.learning.probes
- class GymProbe(groups: Collection[GroupConfig])#
A probe to record observation, rewards and actions, like during a rollout. Internally uses a
imitation.data.rollout.TrajectoryAccumulator
to store the data, which it writes to datasets only at the end of the run:observations/<agent_index>/<key>
actions/<agent_index>
rewards/<agent_index>
- Parameters:
groups (Collection[GroupConfig]) – The configuration of the groups
- classmethod with_env(env: BaseEnv | BaseParallelEnv) → Callable[[], GymProbe]#
Creates a probe factory to record all actions and observations in an environment
- Parameters:
env (BaseEnv | BaseParallelEnv) – The environment
- Returns:
A callable that can be added to runs or experiments, using
navground.sim.ExperimentalRun.add_record_probe()
ornavground.sim.Experiment.add_record_probe()
- Return type:
Callable[[], GymProbe]
- class RewardProbe(ds: Dataset, groups: Collection[GroupConfig] = (), reward: Reward | None = None)#
A probe to record rewards to a single dataset of shape
(#agents, #steps)
- Parameters:
ds (sim.Dataset) – The dataset
groups (Collection[GroupConfig]) – The configuration of the groups
reward (Reward | None) – The reward function
- classmethod with_reward(reward: Reward) → Callable[[Dataset], RewardProbe]#
Creates a probe factory to record a reward
- Parameters:
reward (Reward) – The reward
- Returns:
A callable that can be added to runs or experiments using
navground.sim.ExperimentalRun.add_record_probe()
ornavground.sim.Experiment.add_record_probe()
.- Return type: