Skip to main content

Go to target

This endpoint sends a "Go to" command to the drone to navigate to a specific point.

When accepted, the drone will fly to the specified coordinates.

 POST /api/1.0/drone/{droneId}/goTo
tip

Remember to subscribe to the status_message topic to receive feedback from pilot accept/reject decisions or drone messages.

Body

The expected body is a stringified JSON with the following keys:

{
latitude: number, // Latitude of the target point in decimal degrees
longitude: number, // Longitude of the target point in decimal degrees
altitude: number, // Altitude of the target point in meters above sea level
token?: string // (Optional) Validation token from a previous go to command
}

Response

The command will return a status message indicating that the command is pending pilot approval, or a rejection depending on certain validations:

caution

The system performs the following checks and will throw errors if they fail:

  • Minimum clearance of 20m
  • Target position is within the allowed geofence

The system will also return a validation token that can be used to send subsequent go to commands without pilot approval. This token will expire if another go to command is accepted, when the drone changes its mode by an operator, or after one hour.

{
"status": "Command received, pending for pilot approval",
"token": "<validation_token>"
}

Example

const fetchData = async () => {
let response;
try {
const serverResponse = await fetch(`https://cloud.rigi.tech/api/1.0/drone/41/goTo`, {
mode: "cors",
method: "POST",
referrer: "no-referrer",
headers: {"authorization": "Bearer " + token},
body: JSON.stringify({
latitude: 40.4168,
longitude: -3.7038,
altitude: 100,
token: "<validation_token>"
}),
});

if (!serverResponse.ok) {
switch (serverResponse.status) {
case 400:
response = await serverResponse.json();
break;
case 403:
response = { message: "Forbidden access to data" };
break;
case 404:
response = { message: "Address not found" };
break;
default:
response = await serverResponse.json();
}
} else {
response = await serverResponse.json();
}

console.debug(response);
} catch (e) {
console.debug("Error fetching data:", e);
}
}
fetchData();