48 if(brother)
delete brother;
49 if(child)
delete child;
65 for(p=
this, ret=0; p && p!=target_p; p=p->
parent, ret++);
72 for(i=0, cur=
this; cur && i<id; i++, cur=cur->
parent);
83 return total_astar_cost;
107 virtual int create_child_nodes(
dpNode**& nodes) = 0;
109 virtual double calc_cost() = 0;
115 virtual int same_state(
dpNode* refnode) = 0;
117 virtual int is_goal() = 0;
120 int open(
int _max_nodes,
int _max_goals);
122 void remove_single();
127 for(c = first_child ? first_child->
brother : child; c && !ret; c=c->
brother)
137 if(depth >= refnode->
depth && active)
return this;
143 virtual void dump(ostream& ost) {
146 parent->dump_trajectory(ost);
150 for(
int i=0;
i<depth;
i++) ost <<
" " << flush;
152 child->dump_all(ost);
153 brother->dump_all(ost);
190 if(larger_child)
delete larger_child;
191 if(smaller_child)
delete smaller_child;
220 if(smaller_child) ret = smaller_child->
smallest();
227 else if(larger_child) ret = larger_child->
smallest();
260 if(node->is_goal()) ret =
this;
267 ost <<
"--- id = " << node->id << endl;
268 ost <<
" cost = " << node->total_cost <<
", goal = " << node->is_goal() << endl;
269 ost <<
" smaller = " << (smaller_child ? smaller_child->node->id : -1) <<
", larger = " << (larger_child ? larger_child->node->id : -1) << endl;
270 smaller_child->dump(ost);
271 larger_child->dump(ost);
298 if(start_node)
delete start_node;
299 if(top_queue)
delete top_queue;
319 int Search(
int _max_nodes = -1,
int _max_goals = -1);
321 int Search(
double max_time);
323 int SearchDepthFirst(
int _max_nodes = -1,
int _max_goals = -1);
325 int SearchBreadthFirst(
int _max_nodes = -1,
int _max_goals = -1);
333 void DumpTrajectory(ostream& ost,
dpNode* goal);
337 if(!top_queue)
return 0;
341 if(g)
return g->
node;
352 cerr <<
"--" << endl;
353 start_node->dump_all(ost);
354 cerr <<
"--" << endl;
357 top_queue->dump(ost);
362 if(start_node)
delete start_node;
363 if(top_queue)
delete top_queue;
384 if(!top_queue)
return 0;
dpNode * next_depth(dpNode *first_child=0)
void add_queue(dpQueue *q)
dpQueue * smallest_goal()
void remove_node(dpNode *node)
dpNode * next_breadth(dpNode *refnode)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
dpQueue * smallest_queue()
dpQueue * larger_goal_sub()
dpNode * GetParent(int id)
virtual int is_goal()=0
Check if the state is goal.
void SetStartNode(dpNode *_n)
Set the initial node for search.
void remove_node_single(dpNode *node)
void DumpQueue(ostream &ost)
dpNode * next_breadth(dpNode *refnode)
void dump(const SDOPackage::NVList &nv)
void DumpAll(ostream &ost)
void add_queue(dpQueue *_q)
int Depth(dpNode *target_p=0)
void dump_all(ostream &ost)
virtual double calc_astar_cost(dpNode *potential_parent)
Compute the A-star cost at the node (optional).
dpNode * BestGoal(dpNode *ref=0)
Extract the goal with the smallest cost (if any).
void dump_trajectory(ostream &ost)
void add_node(dpNode *_n)
virtual void dump(ostream &ost)