• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ check_failed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中check_failed函数的典型用法代码示例。如果您正苦于以下问题:C++ check_failed函数的具体用法?C++ check_failed怎么用?C++ check_failed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_failed函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: check_failed

// check we have required terrain data
bool AP_Arming_Copter::pre_arm_terrain_check(bool display_failure)
{
#if AP_TERRAIN_AVAILABLE && AC_TERRAIN
    // succeed if not using terrain data
    if (!copter.terrain_use()) {
        return true;
    }

    // check if terrain following is enabled, using a range finder but RTL_ALT is higher than rangefinder's max range
    // To-Do: modify RTL return path to fly at or above the RTL_ALT and remove this check

    if (copter.rangefinder_state.enabled && (copter.g.rtl_altitude > copter.rangefinder.max_distance_cm_orient(ROTATION_PITCH_270))) {
        check_failed(ARMING_CHECK_PARAMETERS, display_failure, "RTL_ALT above rangefinder max range");
        return false;
    }

    // show terrain statistics
    uint16_t terr_pending, terr_loaded;
    copter.terrain.get_statistics(terr_pending, terr_loaded);
    bool have_all_data = (terr_pending <= 0);
    if (!have_all_data) {
        check_failed(ARMING_CHECK_PARAMETERS, display_failure, "Waiting for Terrain data");
    }
    return have_all_data;
#else
    return true;
#endif
}
开发者ID:planckaero,项目名称:ardupilot,代码行数:29,代码来源:AP_Arming.cpp


示例2: rc

// perform pre-arm checks
//  return true if the checks pass successfully
bool AP_Arming_Copter::pre_arm_checks(bool display_failure)
{
    // exit immediately if already armed
    if (copter.motors->armed()) {
        return true;
    }

    // check if motor interlock and Emergency Stop aux switches are used
    // at the same time.  This cannot be allowed.
    if (rc().find_channel_for_option(RC_Channel::aux_func::MOTOR_INTERLOCK) &&
        rc().find_channel_for_option(RC_Channel::aux_func::MOTOR_ESTOP)){
        check_failed(ARMING_CHECK_NONE, display_failure, "Interlock/E-Stop Conflict");
        return false;
    }

    // check if motor interlock aux switch is in use
    // if it is, switch needs to be in disabled position to arm
    // otherwise exit immediately.  This check to be repeated,
    // as state can change at any time.
    if (copter.ap.using_interlock && copter.ap.motor_interlock_switch) {
        check_failed(ARMING_CHECK_NONE, display_failure, "Motor Interlock Enabled");
    }

    // succeed if pre arm checks are disabled
    if (checks_to_perform == ARMING_CHECK_NONE) {
        return true;
    }

    return fence_checks(display_failure)
        & parameter_checks(display_failure)
        & motor_checks(display_failure)
        & pilot_throttle_checks(display_failure) &
        AP_Arming::pre_arm_checks(display_failure);
}
开发者ID:planckaero,项目名称:ardupilot,代码行数:36,代码来源:AP_Arming.cpp


示例3: check_failed

bool AP_Arming::servo_checks(bool report) const
{
    bool check_passed = true;
    for (uint8_t i = 0; i < NUM_SERVO_CHANNELS; i++) {
        const SRV_Channel *c = SRV_Channels::srv_channel(i);
        if (c == nullptr || c->get_function() == SRV_Channel::k_none) {
            continue;
        }

        const uint16_t trim = c->get_trim();
        if (c->get_output_min() > trim) {
            check_failed(ARMING_CHECK_NONE, report, "SERVO%d minimum is greater than trim", i + 1);
            check_passed = false;
        }
        if (c->get_output_max() < trim) {
            check_failed(ARMING_CHECK_NONE, report, "SERVO%d maximum is less than trim", i + 1);
            check_passed = false;
        }
    }

#if HAL_WITH_IO_MCU
    if (!iomcu.healthy()) {
        check_failed(ARMING_CHECK_NONE, report, "IOMCU is unhealthy");
        check_passed = false;
    }
#endif

    return check_passed;
}
开发者ID:ArduPilot,项目名称:ardupilot,代码行数:29,代码来源:AP_Arming.cpp


