Open Agriculture Foundation

Logo

OpenAg informational website

View GitHub Profile

Fixtures

can be configured with different sensors, actuators and control loops using fixtures. This can be used to customize the software for the or, in future, the Food Server.

Fixtures for are written as JSON files. These files are loaded into the database when starts.

Default fixtures

ships with some useful default fixtures. They can be found in https://github.com/OpenAgInitiative/openag_brain/tree/master/fixtures.

Starting openag_brain with fixtures

You can start with a specific set of fixtures. Note this is typically taken care of for you by Docker, so this is mostly useful when developing or customizing the .

Starting openag_brain with the default fixture:

rosrun openag_brain main -f default

Starting openag_brain with a custom fixture:

rosrun openag_brain main -F ~/path_to_my_fixture.json

Loading fixtures

You can also load fixtures any time CouchDB is running using the openag_brain command line tool. To load a default fixture from :

rosrun openag_brain load_fixture [fixture_name]

For example to load fixture default:

rosrun openag_brain load_fixture default

(Note: you’ll need to activate the ROS workspace before you can use rosrun commands.)

To load a fixture file at its path, you can use the openag_python command line tools:

openag db load_fixture ~/path/to/my_fixture.json

Fixture schema

Default configurations for the database can be created with *fixtures*. Fixtures are JSON documents that describe records that should be added to the database.

You can find the default JSON fixtures in https://github.com/OpenAgInitiative/openag_brain/tree/master/fixtures.

Fixtures follow the format::

{
  database_name: [
    {
      _id: 'couchdb_doc_1',
      ...
    }
  ]
}

Where each key in the top level object is the name of a Couch database and each object in the array is a Couch document.

Firmware Module Fixtures

One place where fixtures come in handy is configuring a firmware module setup for a particular Food Computer or Food Server model. Let’s look at an example firmware_module database fixture:

{
  "firmware_module": [
    {
      "_id": "dht22_1",
      "type": "dht22",
      "environment": "environment_1",
      "arguments": [5],
      "outputs": {
        "air_temperature": {"variable": "air_temperature"},
        "air_humidity": {"variable": "air_humidity"}
      }
    }
  ]
}

firmware_module is the database we’re creating a fixture for. Within it is a list of JSON documents.

Default values for arguments, outputs and inputs can be configured for each firmware type in the firmware_module_type database, so you don’t always have to specify all of these to configure a module.

Firmware Type Fixtures

The firmware_module_type database describes module types installed and supported by the system. It acts as a package manager and glue layer for the C++ firmware code that is flashed on to the Arduino.

Let’s look at an example firmware_module_type database fixture:

{
  "firmware_module_type": [
    {
      "_id": "atlas_do",
      "repository": {
        "type": "git",
        "url": "https://github.com/OpenAgInitiative/openag_atlas_do.git"
      },
      "description": "",
      "header_file": "openag_atlas_do.h",
      "class_name": "AtlasDo",
      "arguments": [
        {
          "name": "i2c_address",
          "type": "int",
          "default": 97
        }
      ],
      "inputs": {
        "atmospheric_calibration": {
          "type": "std_msgs/Empty",
          "categories": ["calibration"]
        },
        "zero_calibration": {
          "type": "std_msgs/Empty",
          "categories": ["calibration"]
        }
      },
      "outputs": {
        "water_dissolved_oxygen": {
          "type": "std_msgs/Float32"
        }
      },
      "dependencies": [
        {"type": "git", "url": "https://github.com/OpenAgInitiative/openag_firmware_module.git"}
      ]
    }
  ]
}

Let’s go over these fields: