Skip to content

API Documentation

Khoi edited this page May 15, 2023 · 11 revisions

For Vehicles

Vehicle Data

  • GET /api/vehicleData/<vehicle> - Retrieve crucial information for each vehicle (i.e., waypoints, manual mode status, current stage ID, etc.)
  • POST /api/vehicleData/<vehicle>?db_type=vehicles - Send vehicle data to GCS to be updated
## EXAMPLE IN PYTHON

# FOR GROUND VEHICLES (i.e., ERU) ********************************************************** #
eru_data = {
  "lastUpdateTime": "2022-01-01 00:00:00",
  "speed": 0.0,
  "batteryLife": 0.0,
  "sensorOk": False,
  "latestCoordinates": {
    "lat": 0.0,
    "lng": 0.0
  }
}
# Make sure you specify the `db_type` as `vehicles` in your query string
response = requests.post("http://127.0.0.1:5000/api/vehicleData/ERU?db_type=vehicles", json=eru_data)

# Retrieve the status code of response, mainly to check whether request is successful or not
# 200 = success; 400 = client error; 500 == API error
print(response.status_code)



# FOR AIR VEHICLES (i.e., MAC, MEA) ******************************************************** #
mac_data = {
  "lastUpdateTime": "2022-01-01 00:00:00",
  "altitude": 0.0,
  "speed": 0.0,
  "pitch": 0.0,
  "roll": 0.0,
  "yaw": 0.0,
  "batteryLife": 0.0,
  "sensorOk": false,
  "latestCoordinates": {
    "lat": 0.0,
    "lng": 0.0
  }
}
# Make sure you specify the `db_type` as `vehicles` in your query string
response = requests.post("http://127.0.0.1:5000/api/vehicleData/MAC?db_type=vehicles", json=mac_data)

# Retrieve the status code of response, mainly to check whether request is successful or not
# 200 = success; 400 = client error; 500 = API server error
print(response.status_code)

GeoFence / Keep-in Zones

  • GET /api/geofence - Receive keep-in/keep-out geofence coordinates from GCS
// SAMPLE RESPONSE BODY (array of geofence objects are sorted chornologically)
[
  {
    "coordinates": [
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      }
    ],
    "isKeepIn": true,
    "timeCreated": "10:00:00"
  },
  {
    "coordinates": [
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      }
    ],
    "isKeepIn": false,
    "timeCreated": "10:01:43"
  },
  {
    "coordinates": [
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      },
      {
        "lat": 0.0,
        "lng": 0.0
      }
    ],
    "isKeepIn": true,
    "timeCreated": "20:00:00"
  },
]

Search Area

  • GET /api/searchArea - Receive the search area coordinates from GCS
// SAMPLE RESPONSE BODY
{
  "coordinates": [
    {
      "lat": 0,
      "lng": 0
    },
    {
      "lat": 0,
      "lng": 0
    },
    {
      "lat": 0,
      "lng": 0
    }
  ]
}

For Frontend Client

ingnore this section for now

GeoFence

  • GET /getGeofence/<vehicle_name> - Return current GeoFence coordinates of the according vehicle

  • POST /postGeofence/<vehicle_name> - Update current GeoFence coordinates of the according vehicle

// POST request body format:
// NOTE: Geofence is an array of objects that each represents a single polygon. 
// NOTE: Each polygon is composed of the boolean 'Keep_in' and an array that can contain any number of coordinates.
{
  "geofence": [
    {
      "coordinates": [
        {
          "lat": 0.0,
          "lng": 0.0
        },
        {
          "lat": 0.0,
          "lng": 0.0
        },
        {
          "lat": 0.0,
          "lng": 0.0
        },
      ],
      "keep_in": true
    },
    {
      "coordinates": [
        {
          "lat": 0.0,
          "lng": 0.0
        },
        {
          "lat": 0.0,
          "lng": 0.0
        },
        {
          "lat": 0.0,
          "lng": 0.0
        },
      ],
      "keep_in": true
    }
  ]
}

Mission Waypoint

  • GET /getMissionWaypoint/<vehicle_name> - Return current mission waypoint coordinates of the according vehicle

Search Area

  • GET /getSearchArea - Return the current set of coordinates of the search area

  • POST /postSearchArea - Update the current set of coordinates of the search area.

// POST request body format:
{
  "search_area": [
    {
      "lat": 0,
      "lng": 0
    },
    {
      "lat": 0,
      "lng": 0
    },
    {
      "lat": 0,
      "lng": 0
    }
  ]
}