28.02.2014 Aufrufe

Bahnplanungsframework für ein autonomes Fahrzeug - oops ...

Bahnplanungsframework für ein autonomes Fahrzeug - oops ...

Bahnplanungsframework für ein autonomes Fahrzeug - oops ...

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

56 Suchalgorithmen<br />

1 p u b l i c L i s t AStar ( Node s t a r t , Node g o a l )<br />

{<br />

3 / / C r e a t e two empty s e t s<br />

L i s t c l o s e d S e t = new L i s t ( ) ;<br />

5 L i s t openSet = new L i s t ( ) ;<br />

7 / / Add s t a r t t o open s e t<br />

s t a r t .G = 0 ;<br />

9 s t a r t .H = H e u r i s t i c ( s t a r t , g o a l ) ;<br />

s t a r t . F = s t a r t .G + s t a r t .H;<br />

11 openSet . Add ( s t a r t ) ;<br />

13 w h i l e ( ! openSet . IsEmpty )<br />

{<br />

15 / / Find t h e b e s t s c o r e node<br />

Node c u r r e n t = FindLowest ( openSet ) ;<br />

17 i f ( D i s t a n c e ( c u r r e n t , g o a l ) found a way<br />

19 r e t u r n R e c o n s t r u c t P a t h ( c u r r e n t ) ;<br />

21 openSet . Remove ( c u r r e n t ) ; / / Remove c u r r e n t from open s e t<br />

c l o s e d S e t . Add ( c u r r e n t ) ; / / And add i t t o t h e c l o s e d s e t<br />

23<br />

/ / C r e a t e n e i g h b o r s f o r c u r r e n t and c a l c u l a t e s c o r e s<br />

25 f o r e a c h ( Node n e i g h b o r i n c u r r e n t . Neighbors )<br />

{<br />

27 i f ( GetNode ( c l o s e d S e t , n e i g h b o r ) != n u l l )<br />

/ / Neighbor i s a l r e a d y i n c l o s e d s e t , c o n t i n u e with n e x t<br />

29 c o n t i n u e ;<br />

31 i f ( c h e c k C o l l i s i o n ( n e i g h b o r ) )<br />

{<br />

33 / / Neighbor c o l l i d e s with t h e environment , add i t<br />

/ / d i r e c t l y t o c l o s e d s e t and c o n t i n u e with n e x t<br />

35 c l o s e d S e t . Add ( n e i g h b o r ) ;<br />

c o n t i n u e ;<br />

37 }<br />

39 / / C a l c u l a t e t h e s c o r e s<br />

n e i g h b o r .G = Score ( c u r r e n t , n e i g h b o r ) ;<br />

41 n e i g h b o r .H = H e u r i s t i c ( neighbor , end ) ;<br />

n e i g h b o r . F = n e i g h b o r .G + n e i g h b o r .H;<br />

43<br />

/ / Try t o f i n d o t h e r node , t h a t ’ s n e a r enough t o t h i s node<br />

45 / / and has a l m o s t t h e same o r i e n t a t i o n , so i t can be<br />

/ / h a n d l e d l i k e t h i s n e i g h b o r node

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!