Validate go to target
This endpoint performs the validations for a previously sent go to command. These validations are the same as those executed for the go to command, but in this case it only tests the validations without executing the command.
POST /api/1.0/drone/{droneId}/validate_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
}
Response
The command will return a status message indicating that the target point is accepted, 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
{
"status": "rejected",
"errors": "The errors encountered during validation"
}
Example
const fetchData = async () => {
let response;
try {
const serverResponse = await fetch(`https://cloud.rigi.tech/api/1.0/drone/41/validate_goTo`, {
mode: "cors",
method: "POST",
referrer: "no-referrer",
headers: {"authorization": "Bearer " + token},
body: JSON.stringify({
latitude: 40.4168,
longitude: -3.7038,
altitude: 100,
}),
});
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();