本文整理汇总了C++中TaskManager::task_size方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskManager::task_size方法的具体用法?C++ TaskManager::task_size怎么用?C++ TaskManager::task_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskManager
的用法示例。
在下文中一共展示了TaskManager::task_size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_task_bad
bool test_task_bad(TaskManager& task_manager,
const Waypoints& waypoints)
{
test_task_random(task_manager,waypoints,2);
task_manager.set_factory(OrderedTask::FACTORY_RT);
AbstractTaskFactory& fact = task_manager.get_factory();
const Waypoint* wp = random_waypoint(waypoints);
ok (!fact.createFinish((AbstractTaskFactory::LegalPointType_t)20,*wp),"bad finish type",0);
ok (!fact.createStart((AbstractTaskFactory::LegalPointType_t)20,*wp),"bad start type",0);
ok (!fact.createIntermediate((AbstractTaskFactory::LegalPointType_t)20,*wp),"bad intermediate type",0);
// now create a taskpoint from FAI
AbstractTaskFactory::LegalPointType_t s =
fact.getIntermediateTypes()[(rand() % fact.getIntermediateTypes().size())];
// test it is bad for AAT
task_manager.set_factory(OrderedTask::FACTORY_AAT);
AbstractTaskFactory& bfact = task_manager.get_factory();
ok (!bfact.createIntermediate(s,*wp),"bad intermediate type (after task change)",0);
bfact.remove(1);
ok (bfact.validate(),"ok with one tp",0);
bfact.remove(1);
ok (!bfact.validate(),"insufficient tps for aat",0);
ok (bfact.remove(task_manager.task_size()-1,false),"remove finish manually",0);
ok (!bfact.validate(),"aat is invalid (no finish)",0);
return true;
}
示例2: test_task_random_RT_AAT_FAI
bool test_task_random_RT_AAT_FAI(TaskManager& task_manager,
const Waypoints &waypoints,
const unsigned _num_points)
{
const Waypoint *wp;
OrderedTaskPoint *tp;
AbstractTaskFactory &fact = task_manager.get_factory();
char tmp[255];
char tskType[20];
tskType[0] = '\0';
switch (rand() %3) {
case 0:
task_manager.set_factory(TaskBehaviour::FACTORY_AAT);
strcpy(tskType,"AAT");
test_note("# creating random AAT task\n");
break;
case 1:
task_manager.set_factory(TaskBehaviour::FACTORY_RT);
strcpy(tskType,"RT");
test_note("# creating random RT task\n");
break;
case 2:
task_manager.set_factory(TaskBehaviour::FACTORY_FAI_GENERAL);
strcpy(tskType,"FAI");
test_note("# creating random FAI GENERAL\n");
break;
}
//max points includes start & finish
const unsigned num_points_total = (
max(task_manager.get_ordered_task_behaviour().min_points,
(_num_points % task_manager.get_ordered_task_behaviour().max_points) + 1));
const unsigned num_int_points = num_points_total - 2;
test_note("# adding start\n");
wp = random_waypoint(waypoints);
if (wp) {
AbstractTaskFactory::LegalPointType_t s =
fact.getStartTypes()[(rand() % fact.getStartTypes().size())];
tp = fact.createStart(s,*wp);
if (!fact.append(*tp,false)) {
return false;
}
delete tp;
}
for (unsigned i=0; i<num_int_points; i++) {
test_note("# adding intermediate\n");
wp = random_waypoint(waypoints);
if (wp) {
AbstractTaskFactory::LegalPointType_t s =
fact.getIntermediateTypes()[(rand() % fact.getIntermediateTypes().size())];
tp = fact.createIntermediate(s,*wp);
if (!fact.append(*tp,false)) {
return false;
}
delete tp;
}
}
test_note("# adding finish\n");
wp = random_waypoint(waypoints);
if (wp) {
AbstractTaskFactory::LegalPointType_t s =
fact.getFinishTypes()[(rand() % fact.getFinishTypes().size())];
tp = fact.createFinish(s,*wp);
if (!fact.append(*tp,false)) {
return false;
}
delete tp;
}
test_note("# validating task..\n");
if (!fact.validate()) {
return false;
}
if (task_manager.get_ordered_task().get_factory_type()
== TaskBehaviour::FACTORY_FAI_GENERAL)
{
test_note("# checking OZs for FAI General..\n");
if (!fact.validateFAIOZs())
return false;
}
task_manager.resume();
sprintf(tmp, "# SUCCESS CREATING %s task! task_size():%d..\n",
tskType,
task_manager.task_size());
test_note(tmp);
return true;
}
示例3: test_task_manip
bool test_task_manip(TaskManager& task_manager,
const Waypoints &waypoints)
{
if (!test_task_mixed(task_manager, waypoints)) {
return false;
}
AbstractTaskFactory &fact = task_manager.get_factory();
task_report(task_manager, "# removing tp 2\n");
if (!fact.remove(2)) {
return false;
}
task_report(task_manager, "# removing tp 0\n");
if (!fact.remove(0)) {
return false;
}
task_report(task_manager, "# removing tp -1 (illegal)\n");
if (fact.remove(0-1)) {
return false;
}
task_report(task_manager, "# removing tp 50 (illegal)\n");
if (fact.remove(50)) {
return false;
}
OrderedTaskPoint *tp;
const Waypoint *wp;
task_report(task_manager, "# inserting at 3\n");
wp = waypoints.lookup_id(3);
if (wp) {
tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp);
if (!fact.insert(tp,3)) return false;
}
task_report(task_manager, "# auto-replacing at 2 (no morph)\n");
wp = waypoints.lookup_id(9);
if (wp) {
tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp);
if (!fact.replace(tp,2)) return false;
}
task_report(task_manager, "# auto-replacing at 2 (morph)\n");
wp = waypoints.lookup_id(9);
if (wp) {
tp = fact.createStart(*wp);
if (!fact.replace(tp,2)) return false;
}
task_report(task_manager, "# auto-replacing at 0 (morph this)\n");
wp = waypoints.lookup_id(12);
if (wp) {
tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp);
if (!fact.replace(tp,0)) return false;
}
task_report(task_manager, "# auto-replacing at end (morph this)\n");
wp = waypoints.lookup_id(14);
if (wp) {
tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp);
if (!fact.replace(tp,task_manager.task_size()-1)) return false;
}
task_report(task_manager, "# removing finish point\n");
if (!fact.remove(task_manager.task_size()-1)) {
return false;
}
task_report(task_manager, "# inserting at 50 (equivalent to append)\n");
wp = waypoints.lookup_id(8);
if (wp) {
tp = fact.createFinish(*wp);
if (!fact.insert(tp,50)) return false;
}
task_report(task_manager, "# inserting at 0 (morph this)\n");
wp = waypoints.lookup_id(3);
if (wp) {
tp = fact.createFinish(*wp);
if (!fact.insert(tp,0)) return false;
}
task_report(task_manager, "# inserting at 2 (morph this)\n");
wp = waypoints.lookup_id(4);
if (wp) {
tp = fact.createStart(*wp);
if (!fact.insert(tp,2)) return false;
}
task_report(task_manager, "# inserting at 2 (direct)\n");
wp = waypoints.lookup_id(6);
if (wp) {
tp = fact.createIntermediate(*wp);
if (!fact.insert(tp,2,false)) return false;
}
task_report(task_manager, "# checking task\n");
//.........这里部分代码省略.........
示例4: test_task_type_manip
bool test_task_type_manip(TaskManager& task_manager,
const Waypoints &waypoints, unsigned n_points)
{
if (!test_task_random_RT_AAT_FAI(task_manager, waypoints, n_points))
return false;
AbstractTaskFactory &fact = task_manager.get_factory();
switch (rand() %3) {
case 0:
task_manager.set_factory(TaskBehaviour::FACTORY_AAT);
test_note("# switched FACTORY TYPE to AAT\n");
break;
case 1:
task_manager.set_factory(TaskBehaviour::FACTORY_RT);
test_note("# switched FACTORY TYPE to RT\n");
break;
case 2:
task_manager.set_factory(TaskBehaviour::FACTORY_FAI_GENERAL);
test_note("# switched FACTORY TYPE to FAI GENERAL\n");
break;
default:
test_note("# unknown task type\n");
}
fact.mutate_tps_to_task_type();
test_note("# checking mutated start..\n");
if (!fact.validStartType(
fact.getType(*task_manager.get_ordered_task().getTaskPoint(0))))
return false;
char tmp[255];
sprintf(tmp, "# checking mutated intermediates. task_size():%d..\n",
task_manager.task_size());
test_note(tmp);
for (unsigned i = 1; i < (task_manager.task_size() - 1); i++) {
sprintf(tmp, "# checking mutated intermediate point %d..\n", i);
test_note(tmp);
if (!fact.validIntermediateType(
fact.getType(*task_manager.get_ordered_task().getTaskPoint(i))))
return false;
}
test_note("# checking mutated finish..\n");
if (!fact.validFinishType(
fact.getType(*task_manager.get_ordered_task().getTaskPoint(
task_manager.task_size() - 1))))
return false;
test_note("# validating task..\n");
if (!fact.validate()) {
return false;
}
test_note("# checking task..\n");
if (!task_manager.check_ordered_task()) {
return false;
}
if (task_manager.get_ordered_task().get_factory_type() ==
TaskBehaviour::FACTORY_FAI_GENERAL) {
test_note("# checking OZs for FAI task..\n");
if (!fact.validateFAIOZs())
return false;
}
return true;
}