modular-filter-examples

module
v0.0.0-...-791af7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2024 License: Apache-2.0

README

modular-filter-examples

Examples for creating modular components that filter data capture. This repo contains code for:

  • A modular camera that filters camera data capture, in both go (colorfilter directory) and python (pycolorfilter directory). Configuring data capture on this component only keeps the data captured on the underlying camera if the vision service detects a certain color in the captured image.
  • A modular sensor that that filters ultrasonic sensor capture, in go (sensorfilter directory). Configuring data capture on this component only keeps data captured on the underlying sensor if there is a significant change in distance readings.

Usage

Build binary
  • Navigate to example's module subdirectory (ex. for go color filter, cd colorfilter/module)
  • Run go build
Add to robot config

Color filter example:

{
  "modules": [
    {
      "executable_path": <path_to_binary_or_script>,
      "type": "local",
      "name": "colorfilter"
    }
  ],
  "components": [
    {
      "name": "actualcam",
      "type": "camera"
      ...
    },
    {
      "name": "colorfiltercam",
      "type": "camera",
      "model": "example:camera:colorfilter",
      "attributes": {
        "actual_cam": "actualcam",
        "vision_service": "my_color_detector"
      },
      "depends_on": [
        "actualcam",
        "my_color_detector"
      ],
      "service_configs": [
        {
          "type": "data_manager",
          "attributes": {
            "capture_methods": [
              {
                "method": "ReadImage",
                "additional_params": {
                  "mime_type": "image/jpeg"
                },
                "capture_frequency_hz": 1
              }
            ]
          }
        }
      ]
    }
  ],
  "services": [
    {
      "name": "dm",
      "type": "data_manager",
      "attributes": {
        "sync_interval_mins": 0.1,
        "capture_dir": "",
        "tags": [],
        "additional_sync_paths": []
      }
    },
    {
      "type": "vision",
      "attributes": {
        "hue_tolerance_pct": 0.03,
        "segment_size_px": 100,
        "detect_color": "#C6907A"
      },
      "model": "color_detector",
      "name": "my_color_detector"
    }
  ]
}

Sensor filter example:

{
  "modules": [
    {
      "executable_path": <path_to_binary>,
      "type": "local",
      "name": "sensorfilter"
    }
  ]
  "components": [
    {
      "name": "actual_sensor",
      "type": "sensor",
      "model": "ultrasonic",
      "attributes": { ... }
    },
    {
      "name": "filter_sensor",
      "type": "sensor",
      "model": "example:sensor:sensorfilter",
      "service_configs": [
        {
          "type": "data_manager",
          "attributes": {
            "capture_methods": [
              {
                "additional_params": {},
                "capture_frequency_hz": 1,
                "method": "Readings"
              }
            ]
          }
        }
      ],
      "attributes": {
        "actual_sensor": "actual_sensor"
      },
      "depends_on": [
        "actual_sensor"
      ]
    }
  ],
  "services": [
    {
      "type": "data_manager",
      "attributes": {
        "tags": [],
        "additional_sync_paths": [],
        "sync_interval_mins": 0.1,
        "capture_dir": ""
      },
      "name": "dm"
    }
  ]
}

Directories

Path Synopsis
Package colorfilter implements a modular camera that filters the output of an underlying camera and only keeps captured data if the vision service detects a certain color in the captured image.
Package colorfilter implements a modular camera that filters the output of an underlying camera and only keeps captured data if the vision service detects a certain color in the captured image.
module
Package main is a module which serves the colorfilter custom module.
Package main is a module which serves the colorfilter custom module.
Package sensorfilter implements a modular component that filters the output of an underlying ultrasonic sensor and only keeps captured data if there is a significant change in readings.
Package sensorfilter implements a modular component that filters the output of an underlying ultrasonic sensor and only keeps captured data if there is a significant change in readings.
module
Package main is a module which serves the sensorfilter custom module.
Package main is a module which serves the sensorfilter custom module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL