Skip to content

LidarObservation Warning - divide by zero #655

@Rock3Yu

Description

@Rock3Yu

I face the same problem again. Observation: Lidar, Env: parking-v0

version:

Name: highway-env
Version: 1.10.1

I change the env config of parking-v0 with only observation and vehicles_count=0/3/10:

config["observation"] = {
    "type": "LidarObservation",
    "cells": 128,
    "maximum_range": 64,
    "normalise": True,
}

It will only happen when obs=lidar. I tested obs=default/GrayscaleObservation, both are good. (use stable_baselines3)

The UserWarning/RuntimeWarning is like:

/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/gymnasium/utils/passive_env_checker.py:134: UserWarning: WARN: The obs returned by the `reset()` method was expecting numpy array dtype to be float32, actual type: float64
  logger.warn(
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/gymnasium/utils/passive_env_checker.py:158: UserWarning: WARN: The obs returned by the `reset()` method is not within the observation space.
  logger.warn(f"{pre} is not within the observation space.")
Using cpu device
Wrapping the env with a `Monitor` wrapper
Wrapping the env in a DummyVecEnv.
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]
Logging to ./tensorboard_logs/lidar_PPO_empty/PPO_1
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/gymnasium/utils/passive_env_checker.py:134: UserWarning: WARN: The obs returned by the `step()` method was expecting numpy array dtype to be float32, actual type: float64
  logger.warn(
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/gymnasium/utils/passive_env_checker.py:158: UserWarning: WARN: The obs returned by the `step()` method is not within the observation space.
  logger.warn(f"{pre} is not within the observation space.")
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]
/opt/anaconda3/envs/yu/lib/python3.9/site-packages/highway_env/utils.py:403: RuntimeWarning: divide by zero encountered in scalar divide
  interval_2 = [(a - r) @ v / rqv, (d - r) @ v / rqv]

Originally posted by @Rock3Yu in #650 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions