Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sensor Log Processor

This Code Was Written as part of the Treex Robotics home assignment. This code reads a robot telemetry log file by streaming and prints a per-sensor report (count, min, max, mean and gap count).

Build

cmake -S . -B build
cmake --build build

Run

./build/sensor_log_processor <log_file> [gap_threshold_ms]
  • gap_threshold_ms is optional and defaults to 500ms.

Example:

./build/sensor_log_processor sample_log.txt
./build/sensor_log_processor sample_log.txt 1000

Design choices

  • The file is processed one line at a time, so memory use stays constant regardless of log size. (as request)
  • Per-sensor stats (min/max/mean/gap count) are kept in a running SensorInfo accumulator per sensor id, updated incrementally rather than storing every reading.
  • A Record object is used to parse ea lines in to log file into the relevant details.
  • A line is malformed if it doesn't split into exactly 3 whitespace-separated tokens, or if the timestamp/value fields aren't parseable as a number. Malformed lines are counted and skipped rather than stopping the run. (as requested)
  • Gap detection compares each reading's timestamp to that sensor's previous timestamp; the first reading for a sensor has no previous timestamp, so it's never counted as a gap (tracked with a -1 sentinel rather than 0, since 0 is a valid timestamp).

What I'd improve with more time

  1. Validate each line regarding (range, type, continuous etc..)
    • for example timestamps are in ascending order per sensor
    • list of validate sensors
    • sensor range (non negative values)
  2. Handle missing file / unable to open file error
  3. Log malformed lines

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages