# `BB.Message.Sensor.Range`
[🔗](https://github.com/beam-bots/bb/blob/main/lib/bb/message/sensor/range.ex#L5)

Single range reading from a distance sensor.

## Fields

- `radiation_type` - Type of radiation (`:ultrasound` or `:infrared`)
- `field_of_view` - Size of the arc that the sensor covers in radians
- `min_range` - Minimum range in metres
- `max_range` - Maximum range in metres
- `range` - Measured range in metres

Values less than min_range or greater than max_range should be discarded.
A range of `:infinity` indicates no object was detected.

## Examples

    alias BB.Message.Sensor.Range

    {:ok, msg} = Range.new(:ultrasonic_sensor,
      radiation_type: :ultrasound,
      field_of_view: 0.26,
      min_range: 0.02,
      max_range: 4.0,
      range: 1.5
    )

# `radiation_type`

```elixir
@type radiation_type() :: :ultrasound | :infrared
```

# `t`

```elixir
@type t() :: %BB.Message.Sensor.Range{
  field_of_view: float(),
  max_range: float(),
  min_range: float(),
  radiation_type: radiation_type(),
  range: float() | :infinity
}
```

# `new`

```elixir
@spec new(
  atom(),
  keyword()
) :: {:ok, BB.Message.t()} | {:error, term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
