bool MissionFeasibilityChecker::checkMissionFeasible(int mavlink_fd, bool isRotarywing,
	dm_item_t dm_current, size_t nMissionItems, Geofence &geofence,
	float home_alt, bool home_valid, double curr_lat, double curr_lon, float max_waypoint_distance, bool &warning_issued,
	float default_acceptance_rad,
	bool condition_landed)
{
	bool failed = false;
	bool warned = false;
	/* Init if not done yet */
	init();

	_mavlink_fd = mavlink_fd;

	// first check if we have a valid position
	if (!home_valid /* can later use global / local pos for finer granularity */) {
		failed = true;
		warned = true;
		mavlink_log_info(_mavlink_fd, "Not yet ready for mission, no position lock.");
	} else {
		failed = failed || !check_dist_1wp(dm_current, nMissionItems, curr_lat, curr_lon, max_waypoint_distance, warning_issued);
	}

	// check if all mission item commands are supported
	failed = failed || !checkMissionItemValidity(dm_current, nMissionItems, condition_landed);
	failed = failed || !checkGeofence(dm_current, nMissionItems, geofence);
	failed = failed || !checkHomePositionAltitude(dm_current, nMissionItems, home_alt, home_valid, warned);

	if (isRotarywing) {
		failed = failed || !checkMissionFeasibleRotarywing(dm_current, nMissionItems, geofence, home_alt, home_valid, default_acceptance_rad);
	} else {
		failed = failed || !checkMissionFeasibleFixedwing(dm_current, nMissionItems, geofence, home_alt, home_valid);
	}

	return !failed;
}
bool MissionFeasibilityChecker::checkMissionFeasible(bool isRotarywing, dm_item_t dm_current, size_t nMissionItems, Geofence &geofence, float home_alt)
{
	/* Init if not done yet */
	init();

	/* Open mavlink fd */
	if (_mavlink_fd < 0) {
		/* try to open the mavlink log device every once in a while */
		_mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
	}


	if (isRotarywing)
		return checkMissionFeasibleRotarywing(dm_current, nMissionItems, geofence, home_alt);
	else
		return checkMissionFeasibleFixedwing(dm_current, nMissionItems, geofence, home_alt);
}
bool MissionFeasibilityChecker::checkMissionFeasible(bool isRotarywing, dm_item_t dm_current, size_t nMissionItems, Geofence &geofence, float home_alt)
{
	bool failed = false;
	/* Init if not done yet */
	init();

	/* Open mavlink fd */
	if (_mavlink_fd < 0) {
		/* try to open the mavlink log device every once in a while */
		_mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
	}

	// check if all mission item commands are supported
	failed |= !checkMissionItemValidity(dm_current, nMissionItems);


	if (isRotarywing)
		failed |= !checkMissionFeasibleRotarywing(dm_current, nMissionItems, geofence, home_alt);
	else
		failed |= !checkMissionFeasibleFixedwing(dm_current, nMissionItems, geofence, home_alt);

	return !failed;
}