示例4: check_failed

// performs pre_arm gps related checks and returns true if passed
bool AP_Arming_Rover::gps_checks(bool display_failure)
{
    if (!rover.control_mode->requires_position() && !rover.control_mode->requires_velocity()) {
        // we don't care!
        return true;
    }

    // check for ekf failsafe
    if (rover.failsafe.ekf) {
        check_failed(ARMING_CHECK_NONE, display_failure, "EKF failsafe");
        return false;
    }

    // ensure position esetimate is ok
    if (!rover.ekf_position_ok()) {
        const char *reason = AP::ahrs().prearm_failure_reason();
        if (reason == nullptr) {
            reason = "Need Position Estimate";
        }
        check_failed(ARMING_CHECK_NONE, display_failure, "%s", reason);
        return false;
    }

    // call parent gps checks
    return AP_Arming::gps_checks(display_failure);
}
开发者ID:KIrill-ka,项目名称:ardupilot,代码行数:27,代码来源:AP_Arming.cpp


示例5: rc

bool AP_Arming::rc_calibration_checks(bool report)
{
    bool check_passed = true;
    const uint8_t num_channels = RC_Channels::get_valid_channel_count();
    for (uint8_t i = 0; i < NUM_RC_CHANNELS; i++) {
        const RC_Channel *c = rc().channel(i);
        if (c == nullptr) {
            continue;
        }
        if (i >= num_channels && !(c->has_override())) {
            continue;
        }
        const uint16_t trim = c->get_radio_trim();
        if (c->get_radio_min() > trim) {
            check_failed(ARMING_CHECK_RC, report, "RC%d minimum is greater than trim", i + 1);
            check_passed = false;
        }
        if (c->get_radio_max() < trim) {
            check_failed(ARMING_CHECK_RC, report, "RC%d maximum is less than trim", i + 1);
            check_passed = false;
        }
    }

    return check_passed;
}
开发者ID:ArduPilot,项目名称:ardupilot,代码行数:25,代码来源:AP_Arming.cpp


示例6: check_failed

bool AP_Arming::gps_checks(bool report)
{
    const AP_GPS &gps = AP::gps();
    if ((checks_to_perform & ARMING_CHECK_ALL) || (checks_to_perform & ARMING_CHECK_GPS)) {

        //GPS OK?
        if (!AP::ahrs().home_is_set() ||
            gps.status() < AP_GPS::GPS_OK_FIX_3D) {
            check_failed(ARMING_CHECK_GPS, report, "Bad GPS Position");
            return false;
        }

        //GPS update rate acceptable
        if (!gps.is_healthy()) {
            check_failed(ARMING_CHECK_GPS, report, "GPS is not healthy");
            return false;
        }

        // check GPSs are within 50m of each other and that blending is healthy
        float distance_m;
        if (!gps.all_consistent(distance_m)) {
            check_failed(ARMING_CHECK_GPS, report, "GPS positions differ by %4.1fm",
                         (double)distance_m);
            return false;
        }
        if (!gps.blend_health_check()) {
            check_failed(ARMING_CHECK_GPS, report, "GPS blending unhealthy");
            return false;
        }

        // check AHRS and GPS are within 10m of each other
        Location gps_loc = gps.location();
        Location ahrs_loc;
        if (AP::ahrs().get_position(ahrs_loc)) {
            const float distance = location_diff(gps_loc, ahrs_loc).length();
            if (distance > AP_ARMING_AHRS_GPS_ERROR_MAX) {
                if (report) {
                    gcs().send_text(MAV_SEVERITY_CRITICAL, "PreArm: GPS and AHRS differ by %4.1fm", (double)distance);
                }
                return false;
            }
        }
    }

    if ((checks_to_perform & ARMING_CHECK_ALL) || (checks_to_perform & ARMING_CHECK_GPS_CONFIG)) {
        uint8_t first_unconfigured = gps.first_unconfigured_gps();
        if (first_unconfigured != AP_GPS::GPS_ALL_CONFIGURED) {
            if (report) {
                gcs().send_text(MAV_SEVERITY_CRITICAL,
                                                 "PreArm: GPS %d failing configuration checks",
                                                  first_unconfigured + 1);
                gps.broadcast_first_configuration_failure_reason();
            }
            return false;
        }
    }

    return true;
}
开发者ID:Javiercerna,项目名称:ardupilot,代码行数:59,代码来源:AP_Arming.cpp


