bool test_lookup(const Waypoints& waypoints, unsigned id) { const Waypoint* wp; wp = waypoints.lookup_id(id); if (wp== NULL) { return false; } return true; }
bool test_task_dash(TaskManager& task_manager, const Waypoints &waypoints) { const Waypoint *wp; task_manager.set_factory(TaskBehaviour::FACTORY_TOURING); AbstractTaskFactory &fact = task_manager.get_factory(); task_report(task_manager, "# adding start\n"); wp = waypoints.lookup_id(1); if (wp) { OrderedTaskPoint *tp = fact.createStart(*wp); if (!fact.append(*tp)) { return false; } delete tp; } task_manager.setActiveTaskPoint(0); task_manager.resume(); task_report(task_manager, "# adding finish\n"); wp = waypoints.lookup_id(3); if (wp) { OrderedTaskPoint *tp = fact.createFinish(*wp); if (!fact.append(*tp)) { return false; } delete tp; } task_report(task_manager, "# checking task..\n"); if (!fact.validate()) { return false; } if (!task_manager.check_ordered_task()) { return false; } return true; }
unsigned test_radius(const Waypoints& waypoints, const double range) { const Waypoint *r = waypoints.lookup_id(3); if (r) { WaypointVisitorPrint v; waypoints.visit_within_radius(r->Location, fixed(range), v); return v.count; } else { return 0; } }
bool test_replace(Waypoints& waypoints, unsigned id) { const Waypoint* wp; wp = waypoints.lookup_id(id); if (wp== NULL) { return false; } tstring oldName = wp->Name; Waypoint copy = *wp; copy.Name= "Fred"; waypoints.replace(*wp,copy); waypoints.optimise(); wp = waypoints.lookup_id(id); if (wp== NULL) { return false; } return (wp->Name != oldName) && (wp->Name == "Fred"); }
static bool test_nearest(const Waypoints& waypoints) { const Waypoint *r = waypoints.lookup_id(3); if (!r) return false; r = waypoints.get_nearest(r->Location); if (!r) return false; return r->id == 3; }
unsigned test_nearest(const Waypoints& waypoints) { const Waypoint *r = waypoints.lookup_id(3); if (r) { Waypoints::WaypointTree::const_iterator it = waypoints.find_nearest(r->Location); if (it != waypoints.end()) { return true; } else { return false; } } return false; }
unsigned test_copy(Waypoints& waypoints) { const Waypoint *r = waypoints.lookup_id(5); if (!r) { return false; } unsigned size_old = waypoints.size(); Waypoint wp = *r; wp.id = waypoints.size()+1; waypoints.append(wp); waypoints.optimise(); unsigned size_new = waypoints.size(); return (size_new == size_old+1); }
bool test_task_aat(TaskManager& task_manager, const Waypoints &waypoints) { const TaskProjection &projection = task_manager.get_ordered_task().get_task_projection(); task_manager.set_factory(OrderedTask::FACTORY_AAT); AbstractTaskFactory &fact = task_manager.get_factory(); const Waypoint *wp; task_report(task_manager, "# adding start\n"); wp = waypoints.lookup_id(1); if (wp) { if (!fact.append(fact.createStart(*wp),false)) { return false; } } task_manager.setActiveTaskPoint(0); task_manager.resume(); task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(2); if (wp) { OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(tp,false)) { return false; } } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(3); if (wp) { OrderedTaskPoint* tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(40000.0)); tp->update_oz(projection); } if (!fact.append(tp,false)) { return false; } } task_report(task_manager, "# adding finish\n"); wp = waypoints.lookup_id(1); if (wp) { if (!fact.append(fact.createFinish(*wp),false)) { return false; } } task_report(task_manager, "# checking task..\n"); if (!fact.validate()) { return false; } if (!task_manager.check_ordered_task()) { return false; } return true; }
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"); if (task_manager.check_ordered_task()) { task_manager.reset(); task_manager.setActiveTaskPoint(0); task_manager.resume(); } else { return false; } return true; }
bool test_task_mixed(TaskManager& task_manager, const Waypoints &waypoints) { const TaskProjection &projection = task_manager.get_ordered_task().get_task_projection(); OrderedTaskPoint *tp; const Waypoint *wp; task_manager.set_factory(TaskBehaviour::FACTORY_MIXED); AbstractTaskFactory &fact = task_manager.get_factory(); task_report(task_manager, "# adding start\n"); wp = waypoints.lookup_id(1); if (wp) { tp = fact.createStart(AbstractTaskFactory::START_LINE,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(5000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_manager.setActiveTaskPoint(0); task_manager.resume(); task_report(task_manager, "# adding intermdiate\n"); wp = waypoints.lookup_id(2); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AST_CYLINDER,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermdiate\n"); wp = waypoints.lookup_id(3); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(4); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding intermediate\n"); wp = waypoints.lookup_id(5); if (wp) { tp = fact.createIntermediate(AbstractTaskFactory::AAT_CYLINDER,*wp); if (tp->get_oz()->shape == ObservationZonePoint::CYLINDER) { CylinderZone *cz = (CylinderZone *)tp->get_oz(); cz->setRadius(fixed(30000.0)); tp->update_oz(projection); } if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# adding finish\n"); wp = waypoints.lookup_id(1); if (wp) { tp = fact.createFinish(AbstractTaskFactory::FINISH_LINE,*wp); if (!fact.append(*tp,false)) return false; delete tp; } else { return false; } task_report(task_manager, "# checking task\n"); if (!fact.validate()) { return false; } if (!task_manager.check_ordered_task()) { return false; } return true; }