Package com.studica.frc

## Class LidarMini

- java.lang.Object
- - com.studica.frc.LidarMini

    public class LidarMini
    extends java.lang.Object

Java driver for the T-mini Plus 360Â° laser range scanner.

### Nested Class Summary

Nested Classes
`static class` `LidarMini.LidarHealth` Device health status.
`static class` `LidarMini.LidarInfo` Device information.
`static class` `LidarMini.Port` Physical USB port location
`static class` `LidarMini.ScanData` A single completed 360Â° scan from the T-mini Plus.

### Field Summary

Fields
`static float` `FREQ_DEFAULT_HZ` Factory default scan frequency: 6 Hz.
`static float` `FREQ_MAX_HZ` Maximum scan frequency permitted by the T-mini Plus hardware: 12 Hz.
`static float` `FREQ_MIN_HZ` Minimum scan frequency permitted by the T-mini Plus hardware: 6 Hz.

### Constructor Summary

Constructors
`LidarMini​(LidarMini.Port port)` Creates a LidarMini instance, opens the serial port, and performs a brief scan-start â†’ stop wake sequence to bring the T-mini Plus into a responsive idle state.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `decreaseFrequencyHz()` Decreases the scan frequency by 1 Hz.
`void` `decreaseFrequencyTenthHz()` Decreases the scan frequency by 0.1 Hz.
`void` `destroy()` Stops scanning (if active) and closes the serial port.
`float` `getCurrentFrequency()` Returns the current scan frequency as tracked by this driver instance.
`LidarMini.ScanData` `getData()` Returns a snapshot of the last completed 360Â° scan.
`LidarMini.LidarHealth` `getHealth()` Queries the T-mini Plus health status.
`LidarMini.LidarInfo` `getInfo()` Queries the T-mini Plus for its model, firmware version, hardware version, and factory serial number.
`void` `increaseFrequencyHz()` Increases the scan frequency by 1 Hz.
`void` `increaseFrequencyTenthHz()` Increases the scan frequency by 0.1 Hz.
`void` `start()` Sends the scan-start command to the T-mini Plus and launches the background packet-parsing thread.
`void` `stop()` Sends the stop command to the T-mini Plus and shuts down the background thread.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### FREQ_MIN_HZ

    public static final float FREQ_MIN_HZ

Minimum scan frequency permitted by the T-mini Plus hardware: 6 Hz.

See Also:
  Constant Field Values

#### FREQ_MAX_HZ

    public static final float FREQ_MAX_HZ

Maximum scan frequency permitted by the T-mini Plus hardware: 12 Hz.

See Also:
  Constant Field Values

#### FREQ_DEFAULT_HZ

    public static final float FREQ_DEFAULT_HZ

Factory default scan frequency: 6 Hz.

See Also:
  Constant Field Values

### Constructor Detail

#### LidarMini

    public LidarMini​(LidarMini.Port port)

Creates a LidarMini instance, opens the serial port, and performs a brief scan-start â†’ stop wake sequence to bring the T-mini Plus into a responsive idle state.

The wake sequence takes approximately 250 ms. After the constructor returns, `getInfo()` and `getHealth()` are safe to call immediately. Call `start()` when ready to begin scanning.

Parameters:
  `port` - USB port the T-mini Plus is connected to

### Method Detail

#### start

    public void start()

Sends the scan-start command to the T-mini Plus and launches the background packet-parsing thread.

Call `getInfo()` / `getHealth()` before calling this method, as those commands cannot be issued while the device is scanning.

#### stop

    public void stop()

Sends the stop command to the T-mini Plus and shuts down the background thread. The serial port remains open; call `start()` to resume scanning.

#### destroy

    public void destroy()

Stops scanning (if active) and closes the serial port. The object should not be used after this call.

#### increaseFrequencyHz

    public void increaseFrequencyHz()

Increases the scan frequency by 1 Hz.

Must be called while the device is not scanning (call `stop()` first if necessary).

Clamped to the datasheet maximum of 12.0f Hz â€” prints a warning and takes no action if the step would exceed that limit.

Example: current frequency 9 Hz â†’ becomes 10 Hz.

#### increaseFrequencyTenthHz

    public void increaseFrequencyTenthHz()

Increases the scan frequency by 0.1 Hz.

Must be called while the device is not scanning (call `stop()` first if necessary).

Clamped to the datasheet maximum of 12.0f Hz â€” prints a warning and takes no action if the step would exceed that limit.

Example: current frequency 9.0 Hz â†’ becomes 9.1 Hz.

#### decreaseFrequencyHz

    public void decreaseFrequencyHz()

Decreases the scan frequency by 1 Hz.

Must be called while the device is not scanning (call `stop()` first if necessary).

Clamped to the datasheet minimum of 6.0f Hz â€” prints a warning and takes no action if the step would go below that limit.

Example: current frequency 9 Hz â†’ becomes 8 Hz.

#### decreaseFrequencyTenthHz

    public void decreaseFrequencyTenthHz()

Decreases the scan frequency by 0.1 Hz.

Must be called while the device is not scanning (call `stop()` first if necessary).

Clamped to the datasheet minimum of 6.0f Hz â€” prints a warning and takes no action if the step would go below that limit.

Example: current frequency 9.0 Hz â†’ becomes 8.9 Hz.

#### getCurrentFrequency

    public float getCurrentFrequency()

Returns the current scan frequency as tracked by this driver instance. Reflects all changes made via `increaseFrequencyHz()`, `increaseFrequencyTenthHz()`, `decreaseFrequencyHz()`, and `decreaseFrequencyTenthHz()` since construction.

Returns:
  current scan frequency in Hz

#### getInfo

    public LidarMini.LidarInfo getInfo()

Queries the T-mini Plus for its model, firmware version, hardware version, and factory serial number.

Must be called before `start()`. Sending this command while the device is in scan mode will corrupt the data stream.

Returns:
  a `LidarMini.LidarInfo` populated with device information, or a zeroed struct if communication failed

#### getHealth

    public LidarMini.LidarHealth getHealth()

Queries the T-mini Plus health status.

Must be called before `start()`. Check `LidarMini.LidarHealth.isHealthy()` before beginning a scanning session. Real-time health updates are also embedded in the point-cloud stream during scanning (parsed automatically by the driver).

Returns:
  a `LidarMini.LidarHealth` with per-module status flags, or a zeroed struct if communication failed

#### getData

    public LidarMini.ScanData getData()

Returns a snapshot of the last completed 360Â° scan.

This method is thread-safe and non-blocking. It returns an empty `LidarMini.ScanData` (with `LidarMini.ScanData.size()` == 0) if the first full lap has not yet completed since `start()` was called.

Call this method periodically (e.g. every robot loop iteration). The underlying driver replaces the completed buffer once per revolution, so calling more frequently than the scan rate returns the same data.

Returns:
  the most recent complete scan, never `null`