当前位置: 首页>>代码示例>>C++>>正文


C++ Motion::back方法代码示例

本文整理汇总了C++中Motion::back方法的典型用法代码示例。如果您正苦于以下问题:C++ Motion::back方法的具体用法?C++ Motion::back怎么用?C++ Motion::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Motion的用法示例。


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

示例1: move

// Generate next movement
bool BufferingPlayer::move(double deadline, Motion& motion_output) {
	initialize();
	CGAL::Timer timer;
	timer.start();

	// Make sure the motion buffer is not empty before we proceed
	while ((timer.time() < deadline) && !has_buffered_motion()) {
		TIMED_TRACE_ACTION("move", "no pending movement");
		plan(deadline);
	}
	if (timer.time() < deadline) {
		TIMED_TRACE_ACTION("move", "additional motion found");
	} else {
		TIMED_TRACE_ACTION("move", "could not find additional movement");
		return true;
	}

	// Attempt to perform the first motion in the buffer
	Motion& motion = motion_buffer.front();
	MS_base* step = NULL;
	bool blocked = false;

	while (!motion.empty() && !blocked && (deadline - timer.time() > 0)) {
		// Get the next step
		motion.cut_step(deadline - timer.time(), motion_output);
		step = motion_output.back();
		deadline -= Motion::step_time(step);

		// Validate it
		Extended_polygon robot_a = env->get_robot_a();
		robot_a.move_absolute(step->source());
		Extended_polygon robot_b = env->get_robot_b();
		robot_b.move_absolute(dynamic_obstacle);
		VALIDATION vResult = planner.validate_step(*step, robot_a, robot_b);

		switch (vResult) {
		case OK:
			// Step is valid
			continue;
		case PATH_BLOCKED:
			// Path is blocked but destination is free
		case DST_BLOCKED:
			// Destination is blocked
			// Return it to the buffer
			motion.add_motion_step_front(step);
			// Don't output this invalid step
			motion_output.pop_back();
			// TODO find the entire gap and find a path around it
			// Right now we can't do anything useful with our remaining time
			blocked = true;
			break;
		}
	}

	if (step == NULL) {
		return false;
	}
	if (motion.empty()) {
		// Executed the entire motion
		buffered_targets.pop_front();
		motion_buffer.pop_front();
	}
	return !blocked;
}
开发者ID:shaybarak,项目名称:HQMP,代码行数:65,代码来源:BufferingPlayer.cpp


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