OpenAg Wiki Archive

Archived Contents from the original OpenAg Wiki (snapshot on Apr 8, 2020)

The archived wiki only includes information up the v3.0 version of the PFC-EDU, and is here for preservation purposes. You can find resources about the latest version of the PFC v4.0 on the Personal Food Computer resources page.

Overview

The OpenAg REST API comes in 2 parts:

  1. The CouchDB API for interacting with data stored in CouchDB
    1. Special design documents provide some useful features on top of the default Couch API.
  2. The ROS API for interacting with openag_brain

For useful API formulas, see the API Cookbook.

Database API

Since the food_computer_2 database runs on CouchDB, all standard CouchDB REST endpoints are available. See CouchDB API for more.

ROS REST API

You can interact with the Food Computer ROS system via HTTP using a REST API. This API is proxied by CouchDB and available at:

http://<Food Computer IP>:5984/_openag/api/0.0.1/

param

GET /api/0.0.1/param

GET a list of all available params from the ROS Parameter Server. See Parameter Server for more on the Parameter Server.

Parameter names are listed in the “results” field of the JSON response body.

GET /api/0.0.1/param/<param_name>

GET the value for a specific parameter at param_name in the ROS Parameter Server.

Parameter value is in the “result” field of the JSON response body. If parameter does not exist, a JSON document with ERROR field will be returned.

POST /api/0.0.1/param/<param_name>

POST /api/0.0.1/param/<param_name> {"value": "x"}

POST to the ROS Parameter Server. Value should be in the value field of the request body.

service

GET /api/0.0.1/service

GET a list of all available ROS services.

Services are listed in the “results” field of the JSON response body.

GET /api/0.0.1/service/<service_name>

GET information about a ROS service.

POST /api/0.0.1/service/<service_name>

POST to a service to change it somehow. service_name may be a path.

For example, to start an environmental recipe in an environment, use the start_recipe service:

POST /api/0.0.1/service/<environment_id>/start_recipe {"recipe_id": <id>}

topic

GET /api/0.0.1/topic

GET the list of published ROS topics.

GET /api/0.0.1/topic/<topic_name>

GET info from a ROS topic.

Returns a JSON response with the following fields (or error):

{
    "type": "...",   // topic type, \n
    "subs": [...],   // a list of subscribers \n
    "pubs": [...]    // a list of publishers \n
}

POST /api/0.0.1/topic/<topic_name>

POST a message to a ROS topic by name.

Requires a JSON payload of shape: [x, y, z]. The values of the JSON array must match the argument types of the topic’s type constructor.

topic_stream

GET /api/0.0.1/topic_stream/<topic_name>

Stream a topic over HTTP by keeping the http connection alive.

node

GET /api/0.0.1/node

List all active ROS nodes.

GET /api/0.0.1/node/<node_name>

Get information about a ROS node.