Navground Components#
Behaviors#
navground.learning.behaviors
PolicyBehavior#
- class PolicyBehavior(kinematics: core.Kinematics | None = None, radius: float = 0.0, policy: AnyPolicyPredictor | None = None, policy_path: PathLike = '', action_config: ControlActionConfig = ControlActionConfig(), observation_config: DefaultObservationConfig = DefaultObservationConfig(ignore_keys=[]), deterministic: bool = False, pre: ObservationTransform | None = None)#
Bases:
BasePolicyMixin
,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_angular_speed
(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
action_config (ControlActionConfig) – Configures which actions the policy generates
observation_config (DefaultObservationConfig) – Configures which observations the policy consumes
deterministic (bool) – Whether the policy evaluation is deterministic
pre (ObservationTransform | None) – Optional input (observations) transformation
policy_path (PathLike)
- class Heading#
Bases:
pybind11_object
Different behavior variants for the angular motion when it is no constrained by the kinematics or already specified by the current target.
They ability to apply them depends on the kinematics and on the current target.
- property name#
- actuate(*args, **kwargs)#
Overloaded function.
actuate(self: navground.core._navground.Behavior, twist: navground.core._navground.Twist2, time_step: float, enforce_feasibility: bool = False) -> None
Actuate a twist command, integrating using
Pose2.integrate()
- Parameters:
twist_cmd – The twist
time_step – The time step
enforce_feasibility – Whether to enforce that the command is kinematically feasible
actuate(self: navground.core._navground.Behavior, time_step: float) -> None
Convenience method to actuate the stored actuated twist command,
- Parameters:
time_step – The time step
- add_modulation(self: object, value: object) → None#
Adds a modulation.
- Parameters:
value – The modulation to add
- check_if_target_satisfied(self: navground.core._navground.Behavior) → bool#
Check if the current target has been satisfied
- Returns:
True if the current target has been satisfied.
- clone() → Self#
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, pre: ObservationTransform | None = None) → 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
pre (ObservationTransform | None) – Optional input (observations) transformation
action_config (ControlActionConfig)
observation_config (DefaultObservationConfig)
- Returns:
The configured policy behavior
- Return type:
Self
- close(self: navground.core._navground.Behavior) → None#
Clean-up the behavior before termination.
Call it once the behavior is not used anymore.
The base class implementation does nothing. Override it to add any logic to clean-up steps performed in
prepare()
.
- cmd_twist_along_path(self: navground.core._navground.Behavior, path: navground.core._navground.Path, speed: float, time_step: float) → navground.core._navground.Twist2#
Compute a command to follow a path
Users may override it to specialize a
Behavior
.The base implementation uses a carrot planner to computes a target velocity, and then calls
cmd_twist_towards_velocity
.- Parameters:
path – The desired path in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_angular_speed(self: navground.core._navground.Behavior, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to turn at a desired angular speed
Users may override it to specialize a
Behavior
.The base implementation returns the nearest feasible twist to a twist with null velocity and desired angular speed.
- Parameters:
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_orientation(self: navground.core._navground.Behavior, orientation: float, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to turn towards a desired orientation
Users may override it to specialize a
Behavior
.The base implementation:
computes a desired angular speed to rotate in
rotation_tau
time towards the desired orientation
- Parameters:
orientation – The desired orientation in world-fixed frame
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_point(self: navground.core._navground.Behavior, point: numpy.ndarray[numpy.float32[2, 1]], speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to move towards a desired position
Users may override it to specialize a
Behavior
.The base implementation:
calls
desired_velocity_towards_point
to compute a desired velocitycalls
twist_towards_velocity
to compute a desired twistreturns the nearest feasible twist.
- Parameters:
point – The desired position in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_pose(self: navground.core._navground.Behavior, pose: navground.core._navground.Pose2, speed: float, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to move towards a desired pose
Users may override it to specialize a
Behavior
.The base implementation ignores the orientation, calling call
cmd_twist_towards_point
, to first reach the desired position and then rotate in place to reach the desired orientation.- Parameters:
pose – The desired pose in world-fixed frame
speed – The desired speed
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_stopping(self: navground.core._navground.Behavior, time_step: float) → navground.core._navground.Twist2#
Computes a command to stop
Users may override it to specialize a
Behavior
.The base implementation returns the null twist.
- Parameters:
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], time_step: float) → navground.core._navground.Twist2#
Computes a command to turn towards a desired orientation
Users may override it to specialize a
Behavior
.The base implementation:
calls
desired_velocity_towards_velocity
to compute a desired velocitycalls
twist_towards_velocity
to compute a desired twistreturns the nearest feasible twist.
- Parameters:
velocity – The velocity in world-fixed frame
time_step – The time step
- Returns:
The command twist.
- compute_cmd(self: navground.core._navground.Behavior, time_step: float, frame: navground.core._navground.Frame | None = None, enforce_feasibility: bool = False) → navground.core._navground.Twist2#
Query the behavior to get a control command
Before calling this method, update the state using methods such as
pose
, andtwist
and set the targettarget
.Behaviors may use caching to speed up the next queries if the state does not change.
Modulations are applied as wrappers/context modifiers: right before evaluating the behavior in
compute_cmd_internal
, it will callBehaviorModulation.pre()
for any modulation inmodulations
, and right afterBehaviorModulation.post()
but in reverse order.- Parameters:
time_step – The control time step. Not all behavior use it but some may use it, for example, to limit accelerations.
frame – An optional desired frame of reference for the command.
enforce_feasibility – Whether to enforce that the command is kinematically feasible
- Returns:
The control command as a twist in the specified frame.
- desired_velocity_towards_point(self: navground.core._navground.Behavior, point: numpy.ndarray[numpy.float32[2, 1]], speed: float, time_step: float) → numpy.ndarray[numpy.float32[2, 1]]#
Computes a control velocity towards a desired position
Users may override it to specialize a
Behavior
.The base implementation returns a null vector.
- Parameters:
point – The desired point in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
A velocity in world-fixed frame
- desired_velocity_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], time_step: float) → numpy.ndarray[numpy.float32[2, 1]]#
Computes a control velocity towards a desired velocity
Users may override it to specialize a
Behavior
.The base implementation returns a null vector.
- Parameters:
velocity – The desired velocity in world-fixed frame
time_step – The time step
- Returns:
A velocity in world-fixed frame
- dump(self: navground::core::Behavior) → str#
Dumps the object to a YAML-string.
- Returns:
The YAML representation
- Return type:
- estimate_time_until_target_satisfied(self: navground.core._navground.Behavior) → float#
Estimate how much time before the target is satisfied
- Returns:
A positive value if the target is not yet satisfied, else 0.
- feasible_angular_speed(self: navground.core._navground.Behavior, value: float) → float#
Clamp an angular speed in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_speed(self: navground.core._navground.Behavior, value: float) → float#
Clamp a speed in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_twist(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2) → navground.core._navground.Twist2#
Clamp an twist in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_twist_from_current(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2, time_step: float) → navground.core._navground.Twist2#
Computes the nearest feasible twist given the kinematics and the current twist over a time step
- Parameters:
value – The desired value
time_step – The time step
- Returns:
the nearest feasible value
- get(self: navground.core._navground.HasProperties, name: str) → bool | int | float | str | numpy.ndarray[numpy.float32[2, 1]] | list[bool] | list[int] | list[float] | list[str] | list[numpy.ndarray[numpy.float32[2, 1]]]#
Gets the value of the specified property.
- Parameters:
name – The name of the property
- Raise:
std::runtime_error A runtime error if no property is found.
- Returns:
The value of the property
- get_actuated_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → navground.core._navground.Twist2#
Gets the last actuated twist.
- Parameters:
frame – The desired frame of reference.
- Returns:
The actuated twist.
- get_property_type_name(self: navground.core._navground.HasProperties, name: str) → str#
Gets the type of a property.
- Parameters:
name – The name of the property
- Returns:
The property type name or an empty string if the property is not defined.
- get_target_angular_direction(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → int | None#
Returns the distance to the target point, if valid, else null.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The distance.
- get_target_angular_distance(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Returns the distance to the target orientation, if valid, else 0.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The angular distance.
- get_target_angular_speed(self: navground.core._navground.Behavior) → float#
Returns the nearest feasible angular speed to target’s angular speed, if defined, else to the behavior own optimal angular speed.
- Returns:
The angular speed.
- get_target_angular_velocity(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Gets the current target angular velocity.
Multiplication of
get_target_angular_direction()
byget_target_angular_speed()
. Returns zero if the target angular direction is undefined.Note that this returns a signed value, while
get_target_angular_speed()
, returns the absolute value instead. Moreover considers (angular) tolerances, whileget_target_angular_speed()
not, just likeget_target_velocity()
vsget_target_speed()
.- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The angular velocity z-component.
- get_target_direction(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]] | None#
Returns the direction towards the target’s position if not satisfied, or the target’s direction if defined, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The normalized direction in the desired frame
- get_target_distance(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Returns the distance to the target point, if valid, else 0.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The distance.
- get_target_orientation(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame, ignore_tolerance: bool = False) → float | None#
Returns the target’s orientation if not satisfied, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The orientation in the desired frame
- get_target_pose(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → navground.core._navground.Pose2 | None#
Returns the target’s pose composed by position
get_target_position()
and orientationget_target_orientation()
, if both are defined, else null.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The pose in the desired frame or null.
- get_target_position(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]] | None#
Returns the target’s position if not satisfied, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The vector in the desired frame
- get_target_speed(self: navground.core._navground.Behavior) → float#
Returns the nearest feasible speed to target’s speed, if defined, else to the behavior own optimal speed.
- Returns:
The speed
- get_target_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → navground.core._navground.Twist2#
Gets the current target velocity.
Multiply
get_target_direction()
byget_target_speed()
. Returns a zero vector if the target direction is undefined.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The velocity in the desired frame.
- get_target_velocity(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]]#
Gets the current target velocity.
Multiply
get_target_direction()
byget_target_speed()
. Returns a zero vector if the target direction is undefined.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The velocity in the desired frame.
- get_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → navground.core._navground.Twist2#
Gets the current twist.
- Parameters:
frame – The desired frame of reference.
- Returns:
The current twist.
- get_velocity(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → numpy.ndarray[numpy.float32[2, 1]]#
Convenience method to get the current velocity. See
get_twist()
- Parameters:
frame – The desired frame of reference.
- Returns:
The velocity.
- has(self: navground.core._navground.HasProperties, name: str) → bool#
Checks whether a property exists.
- Parameters:
name – The name of the property
- Returns:
True if the property exists
- static has_type(name: str) → bool#
Check whether a type name has been registered.
- Parameters:
type – The associated type name.
- Returns:
True if the type name has been registered.
- init_policy() → None#
Loads the policy from
policy_path
if not already done.- Return type:
None
- is_stopped(self: navground.core._navground.Behavior, epsilon_speed: float = 1e-06, epsilon_angular_speed: float = 1e-06) → bool#
Determines if the behavior twist is small enough.
- Parameters:
epsilon_speed – The maximal speed to be at stop
epsilon_angular_speed – The maximal angular speed to be at stop
- Returns:
True if stopped, False otherwise.
- static load(value: str) → object#
Load a behavior from a YAML string.
- Parameters:
value – the YAML string.
- Returns:
The loaded behavior or
None
if loading fails.- Return type:
Behavior| None
- static make_type(name: str) → object#
Create an object of a sub-class selected by name.
- Parameters:
type – The associated type name.
- Returns:
An object of a registered sub-class or
None
in case the desired name is not found.
- static register_schema() → object#
Returns the json-schema that includes registered components.
- Returns:
“anyOf” json-schema of all registered components.
- Return type:
- remove_modulation(self: object, value: object) → None#
Removes a modulation.
- Parameters:
value – The modulation to remove
- static schema(reference_register_schema: bool = True, type: str | None = None) → object#
Returns the json-schema of a component
Returns an empty dictionary if a not registered type is requested.
- Parameters:
reference_register_schema – Whether to reference registered components schema in the base class schema.
type (str) – An optional registered type. If not specified, it returns the schema of the base class.
- Returns:
A json-schema of the registered class
- Return type:
- set(self: navground.core._navground.HasProperties, name: str, value: bool | int | float | str | numpy.ndarray[numpy.float32[2, 1]] | list[bool] | list[int] | list[float] | list[str] | list[numpy.ndarray[numpy.float32[2, 1]]]) → None#
Set the value of a named property. Fails silently if no property can be found or if the value has a non-compatible type.
- Parameters:
name – The name of the property
value – The desired value for the property
- set_state_from(self: navground.core._navground.Behavior, other: navground.core._navground.Behavior) → None#
Clone the state of this behavior from another behavior
- Parameters:
other – The other behavior
- set_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → None#
Convenience method to set the current velocity. See
twist
- Parameters:
value – The velocity
frame – The desired frame of reference.
- to_frame(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2, frame: navground.core._navground.Frame) → navground.core._navground.Twist2#
Convert a twist to a reference frame.
- Parameters:
value – The original twist.
frame – The desired frame of reference
- Returns:
The twist in the desired frame of reference.
- twist_from_wheel_speeds(self: navground.core._navground.Behavior, value: list[float]) → navground.core._navground.Twist2#
Convenience method to transform from wheel speeds to twist.
If the agent is not wheeled (
Kinematics.is_wheeled()
), an zero twist is returned.- Parameters:
value – The wheel speeds
- Returns:
The corresponding twist.
- twist_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]]) → navground.core._navground.Twist2#
Computes a twist to reach a control velocity
This method assumes that the control velocity is safe. Use it to convert a velocity to a twist once you have computed (using, e.g.,
desired_velocity_towards_point
ordesired_velocity_towards_velocity
) a safe control velocity.- Parameters:
velocity – The control velocity in world-fixed frame
- Returns:
A command twist.
- wheel_speeds_from_twist(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2) → list[float]#
Convenience method to transform from twist to wheel speeds.
If the agent is not wheeled (
Kinematics.is_wheeled()
), an empty vector is returned.- Parameters:
value – The twist
- Returns:
The corresponding wheel speeds.
- property actuated_twist#
The last actuated twist.
- Parameters:
frame – the desired frame of reference.
- property actuated_wheel_speeds#
Convenience method to get the last actuated wheel speeds from
actuated_twist
.If the agent is not wheeled (
Kinematics.is_wheeled()
), an empty vector is returned.
- property angular_speed#
Convenience method to get the current the angular speed.
- property assume_cmd_is_actuated#
Whether to assume that the compute command will be actuated as it is.
if set,
behavior
will assume that the control command computed bycompute_cmd()
be actuated, therefore settingactuated_twist
to that value. if not set, the user should setbehavior.actuated_twist
before querying for a new control commands: some behavior use the old actuated control command to compute smoother controls.
- property desired_velocity#
The last computed desired velocity.
- property efficacy#
The efficacy: the projection of the current velocity on the ideal velocity (ignoring obstacles) towards the target.
a value of 1.0 denotes ideal efficacy, value of 0.0 that the agent is stuck.
- property environment_state#
The environment state.
- property has_target#
Whether the current target is valid
- property heading_behavior#
The heading behavior:
- property horizon#
The horizon: the size of the portion of environment around the agent considered when computing possible collisions. larger values generally lead to a more computationally expensive
compute_cmd()
but fewer deadlocks and less jamming.
- property include_target_direction_validity: bool#
See
DefaultObservationConfig.include_target_direction_validity
- property include_target_distance_validity: bool#
See
DefaultObservationConfig.include_target_distance_validity
- property is_stuck#
Determines if the agent is stuck: if should move but it is still.
- property kinematics#
The kinematics.
- property max_angular_speed#
The maximal angular speed speed.
- property max_speed#
The maximal speed.
- property modulations#
The modulations applied to this behavior
- property optimal_angular_speed#
The desired optimal angular speed.
if not configured through
optimal_angular_speed
, it will return set tomax_angular_speed
.
- property optimal_speed#
The desired optimal speed.
if not configured through
optimal_speed
, it returnmax_speed
.
- property path_look_ahead#
The path look-ahead distance
- property path_tau#
The path relaxation time
- property pose#
The current pose in the world-fixed frame.
- property position#
Convenience method to get the current position in the world-fixed frame. See
pose
.
- property properties#
The registered properties
- property radius#
The radius of the agent.
- property rotation_tau#
The relaxation time to rotate towards a desired orientation.
the default behaviors applies a p control to rotations, e.g., \(\omega = \frac{\delta \theta}{\tau_\textrm{rot}}\)
- property safety_margin#
The minimal safety margin to keep away from obstacles
- property social_margin#
The behavior social margin modulation
- property speed#
Convenience method to get the current speed. See
get_twist()
- property target#
The target.
- property target_ref#
A reference to the target.
- property twist#
The current twist.
- Parameters:
frame – the desired frame of reference.
- property type#
The name associated to the type of an object
- property velocity#
Convenience method to get the current velocity. See
get_twist()
- Parameters:
frame – The desired frame of reference.
- property wheel_speeds#
Convenience method to get the current wheel speeds. See
get_twist()
GroupedPolicyBehavior#
- class GroupedPolicyBehavior(kinematics: core.Kinematics | None = None, radius: float = 0.0, policy: AnyPolicyPredictor | None = None, policy_path: PathLike = '', action_config: ControlActionConfig = ControlActionConfig(), observation_config: DefaultObservationConfig = DefaultObservationConfig(ignore_keys=[]), deterministic: bool = False, pre: ObservationTransform | None = None)#
Bases:
BasePolicyMixin
,BehaviorGroupMember
- Parameters:
kinematics (core.Kinematics | None)
radius (float)
policy (AnyPolicyPredictor | None)
policy_path (PathLike)
action_config (ControlActionConfig)
observation_config (DefaultObservationConfig)
deterministic (bool)
pre (ObservationTransform | None)
- class Heading#
Bases:
pybind11_object
Different behavior variants for the angular motion when it is no constrained by the kinematics or already specified by the current target.
They ability to apply them depends on the kinematics and on the current target.
- property name#
- actuate(*args, **kwargs)#
Overloaded function.
actuate(self: navground.core._navground.Behavior, twist: navground.core._navground.Twist2, time_step: float, enforce_feasibility: bool = False) -> None
Actuate a twist command, integrating using
Pose2.integrate()
- Parameters:
twist_cmd – The twist
time_step – The time step
enforce_feasibility – Whether to enforce that the command is kinematically feasible
actuate(self: navground.core._navground.Behavior, time_step: float) -> None
Convenience method to actuate the stored actuated twist command,
- Parameters:
time_step – The time step
- add_modulation(self: object, value: object) → None#
Adds a modulation.
- Parameters:
value – The modulation to add
- check_if_target_satisfied(self: navground.core._navground.Behavior) → bool#
Check if the current target has been satisfied
- Returns:
True if the current target has been satisfied.
- clone() → Self#
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, pre: ObservationTransform | None = None) → 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
pre (ObservationTransform | None) – Optional input (observations) transformation
action_config (ControlActionConfig)
observation_config (DefaultObservationConfig)
- Returns:
The configured policy behavior
- Return type:
Self
- cmd_twist_along_path(self: navground.core._navground.Behavior, path: navground.core._navground.Path, speed: float, time_step: float) → navground.core._navground.Twist2#
Compute a command to follow a path
Users may override it to specialize a
Behavior
.The base implementation uses a carrot planner to computes a target velocity, and then calls
cmd_twist_towards_velocity
.- Parameters:
path – The desired path in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_angular_speed(self: navground.core._navground.Behavior, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to turn at a desired angular speed
Users may override it to specialize a
Behavior
.The base implementation returns the nearest feasible twist to a twist with null velocity and desired angular speed.
- Parameters:
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_orientation(self: navground.core._navground.Behavior, orientation: float, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to turn towards a desired orientation
Users may override it to specialize a
Behavior
.The base implementation:
computes a desired angular speed to rotate in
rotation_tau
time towards the desired orientation
- Parameters:
orientation – The desired orientation in world-fixed frame
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_point(self: navground.core._navground.Behavior, point: numpy.ndarray[numpy.float32[2, 1]], speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to move towards a desired position
Users may override it to specialize a
Behavior
.The base implementation:
calls
desired_velocity_towards_point
to compute a desired velocitycalls
twist_towards_velocity
to compute a desired twistreturns the nearest feasible twist.
- Parameters:
point – The desired position in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_pose(self: navground.core._navground.Behavior, pose: navground.core._navground.Pose2, speed: float, angular_speed: float, time_step: float) → navground.core._navground.Twist2#
Computes a command to move towards a desired pose
Users may override it to specialize a
Behavior
.The base implementation ignores the orientation, calling call
cmd_twist_towards_point
, to first reach the desired position and then rotate in place to reach the desired orientation.- Parameters:
pose – The desired pose in world-fixed frame
speed – The desired speed
angular_speed – The desired angular speed
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_stopping(self: navground.core._navground.Behavior, time_step: float) → navground.core._navground.Twist2#
Computes a command to stop
Users may override it to specialize a
Behavior
.The base implementation returns the null twist.
- Parameters:
time_step – The time step
- Returns:
The command twist.
- cmd_twist_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], time_step: float) → navground.core._navground.Twist2#
Computes a command to turn towards a desired orientation
Users may override it to specialize a
Behavior
.The base implementation:
calls
desired_velocity_towards_velocity
to compute a desired velocitycalls
twist_towards_velocity
to compute a desired twistreturns the nearest feasible twist.
- Parameters:
velocity – The velocity in world-fixed frame
time_step – The time step
- Returns:
The command twist.
- compute_cmd(self: navground.core._navground.Behavior, time_step: float, frame: navground.core._navground.Frame | None = None, enforce_feasibility: bool = False) → navground.core._navground.Twist2#
Query the behavior to get a control command
Before calling this method, update the state using methods such as
pose
, andtwist
and set the targettarget
.Behaviors may use caching to speed up the next queries if the state does not change.
Modulations are applied as wrappers/context modifiers: right before evaluating the behavior in
compute_cmd_internal
, it will callBehaviorModulation.pre()
for any modulation inmodulations
, and right afterBehaviorModulation.post()
but in reverse order.- Parameters:
time_step – The control time step. Not all behavior use it but some may use it, for example, to limit accelerations.
frame – An optional desired frame of reference for the command.
enforce_feasibility – Whether to enforce that the command is kinematically feasible
- Returns:
The control command as a twist in the specified frame.
- compute_cmd_internal(self: navground.core._navground.Behavior, time_step: float) → navground.core._navground.Twist2#
Computes the control command.
This is a virtual protected that sub-classes may override to define a behavior and is not part of the public API. Users should call
compute_cmd()
instead.The base implementation checks for a valid target:
position along a path => calls
cmd_twist_along_path
pose => calls
cmd_twist_towards_pose
position => calls
cmd_twist_towards_point
orientation => calls
cmd_twist_towards_orientation
velocity => calls
cmd_twist_towards_velocity
angular speed => calls
cmd_twist_towards_angular_speed
else => calls
cmd_twist_towards_stopping
.
To specialize a
Behavior
, users may override this or any of the methods listed above. They may also override the following internal methods:The command should be kinematically feasible. The base implementation does not guaranteed it, delegating the check to the methods listed above.
- Parameters:
time_step – The time step
- Returns:
The command in the desired frame.
- desired_velocity_towards_point(self: navground.core._navground.Behavior, point: numpy.ndarray[numpy.float32[2, 1]], speed: float, time_step: float) → numpy.ndarray[numpy.float32[2, 1]]#
Computes a control velocity towards a desired position
Users may override it to specialize a
Behavior
.The base implementation returns a null vector.
- Parameters:
point – The desired point in world-fixed frame
speed – The desired speed
time_step – The time step
- Returns:
A velocity in world-fixed frame
- desired_velocity_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], time_step: float) → numpy.ndarray[numpy.float32[2, 1]]#
Computes a control velocity towards a desired velocity
Users may override it to specialize a
Behavior
.The base implementation returns a null vector.
- Parameters:
velocity – The desired velocity in world-fixed frame
time_step – The time step
- Returns:
A velocity in world-fixed frame
- dump(self: navground::core::Behavior) → str#
Dumps the object to a YAML-string.
- Returns:
The YAML representation
- Return type:
- estimate_time_until_target_satisfied(self: navground.core._navground.Behavior) → float#
Estimate how much time before the target is satisfied
- Returns:
A positive value if the target is not yet satisfied, else 0.
- feasible_angular_speed(self: navground.core._navground.Behavior, value: float) → float#
Clamp an angular speed in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_speed(self: navground.core._navground.Behavior, value: float) → float#
Clamp a speed in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_twist(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2) → navground.core._navground.Twist2#
Clamp an twist in the range of feasible values given by the kinematics.
- Parameters:
value – The desired value
- Returns:
the nearest feasible value
- feasible_twist_from_current(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2, time_step: float) → navground.core._navground.Twist2#
Computes the nearest feasible twist given the kinematics and the current twist over a time step
- Parameters:
value – The desired value
time_step – The time step
- Returns:
the nearest feasible value
- get(self: navground.core._navground.HasProperties, name: str) → bool | int | float | str | numpy.ndarray[numpy.float32[2, 1]] | list[bool] | list[int] | list[float] | list[str] | list[numpy.ndarray[numpy.float32[2, 1]]]#
Gets the value of the specified property.
- Parameters:
name – The name of the property
- Raise:
std::runtime_error A runtime error if no property is found.
- Returns:
The value of the property
- get_actuated_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → navground.core._navground.Twist2#
Gets the last actuated twist.
- Parameters:
frame – The desired frame of reference.
- Returns:
The actuated twist.
- get_property_type_name(self: navground.core._navground.HasProperties, name: str) → str#
Gets the type of a property.
- Parameters:
name – The name of the property
- Returns:
The property type name or an empty string if the property is not defined.
- get_target_angular_direction(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → int | None#
Returns the distance to the target point, if valid, else null.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The distance.
- get_target_angular_distance(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Returns the distance to the target orientation, if valid, else 0.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The angular distance.
- get_target_angular_speed(self: navground.core._navground.Behavior) → float#
Returns the nearest feasible angular speed to target’s angular speed, if defined, else to the behavior own optimal angular speed.
- Returns:
The angular speed.
- get_target_angular_velocity(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Gets the current target angular velocity.
Multiplication of
get_target_angular_direction()
byget_target_angular_speed()
. Returns zero if the target angular direction is undefined.Note that this returns a signed value, while
get_target_angular_speed()
, returns the absolute value instead. Moreover considers (angular) tolerances, whileget_target_angular_speed()
not, just likeget_target_velocity()
vsget_target_speed()
.- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The angular velocity z-component.
- get_target_direction(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]] | None#
Returns the direction towards the target’s position if not satisfied, or the target’s direction if defined, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The normalized direction in the desired frame
- get_target_distance(self: navground.core._navground.Behavior, ignore_tolerance: bool = False) → float#
Returns the distance to the target point, if valid, else 0.
- Parameters:
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The distance.
- get_target_orientation(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame, ignore_tolerance: bool = False) → float | None#
Returns the target’s orientation if not satisfied, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The orientation in the desired frame
- get_target_pose(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → navground.core._navground.Pose2 | None#
Returns the target’s pose composed by position
get_target_position()
and orientationget_target_orientation()
, if both are defined, else null.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The pose in the desired frame or null.
- get_target_position(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]] | None#
Returns the target’s position if not satisfied, else null.
- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The vector in the desired frame
- get_target_speed(self: navground.core._navground.Behavior) → float#
Returns the nearest feasible speed to target’s speed, if defined, else to the behavior own optimal speed.
- Returns:
The speed
- get_target_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → navground.core._navground.Twist2#
Gets the current target velocity.
Multiply
get_target_direction()
byget_target_speed()
. Returns a zero vector if the target direction is undefined.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The velocity in the desired frame.
- get_target_velocity(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute, ignore_tolerance: bool = False) → numpy.ndarray[numpy.float32[2, 1]]#
Gets the current target velocity.
Multiply
get_target_direction()
byget_target_speed()
. Returns a zero vector if the target direction is undefined.- Parameters:
frame – The desired frame
ignore_tolerance – Whether to ignore the target tolerance
- Returns:
The velocity in the desired frame.
- get_twist(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → navground.core._navground.Twist2#
Gets the current twist.
- Parameters:
frame – The desired frame of reference.
- Returns:
The current twist.
- get_velocity(self: navground.core._navground.Behavior, frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → numpy.ndarray[numpy.float32[2, 1]]#
Convenience method to get the current velocity. See
get_twist()
- Parameters:
frame – The desired frame of reference.
- Returns:
The velocity.
- has(self: navground.core._navground.HasProperties, name: str) → bool#
Checks whether a property exists.
- Parameters:
name – The name of the property
- Returns:
True if the property exists
- static has_type(name: str) → bool#
Check whether a type name has been registered.
- Parameters:
type – The associated type name.
- Returns:
True if the type name has been registered.
- init_policy() → None#
Loads the policy from
policy_path
if not already done.- Return type:
None
- is_stopped(self: navground.core._navground.Behavior, epsilon_speed: float = 1e-06, epsilon_angular_speed: float = 1e-06) → bool#
Determines if the behavior twist is small enough.
- Parameters:
epsilon_speed – The maximal speed to be at stop
epsilon_angular_speed – The maximal angular speed to be at stop
- Returns:
True if stopped, False otherwise.
- static load(value: str) → object#
Load a behavior from a YAML string.
- Parameters:
value – the YAML string.
- Returns:
The loaded behavior or
None
if loading fails.- Return type:
Behavior| None
- static make_type(name: str) → object#
Create an object of a sub-class selected by name.
- Parameters:
type – The associated type name.
- Returns:
An object of a registered sub-class or
None
in case the desired name is not found.
- static register_schema() → object#
Returns the json-schema that includes registered components.
- Returns:
“anyOf” json-schema of all registered components.
- Return type:
- remove_modulation(self: object, value: object) → None#
Removes a modulation.
- Parameters:
value – The modulation to remove
- static schema(reference_register_schema: bool = True, type: str | None = None) → object#
Returns the json-schema of a component
Returns an empty dictionary if a not registered type is requested.
- Parameters:
reference_register_schema – Whether to reference registered components schema in the base class schema.
type (str) – An optional registered type. If not specified, it returns the schema of the base class.
- Returns:
A json-schema of the registered class
- Return type:
- set(self: navground.core._navground.HasProperties, name: str, value: bool | int | float | str | numpy.ndarray[numpy.float32[2, 1]] | list[bool] | list[int] | list[float] | list[str] | list[numpy.ndarray[numpy.float32[2, 1]]]) → None#
Set the value of a named property. Fails silently if no property can be found or if the value has a non-compatible type.
- Parameters:
name – The name of the property
value – The desired value for the property
- set_state_from(self: navground.core._navground.Behavior, other: navground.core._navground.Behavior) → None#
Clone the state of this behavior from another behavior
- Parameters:
other – The other behavior
- set_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]], frame: navground.core._navground.Frame = navground.core._navground.Frame.absolute) → None#
Convenience method to set the current velocity. See
twist
- Parameters:
value – The velocity
frame – The desired frame of reference.
- to_frame(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2, frame: navground.core._navground.Frame) → navground.core._navground.Twist2#
Convert a twist to a reference frame.
- Parameters:
value – The original twist.
frame – The desired frame of reference
- Returns:
The twist in the desired frame of reference.
- twist_from_wheel_speeds(self: navground.core._navground.Behavior, value: list[float]) → navground.core._navground.Twist2#
Convenience method to transform from wheel speeds to twist.
If the agent is not wheeled (
Kinematics.is_wheeled()
), an zero twist is returned.- Parameters:
value – The wheel speeds
- Returns:
The corresponding twist.
- twist_towards_velocity(self: navground.core._navground.Behavior, velocity: numpy.ndarray[numpy.float32[2, 1]]) → navground.core._navground.Twist2#
Computes a twist to reach a control velocity
This method assumes that the control velocity is safe. Use it to convert a velocity to a twist once you have computed (using, e.g.,
desired_velocity_towards_point
ordesired_velocity_towards_velocity
) a safe control velocity.- Parameters:
velocity – The control velocity in world-fixed frame
- Returns:
A command twist.
- wheel_speeds_from_twist(self: navground.core._navground.Behavior, value: navground.core._navground.Twist2) → list[float]#
Convenience method to transform from twist to wheel speeds.
If the agent is not wheeled (
Kinematics.is_wheeled()
), an empty vector is returned.- Parameters:
value – The twist
- Returns:
The corresponding wheel speeds.
- property actuated_twist#
The last actuated twist.
- Parameters:
frame – the desired frame of reference.
- property actuated_wheel_speeds#
Convenience method to get the last actuated wheel speeds from
actuated_twist
.If the agent is not wheeled (
Kinematics.is_wheeled()
), an empty vector is returned.
- property angular_speed#
Convenience method to get the current the angular speed.
- property assume_cmd_is_actuated#
Whether to assume that the compute command will be actuated as it is.
if set,
behavior
will assume that the control command computed bycompute_cmd()
be actuated, therefore settingactuated_twist
to that value. if not set, the user should setbehavior.actuated_twist
before querying for a new control commands: some behavior use the old actuated control command to compute smoother controls.
- property desired_velocity#
The last computed desired velocity.
- property efficacy#
The efficacy: the projection of the current velocity on the ideal velocity (ignoring obstacles) towards the target.
a value of 1.0 denotes ideal efficacy, value of 0.0 that the agent is stuck.
- property environment_state#
The environment state.
- property has_target#
Whether the current target is valid
- property heading_behavior#
The heading behavior:
- property horizon#
The horizon: the size of the portion of environment around the agent considered when computing possible collisions. larger values generally lead to a more computationally expensive
compute_cmd()
but fewer deadlocks and less jamming.
- property include_target_direction_validity: bool#
See
DefaultObservationConfig.include_target_direction_validity
- property include_target_distance_validity: bool#
See
DefaultObservationConfig.include_target_distance_validity
- property is_stuck#
Determines if the agent is stuck: if should move but it is still.
- property kinematics#
The kinematics.
- property max_angular_speed#
The maximal angular speed speed.
- property max_speed#
The maximal speed.
- property modulations#
The modulations applied to this behavior
- property optimal_angular_speed#
The desired optimal angular speed.
if not configured through
optimal_angular_speed
, it will return set tomax_angular_speed
.
- property optimal_speed#
The desired optimal speed.
if not configured through
optimal_speed
, it returnmax_speed
.
- property path_look_ahead#
The path look-ahead distance
- property path_tau#
The path relaxation time
- property pose#
The current pose in the world-fixed frame.
- property position#
Convenience method to get the current position in the world-fixed frame. See
pose
.
- property properties#
The registered properties
- property radius#
The radius of the agent.
- property rotation_tau#
The relaxation time to rotate towards a desired orientation.
the default behaviors applies a p control to rotations, e.g., \(\omega = \frac{\delta \theta}{\tau_\textrm{rot}}\)
- property safety_margin#
The minimal safety margin to keep away from obstacles
- property social_margin#
The behavior social margin modulation
- property speed#
Convenience method to get the current speed. See
get_twist()
- property target#
The target.
- property target_ref#
A reference to the target.
- property twist#
The current twist.
- Parameters:
frame – the desired frame of reference.
- property type#
The name associated to the type of an object
- property velocity#
Convenience method to get the current velocity. See
get_twist()
- Parameters:
frame – The desired frame of reference.
- property wheel_speeds#
Convenience method to get the current wheel speeds. See
get_twist()
Pad#
navground.learning.behaviors.pad
- class DistributedPadBehavior(kinematics: Kinematics | None = None, radius: float = 0, pad_width: float = 0.5)#
Bases:
Behavior
A centralized behavior that applies a (quasi) optimal strategy in
navground.learning.scenarios.PadScenario
:if both agents have already passed the mid-point of the pad, or at least one agent has already passed the pad: they advance at full speed
if both agents are in the first half of the pad: if the fastest way for one agent to exit first from the path is to move backwards: the agent move forward at full speed, while the other keeps advancing at full speed
else: the agent predicted to exit the pad second, adjust its speed like
speed = min(optimal_speed, distance_to_enter_pad / other_agent_time_to_exit_the_pad)``
where the computation uses the other agent current speed to predict:
other_agent_time_to_exit_the_pad = ( other_agent_distance_to_exit_pad / other_agent_current_speed)``
- Parameters:
kinematics (core.Kinematics | None)
radius (float)
pad_width (float)
- class CentralizedPadBehavior(kinematics: Kinematics | None = None, radius: float = 0, pad_width: float = 0.5)#
Bases:
BehaviorGroupMember
A centralized behavior that applies a (quasi) optimal strategy in
navground.learning.scenarios.PadScenario
:if both agents have already passed the mid-point of the pad, or at least one agent has already passed the pad: they advance at full speed
if both agents are in the first half of the pad: if the fastest way for one agent to exit first from the path is to move backwards: the agent move forward at full speed, while the other keeps advancing at full speed
else: the agent predicted to exit the pad second, adjust its speed like
speed = min(optimal_speed, distance_to_enter_pad / other_agent_time_to_exit_the_pad)``
where the computation uses the other agent optimal speed to predict:
other_agent_time_to_exit_the_pad = ( other_agent_distance_to_exit_pad / other_agent_optional_speed)``
- Parameters:
kinematics (core.Kinematics | None)
radius (float)
pad_width (float)
- class StopAtPadBehavior(kinematics: Kinematics | None = None, radius: float = 0, pad_width: float = 0.5, tau: float = 0.5)#
Bases:
Behavior
A centralized behavior for
navground.learning.scenarios.PadScenario
, that stops the agent before entering the pad.- Parameters:
kinematics (core.Kinematics | None)
radius (float)
pad_width (float)
tau (float)
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
Pad#
- class PadScenario(length: float = 2, width: float = 0.6, with_walls: bool = True, start_min_x: float = -inf, start_max_x: float = inf, start_in_opposite_sides: bool = True, pad_tolerance: float = 0.01, pad_width: float = 0.5)#
Bases:
Scenario
- render_kwargs(comm: bool = False, low: float = -1, high: float = 1, color_low: tuple[float, float, float] = (0, 0, 0), color_high: tuple[float, float, float] = (0, 0, 1), stroke: str = 'white', binarize: bool = False) → dict[str, Any]#
The kwargs to pass to the world renderer
- Parameters:
comm (bool) – Whether to display transmitted messages using a LED.
low (float) – The message lower bound
high (float) – The message upper bound
color_low (tuple[float, float, float]) – The color associated to lower-valued messages
color_high (tuple[float, float, float]) – The color associated to higher-valued messages
stroke (str) – The color of the LED boundary
binarize (bool) – Whether to binary message values.
- Returns:
The kwargs
- Return type:
State Estimations#
navground.learning.state_estimations
Probes#
navground.learning.probes
- class GymProbe(groups: Collection[GroupConfig])#
Bases:
Probe
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)#
Bases:
RecordProbe
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:
- class SuccessProbe(ds: Dataset, indices: Indices | slice | list[int] | tuple[int] | set[int] | Literal['ALL'] = Indices.all(), is_success: Callable[[Agent, World], bool] | None = None, is_failure: Callable[[Agent, World], bool] | None = None)#
Bases:
RecordProbe
A probe that records successes statuses to a single dataset of shape
(#agents, )
, where-1 = unknown
0 = failure
1 = success
- Parameters:
ds (sim.Dataset) – The dataset
indices (IndicesLike) – The indices of the agents to record
is_success (Condition | None) – Success condition
is_success – Failure condition
is_failure (Condition | None)
- classmethod with_indices(indices: Indices | slice | list[int] | tuple[int] | set[int] | Literal['ALL']) → Callable[[Dataset], SuccessProbe]#
Creates a probe factory to record success statuses.
- Parameters:
indices (Indices | slice | list[int] | tuple[int] | set[int] | Literal['ALL']) – The indices of the agents to record
- 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:
- class CommProbe#
Bases:
RecordProbe
A probe that records transmitted messages to a single dataset of shape
(#agents, message size)