示例7: brk_test

void brk_test()
{
        void *oldbrk1, *oldbrk2;
        const void *brk_failed = (void *) - 1;
        int len;
        unsigned int *tmp;
        unsigned int ii;

        (void) printf("-- brk test start\n");

        /* A length which is not a page multiple, yet a multiple of 8.
        */
        len = 8192 * 5 + 128;

        /* Try allocating some memory.
        */
        oldbrk1 = sbrk(len);
        if (oldbrk1 == brk_failed) {
                check_failed("sbrk alloc");
        }

        /* Try writing to the memory.
        */
        printf("writing to memory at %p\n", oldbrk1);
        tmp = (unsigned int *) oldbrk1;
        for (ii = 0; ii < (len / sizeof(int)); ii++)
                *tmp++ = ii;

        /* Try verifying what we wrote.
        */
        printf("verifying memory\n");
        tmp = (unsigned int *) oldbrk1;
        for (ii = 0; ii < (len / sizeof(int)); ii++) {
                if (*tmp++ != ii) {
                        (void) printf("verify failed at 0x%lx\n",
                                      (unsigned long) tmp);
                        exit(1);
                }
        }

        /* Try freeing the memory.
        */
        printf("freeing memory\n");
        oldbrk2 = sbrk(-len);
        if (oldbrk2 == brk_failed) {
                check_failed("sbrk dealloc");
        }

        /* oldbrk2 should be at least "len" greater than oldbrk1.
        */
        if ((unsigned long) oldbrk2 < ((unsigned long) oldbrk1 + len)) {
                (void) printf("sbrk didn't return old brk??\n");
                exit(1);
        }

        (void) printf("-- brk test passed\n");
}
开发者ID:Aliced3645,项目名称:os,代码行数:57,代码来源:stress.c


示例8: test_rmvol

/**
 * test_rmvol - test that UBI rmvol ioctl rejects bad input parameters.
 *
 * This function returns %0 if the test passed and %-1 if not.
 */
static int test_rmvol(void)
{
	int ret;
	struct ubi_mkvol_request req;
	const char *name = TESTNAME ":test_rmvol()";

	/* Bad vol_id */
	ret = ubi_rmvol(libubi, node, -1);
	if (check_failed(ret, EINVAL, "ubi_rmvol", "vol_id = -1"))
		return -1;

	ret = ubi_rmvol(libubi, node, dev_info.max_vol_count);
	if (check_failed(ret, EINVAL, "ubi_rmvol", "vol_id = %d",
			 dev_info.max_vol_count))
		return -1;

	/* Try to remove non-existing volume */
	ret = ubi_rmvol(libubi, node, 0);
	if (check_failed(ret, ENODEV, "ubi_rmvol",
			 "removed non-existing volume 0"))
		return -1;

	/* Try to remove volume twice */
	req.vol_id = UBI_VOL_NUM_AUTO;
	req.alignment = 1;
	req.bytes = dev_info.avail_bytes;
	req.vol_type = UBI_DYNAMIC_VOLUME;
	req.name = name;
	if (ubi_mkvol(libubi, node, &req)) {
		failed("ubi_mkvol");
		return -1;
	}

	if (ubi_rmvol(libubi, node, req.vol_id)) {
		failed("ubi_rmvol");
		return -1;
	}

	ret = ubi_rmvol(libubi, node, req.vol_id);
	if (check_failed(ret, ENODEV, "ubi_rmvol", "volume %d removed twice",
			 req.vol_id))
		return -1;

	return 0;
}
开发者ID:OpenNoah,项目名称:mtd-utils,代码行数:50,代码来源:mkvol_bad.c


