140 lines
5.2 KiB
Plaintext
140 lines
5.2 KiB
Plaintext
These are all the APIs you can use.
|
|
|
|
Drone Management
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/drones` | List all drones |
|
|
| POST | `/drones` | Register new drone |
|
|
| GET | `/drones/{{id}}` | Get drone details |
|
|
| PUT | `/drones/{{id}}` | Update drone properties (metadata, state, battery, position, home) |
|
|
| PUT | `/drones/{{id}}/position` | Update drone position only |
|
|
| DELETE | `/drones/{{id}}` | Delete drone |
|
|
| POST | `/drones/{{id}}/battery` | Update battery level |
|
|
|
|
Command Management
|
|
|
|
Generic Command Endpoint
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| POST | `/drones/{{id}}/command` | Send any command |
|
|
| GET | `/drones/{{id}}/commands` | Get command history |
|
|
| GET | `/commands/{{command_id}}` | Get command status |
|
|
|
|
Direct Command Endpoints
|
|
|
|
All commands use **POST** method with `/drones/{{id}}/command/{{command_name}}`
|
|
|
|
Charge can only done at Waypoint target.
|
|
|
|
| Command | Parameters | Description |
|
|
|---------|-----------|-------------|
|
|
| `take_off` | `?altitude=10.0` | Takeoff to altitude |
|
|
| `land` | - | Land at position |
|
|
| `move_to` | `?x=50&y=50&z=15` | Move to coordinates |
|
|
| `move_towards` | `?distance=20&heading=90` | Move distance in direction (uses current heading if not specified) |
|
|
| `move_along_path` | Body: `{{waypoints:[...]}}` | Follow waypoints |
|
|
| `change_altitude` | `?altitude=20.0` | Change altitude only |
|
|
| `hover` | `duration` (optional) | Hold position |
|
|
| `rotate` | `?heading=180.0` | Change heading/orientation |
|
|
| `return_home` | - | Return to launch |
|
|
| `set_home` | - | Set home position |
|
|
| `calibrate` | - | Calibrate sensors |
|
|
| `take_photo` | - | Capture image |
|
|
| `send_message` | `?target_drone_id=X&message=Y` | Send to drone |
|
|
| `broadcast` | `?message=text` | Send to all |
|
|
| `charge` | `?charge_amount=30.0` | Charge battery |
|
|
|
|
Target Management
|
|
|
|
Type of target we have fixed, moving, waypoint, circle, polygon. - Note: fixed type can also represent points of interest
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/targets` | List all targets |
|
|
| GET | `/targets/{{id}}` | Get target details |
|
|
| GET | `/targets/type/{{type}}` | Get by type |
|
|
|
|
Waypoint Endpoints
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/targets/waypoints` | List charging stations |
|
|
| POST | `/targets/waypoints/{{id}}/check-drone` | Check if drone at waypoint |
|
|
| GET | `/targets/waypoints/nearest` | Find nearest waypoint |
|
|
|
|
Obstacle Management
|
|
|
|
Type of obstacle we hvave point, circle, ellipse, polygon.
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/obstacles` | List all obstacles |
|
|
| GET | `/obstacles/{{id}}` | Get obstacle |
|
|
| GET | `/obstacles/type/{{type}}` | Get by type |
|
|
|
|
Collision Detection
|
|
|
|
**Endpoint:** `POST /obstacles/path_collision`
|
|
|
|
**Authentication:** Requires SYSTEM role (ADMIN inherits)
|
|
|
|
**Description:** Checks if a flight path from start to end collides with any obstacles. Returns the **first** obstacle that collides with the path.
|
|
|
|
**Parameters:**
|
|
|
|
| Name | Type | Required | Description |
|
|
|------|------|----------|-------------|
|
|
| start | object | Yes | Start point {{x, y, z}} |
|
|
| end | object | Yes | End point {{x, y, z}} |
|
|
| safety_margin | float | No | Additional clearance distance (in meters) around the flight path (default: 0.0). Creates a corridor with specified width on each side. Use 0.0 for direct line path, or > 0.0 for safety corridor (e.g., 5.0 creates a 10m-wide corridor). Note: Drone movement commands use 0.0 by default |
|
|
|
|
**Height Logic:**
|
|
- `height = 0`: Impassable at any altitude
|
|
- `height > 0`: Collision only if max flight altitude <= obstacle.height
|
|
|
|
**Response:** Collision response object or null if no collision
|
|
|
|
**Example Request:**
|
|
```bash
|
|
curl -X POST http://localhost:8000/obstacles/path_collision \\
|
|
-H "Content-Type: application/json" \\
|
|
-H "X-API-Key: system_secret_key_change_in_production" \\
|
|
-d '{{
|
|
"start": {{"x": 0.0, "y": 0.0, "z": 10.0}},
|
|
"end": {{"x": 200.0, "y": 300.0, "z": 10.0}},
|
|
"safety_margin": 2.0
|
|
}}'
|
|
```
|
|
|
|
**Example Response (Collision):**
|
|
```json
|
|
{{
|
|
"obstacle_id": "550e8400-e29b-41d4-a716-446655440001",
|
|
"obstacle_name": "Water Tower",
|
|
"obstacle_type": "circle",
|
|
"collision_type": "path_intersection",
|
|
"distance": 5.0
|
|
}}
|
|
```
|
|
|
|
**Example Response (No Collision):**
|
|
```json
|
|
null
|
|
```
|
|
|
|
| Method | Endpoint | Description | Auth |
|
|
|--------|----------|-------------|------|
|
|
| POST | `/obstacles/path_collision` | Check if flight path collides with obstacles | SYSTEM |
|
|
| POST | `/obstacles/point_collision` | Check if point is inside any obstacles (returns all matches) | SYSTEM |
|
|
|
|
Proximity
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/drones/{{id}}/nearby` | Aggregated nearby drones, targets, obstacles (uses drone's perceived_radius) |
|
|
| GET | `/drones/{{id}}/nearby/drones` | Nearby drones (uses drone's perceived_radius) |
|
|
| GET | `/drones/{{id}}/nearby/targets` | Nearby targets (uses drone's perceived_radius) |
|
|
| GET | `/drones/{{id}}/nearby/obstacles` | Nearby obstacles (uses drone's perceived_radius) |
|
|
All proximity endpoints use the drone's `perceived_radius` to determine the search area. |