POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models package

Tests for POMDPPlanners/environments/carla_pomdp/models/.

Submodules

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_cardreamer_world_model module

Tests for the CarDreamer/DreamerV3 adapter’s framework-agnostic packing helpers.

The JAX-backed CarDreamerWorldModel itself needs jax/dreamerv3 and a trained checkpoint, so it is not exercised here. The latent pack/unpack helpers that bridge the flat planner latent and the DreamerV3 {deter, stoch} state dict are pure NumPy and are covered directly.

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_cardreamer_world_model.test_pack_unpack_latents_round_trip_categorical_stoch()[source]

Packing then unpacking a latent recovers the deterministic and stochastic parts.

Purpose: Validates the flat-latent <-> RSSM-state bridge is lossless for categorical stoch.

Given: A batch of deterministic vectors and categorical (2-D per row) stochastic tensors. When: They are packed into a flat latent and unpacked with the same dimensions. Then: The recovered deter and stoch equal the originals with the expected latent width.

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_cardreamer_world_model.test_unpack_latents_promotes_single_vector_to_batch()[source]

A 1-D latent is treated as a batch of one before splitting.

Purpose: Validates unpacking accepts an unbatched latent vector.

Given: A single flat latent vector concatenating a 2-wide deter and a length-3 stoch. When: It is unpacked with those dimensions. Then: The result carries a leading batch axis of one and the correct split.

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_dreamer_model_pomdp module

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp module

Tests for the kinematic CARLA generative model’s ego transition.

Covers KinematicCarlaModelPOMDP replacing the factored model’s identity transition with a real bicycle propagation: throttle produces forward motion, brake does not, and the batched transition matches the single-sample one. All tests run on hand-built state arrays with no CARLA server.

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_batch_transition_matches_single_sample()[source]

The batched transition equals the per-particle single transition.

Purpose: Validates sample_next_state_batch is consistent with sample_next_state.

Given: A kinematic model and three distinct particles When: sample_next_state_batch and per-particle sample_next_state are compared Then: The batched result matches the stacked single-sample results

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_brake_from_rest_keeps_ego_stationary()[source]

Braking from rest leaves the ego at rest.

Purpose: Validates the transition does not manufacture motion under brake.

Given: A kinematic model and an ego at rest When: sample_next_state is called with the brake preset Then: Velocity and position remain zero

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_is_terminal_false_for_agent_behind_or_far_or_beside()[source]

Agents behind, far ahead, or in an adjacent lane are not collisions.

Purpose: Validates the collision box excludes non-threatening agent positions.

Given: A kinematic model with default collision_gap/collision_halfwidth When: is_terminal is queried for agents behind, beyond the gap, and laterally offset Then: It returns False for every non-colliding placement

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_is_terminal_false_when_slot_absent()[source]

An empty agent slot at the collision position is ignored.

Purpose: Validates only present agents trigger the terminal collision.

Given: A kinematic model and a state whose agent slot carries a pose but present == 0 When: is_terminal is queried Then: It returns False because the slot is not marked present

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_is_terminal_true_for_agent_directly_ahead()[source]

A present agent within the forward collision box makes the state terminal.

Purpose: Validates the kinematic model foresees a collision with a lead vehicle.

Given: A kinematic model and a state with one present agent 2 m directly ahead When: is_terminal is queried Then: It returns True so the reward applies the terminal collision penalty

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_moving_ego_decelerates_under_brake()[source]

Brake reduces the speed of a moving ego.

Purpose: Validates the longitudinal brake deceleration term.

Given: A kinematic model and an ego moving forward at 10 m/s When: sample_next_state is called with the brake preset Then: The resulting longitudinal velocity is lower than the initial speed

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_multiple_samples_return_stacked_copies()[source]

Requesting several next states returns a stacked array of the propagation.

Purpose: Validates the n_samples>1 convention of the kinematic transition.

Given: A kinematic model and a resting ego When: sample_next_state is called with n_samples=4 Then: A (4, width) array is returned whose rows all equal the single propagation

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_reward_applies_collision_penalty_on_predicted_collision()[source]

The inherited reward charges the collision penalty on a terminal state.

Purpose: Validates is_terminal feeds the reward’s terminal collision term.

Given: A kinematic model and a state with an agent inside the forward collision box When: reward is evaluated with that state as the resulting next_state Then: The reward is lower than for the same state with no agent present

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_model_pomdp.test_throttle_from_rest_produces_forward_velocity()[source]

Throttle accelerates the resting ego forward.

Purpose: Validates the kinematic transition converts throttle into speed.

Given: A kinematic model and an ego at rest When: sample_next_state is called with the throttle preset Then: The resulting longitudinal velocity and position advance beyond zero

Test type: unit

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_kinematic_vectorized_model module

POMDPPlanners.tests.test_environments.test_carla_pomdp.test_carla_generative_models.test_carla_model_pomdp module