示例9: assert_u32_less

static int assert_u32_less(u32 val1, u32 val2, const char *name)
{
	if (val1 >= val2) {
		check_failed("Assertion failed for '%s'. 0x%x >= 0x%x\n",
			name, (int)val1, (int)val2);
		//errors++;
		return 1;
	}
	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:10,代码来源:ntfsck.c


示例10: assert_u32_noteq

static int assert_u32_noteq(u32 val, u32 wrong, const char *name)
{
	if (val==wrong) {
		check_failed("Assertion failed for '%lld:%s'. should not be "
			"0x%x.\n", (long long)current_mft_record, name,
			(int)wrong);
		return 1;
	}
	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:10,代码来源:ntfsck.c


示例11: assert_u32_equal

/**
 * 0 success.
 * 1 fail.
 */
static int assert_u32_equal(u32 val, u32 ok, const char *name)
{
	if (val!=ok) {
		check_failed("Assertion failed for '%lld:%s'. should be 0x%x, "
			"was 0x%x.\n", (long long)current_mft_record, name,
			(int)ok, (int)val);
		//errors++;
		return 1;
	}
	return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:15,代码来源:ntfsck.c


示例12: check_failed

bool AP_Arming_Rover::pre_arm_checks(bool report)
{
    if (SRV_Channels::get_emergency_stop()) {
        check_failed(ARMING_CHECK_NONE, report, "Motors Emergency Stopped");
        return false;
    }

    return (AP_Arming::pre_arm_checks(report)
            & rover.g2.motors.pre_arm_check(report)
            & fence_checks(report)
            & proximity_check(report));
}
开发者ID:ArduPilot,项目名称:ardupilot,代码行数:12,代码来源:AP_Arming.cpp


示例13: check_failed

// perform pre_arm_rc_checks checks
bool AP_Arming_Rover::pre_arm_rc_checks(const bool display_failure)
{
    // set rc-checks to success if RC checks are disabled
    if ((checks_to_perform != ARMING_CHECK_ALL) && !(checks_to_perform & ARMING_CHECK_RC)) {
        return true;
    }

    const RC_Channel *channels[] = {
            rover.channel_steer,
            rover.channel_throttle,
    };
    const char *channel_names[] = {"Steer", "Throttle"};

    for (uint8_t i= 0 ; i < ARRAY_SIZE(channels); i++) {
        const RC_Channel *channel = channels[i];
        const char *channel_name = channel_names[i];
        // check if radio has been calibrated
        if (!channel->min_max_configured()) {
            check_failed(ARMING_CHECK_RC, display_failure, "RC %s not configured", channel_name);
            return false;
        }
        if (channel->get_radio_min() > 1300) {
            check_failed(ARMING_CHECK_RC, display_failure, "%s radio min too high", channel_name);
            return false;
        }
        if (channel->get_radio_max() < 1700) {
            check_failed(ARMING_CHECK_RC, display_failure, "%s radio max too low", channel_name);
            return false;
        }
        if (channel->get_radio_trim() < channel->get_radio_min()) {
            check_failed(ARMING_CHECK_RC, display_failure, "%s radio trim below min", channel_name);
            return false;
        }
        if (channel->get_radio_trim() > channel->get_radio_max()) {
            check_failed(ARMING_CHECK_RC, display_failure, "%s radio trim above max", channel_name);
            return false;
        }
    }
    return true;
}
开发者ID:Javiercerna,项目名称:ardupilot,代码行数:41,代码来源:AP_Arming.cpp



注:本文中的check_failed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ check_file函数代码示例发布时间:2022-05-30
下一篇:
C++ check_expected函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap