@@ -473,7 +473,8 @@ def executePlanning(self, goal, start):
473473 return elapsedTime
474474
475475 # Executing BiOUM to compute the path faster
476- def executeSqBiPlanning (self , goal , start , nbUpdate , anisoSearch ):
476+ def executeSqBiPlanning (self , goal , start , nbUpdate , anisoSearch ,
477+ dirPolicy ):
477478 init = time ()
478479 ijStart = np .round ([(start [0 ] -
479480 self .sqXmap [0 ][0 ])/ self .sqCellLateral ,(start [1 ] -
@@ -492,31 +493,43 @@ def executeSqBiPlanning(self, goal, start, nbUpdate, anisoSearch):
492493 ap .computeBiTmap (self .sqVCMap , self .sqAspectMap ,
493494 self .sqAnisotropyMap , ijGoal , ijStart , self .sqXmap ,
494495 self .sqYmap , self .sqCellLateral , gridtype = 'sq' ,
495- nbUpdate = nbUpdate , anisoSearch = anisoSearch )
496+ nbUpdate = nbUpdate , anisoSearch = anisoSearch ,
497+ dirPolicy = dirPolicy )
496498
497499 print ('Elapsed time to compute the Total Cost Map: ' +
498500 str (time ()- init ) + ' seconds' )
499- TlinkG = self .sqTmapG [self .sqLinkNode [1 ],self .sqLinkNode [0 ]]
500- TlinkS = self .sqTmapS [self .sqLinkNode [1 ],self .sqLinkNode [0 ]]
501- self .sqTmap = np .zeros_like (self .sqTmapG )
502- self .sqTmap [:] = self .sqTmapG
503- self .sqTmap [np .where (self .sqTmapS != np .inf )] = TlinkS + TlinkG - self .sqTmapS [np .where (self .sqTmapS != np .inf )]
504- self .sqTmap [np .where (self .sqTmap < 0.0 )] = np .inf
505-
506- self .sqLinkPos = np .empty ([2 ],dtype = float )
507- self .sqLinkPos [:] = [self .sqXmap [self .sqLinkNode [1 ],
508- self .sqLinkNode [0 ]],
509- self .sqYmap [self .sqLinkNode [1 ],
510- self .sqLinkNode [0 ]]]
511-
512- self .sqPathG ,uu = ap .getSqPath (self .sqDirMapG , self .sqLinkPos , goal ,
513- self .xMin , self .yMin , self .sqCellLateral )
514- self .sqPathS ,uu = ap .getSqPath (self .sqDirMapS , self .sqLinkPos , start ,
515- self .xMin , self .yMin , self .sqCellLateral )
516- self .sqPath = np .concatenate ((np .flipud (np .asarray (self .sqPathS )),
517- np .asarray (self .sqPathG )))
518-
519- def executeHexBiPlanning (self , goal , start , nbUpdate , anisoSearch ):
501+ if dirPolicy == 'bidir' :
502+ TlinkG = self .sqTmapG [self .sqLinkNode [1 ],self .sqLinkNode [0 ]]
503+ TlinkS = self .sqTmapS [self .sqLinkNode [1 ],self .sqLinkNode [0 ]]
504+ self .sqTmap = np .zeros_like (self .sqTmapG )
505+ self .sqTmap [:] = self .sqTmapG
506+ self .sqTmap [np .where (self .sqTmapS != np .inf )] = TlinkS + TlinkG - self .sqTmapS [np .where (self .sqTmapS != np .inf )]
507+ self .sqTmap [np .where (self .sqTmap < 0.0 )] = np .inf
508+
509+ self .sqLinkPos = np .empty ([2 ],dtype = float )
510+ self .sqLinkPos [:] = [self .sqXmap [self .sqLinkNode [1 ],
511+ self .sqLinkNode [0 ]],
512+ self .sqYmap [self .sqLinkNode [1 ],
513+ self .sqLinkNode [0 ]]]
514+
515+ self .sqPathG ,uu = ap .getSqPath (self .sqDirMapG , self .sqLinkPos , goal ,
516+ self .xMin , self .yMin , self .sqCellLateral )
517+ self .sqPathS ,uu = ap .getSqPath (self .sqDirMapS , self .sqLinkPos , start ,
518+ self .xMin , self .yMin , self .sqCellLateral )
519+ self .sqPath = np .concatenate ((np .flipud (np .asarray (self .sqPathS )),
520+ np .asarray (self .sqPathG )))
521+ if dirPolicy == 'goal' :
522+ self .sqTmap = self .sqTmapG
523+ path ,uu = ap .getSqPath (self .sqDirMapG , start , goal ,
524+ self .xMin , self .yMin ,
525+ self .sqCellLateral )
526+ self .sqPath = np .asarray (path )
527+ # self.getSqPathData()
528+ # nbUpdate = True, False
529+ # anisoSearch = 'single', 'double'
530+ # dirPolicy = 'start','goal','bidir'
531+ def executeHexBiPlanning (self , goal , start , nbUpdate , anisoSearch ,
532+ dirPolicy ):
520533 init = time ()
521534 IJ2XY = np .zeros ([2 ,self .hexXmap .shape [0 ],self .hexYmap .shape [1 ]])
522535 IJ2XY [0 ] = self .hexXmap
@@ -533,31 +546,31 @@ def executeHexBiPlanning(self, goal, start, nbUpdate, anisoSearch):
533546 ap .computeBiTmap (self .hexVCMap , self .hexAspectMap ,
534547 self .hexAnisotropyMap , ijGoal , ijStart , self .hexXmap ,
535548 self .hexYmap , self .planRes , gridtype = 'hex' ,
536- nbUpdate = nbUpdate , anisoSearch = anisoSearch )
549+ nbUpdate = nbUpdate , anisoSearch = anisoSearch ,
550+ dirPolicy = dirPolicy )
537551 elapsedTime = time ()- init
538552 print ('Elapsed time to compute the Total Cost Map: ' + str (elapsedTime ))
539553 self .linkNode = nodeLink
540554 self .linkPos = IJ2XY [:,nodeLink [1 ],nodeLink [0 ]]
541-
542- self .pathG ,uu = ap .getPath (self .dirMapG , IJ2XY , XY2IJ , self .linkPos ,
543- goal , self .xMin , self .yMin , self .planRes )
544- self .pathS ,uu = ap .getPath (self .dirMapS , IJ2XY , XY2IJ , self .linkPos ,
545- start , self .xMin , self .yMin , self .planRes )
546-
547555 self .IJ2XY = IJ2XY
548556 self .XY2IJ = XY2IJ
557+ if dirPolicy == 'bidir' :
558+ self .pathG ,uu = ap .getPath (self .dirMapG , IJ2XY , XY2IJ , self .linkPos ,
559+ goal , self .xMin , self .yMin , self .planRes )
560+ self .pathS ,uu = ap .getPath (self .dirMapS , IJ2XY , XY2IJ , self .linkPos ,
561+ start , self .xMin , self .yMin , self .planRes )
549562
550- TlinkG = self .TmapG [nodeLink [1 ],nodeLink [0 ]]
551- TlinkS = self .TmapS [nodeLink [1 ],nodeLink [0 ]]
563+ TlinkG = self .TmapG [nodeLink [1 ],nodeLink [0 ]]
564+ TlinkS = self .TmapS [nodeLink [1 ],nodeLink [0 ]]
552565
553- self .pathS = self .pathS [1 :- 1 ]
554-
555- self .path = np .concatenate ((np .flipud (np .asarray (self .pathS )),
556- np .asarray (self .pathG )))
557- self .Tmap = np .zeros_like (self .TmapG )
558- self .Tmap [:] = self .TmapG
559- self .Tmap [np .where (self .TmapS != np .inf )] = TlinkS + TlinkG - self .TmapS [np .where (self .TmapS != np .inf )]
560- self .Tmap [np .where (self .Tmap < 0.0 )] = np .inf
566+ self .pathS = self .pathS [1 :- 1 ]
567+
568+ self .path = np .concatenate ((np .flipud (np .asarray (self .pathS )),
569+ np .asarray (self .pathG )))
570+ self .Tmap = np .zeros_like (self .TmapG )
571+ self .Tmap [:] = self .TmapG
572+ self .Tmap [np .where (self .TmapS != np .inf )] = TlinkS + TlinkG - self .TmapS [np .where (self .TmapS != np .inf )]
573+ self .Tmap [np .where (self .Tmap < 0.0 )] = np .inf
561574 self .getPathData ()
562575 self .elapsedTime = elapsedTime
563576 return elapsedTime
@@ -595,6 +608,13 @@ def getSlope(self, xPos, yPos, heading):
595608 s = np .nan
596609 slope .append (s )
597610 return slope
611+
612+ def getSqPathData (self ):
613+ pathElevation = []
614+ for index , waypoint in enumerate (self .sqPath ):
615+ pathElevation .append (ap .interpolatePoint (
616+ waypoint / self .sqCellLateral ,self .elevationMap ))
617+ self .pathElevation = pathElevation
598618
599619 def getPathData (self ):
600620 pathElevation = []
@@ -757,44 +777,81 @@ def showHexAnisotropyMap(self):
757777 cbar .set_label ('Anisotropy' )
758778 ax .set_aspect ('equal' )
759779 plt .show ()
780+
781+ def showElevationMap (self ,fontsize ):
782+ fig , ax = plt .subplots (constrained_layout = True )
783+ cc = ax .contourf (self .xMap , self .yMap , self .elevationMap ,
784+ 50 , cmap = cm .gist_earth , extend = 'both' )
785+ ax .contour (self .xMap , self .yMap , self .hexElevationMap ,
786+ 20 , colors = 'k' , alpha = .3 )
787+ # cc = ax.scatter(self.hexXmap, self.hexYmap,
788+ # c = self.hexElevationMap, cmap=cm.gist_earth,s=20)
789+ ax .set_xlim ([self .xMap [0 ,2 ], self .xMap [- 1 ,- 4 ]])
790+ ax .set_ylim ([self .yMap [0 ,0 ], self .yMap [- 1 ,- 1 ]])
791+ cbar = fig .colorbar (cc )
792+ cbar .set_label ('Elevation [m]' , fontsize = fontsize )
793+ ax .set_aspect ('equal' )
760794
761- def showHexElevationMap ( self ):
762- self . showNavElevationMap ( 'hex' )
795+ ax . set_xlabel ( 'X-axis [m]' , fontsize = fontsize )
796+ ax . set_ylabel ( 'Y-axis [m]' , fontsize = fontsize )
763797
764- def showSqElevationMap (self ):
765- self .showNavElevationMap ('sq' )
798+ def showHexElevationMap (self , fontsize ):
799+ self .showNavElevationMap ('hex' , fontsize )
800+
801+ def showSqElevationMap (self , fontsize ):
802+ self .showNavElevationMap ('sq' , fontsize )
766803
767- def showNavElevationMap (self , option ):
804+ def showNavElevationMap (self , option , fontsize ):
768805 fig , ax = plt .subplots (constrained_layout = True )
769806 if option == 'sq' :
770807 cc = ax .scatter (self .sqXmap , self .sqYmap , c = self .sqElevationMap ,
771808 cmap = cm .gist_earth ,s = 20 )
772809 ax .set_xlim ([self .xMap [0 ,0 ], self .xMap [- 1 ,- 1 ]])
773810 ax .set_ylim ([self .yMap [0 ,0 ], self .yMap [- 1 ,- 1 ]])
774811 elif option == 'hex' :
775- cc = ax .scatter (self .hexXmap , self .hexYmap ,
776- c = self .hexElevationMap , cmap = cm .gist_earth ,s = 20 )
812+ cc = ax .contourf (self .hexXmap , self .hexYmap , self .hexElevationMap ,
813+ 50 , cmap = cm .gist_earth , extend = 'both' )
814+ ax .contour (self .hexXmap , self .hexYmap , self .hexElevationMap ,
815+ 10 , colors = 'k' , alpha = .3 )
816+ # cc = ax.scatter(self.hexXmap, self.hexYmap,
817+ # c = self.hexElevationMap, cmap=cm.gist_earth,s=20)
777818 ax .set_xlim ([self .xMap [0 ,2 ], self .xMap [- 1 ,- 4 ]])
778819 ax .set_ylim ([self .yMap [0 ,0 ], self .yMap [- 1 ,- 1 ]])
779820 cbar = fig .colorbar (cc )
780- cbar .set_label ('Elevation (m)' )
821+ cbar .set_label ('Elevation [m]' , fontsize = fontsize )
781822 ax .set_aspect ('equal' )
782823
783- ax .set_xlabel ('X-axis [m]' )
784- ax .set_ylabel ('Y-axis [m]' )
824+ ax .set_xlabel ('X-axis [m]' , fontsize = fontsize )
825+ ax .set_ylabel ('Y-axis [m]' , fontsize = fontsize )
785826
786-
787- def showHexSteepnessMap (self ):
827+ def showSqSlopeGradientMap (self , fontsize , maxGradient = 0.0 ):
828+ fig , ax = plt .subplots (constrained_layout = True )
829+ cc = ax .scatter (self .sqXmap , self .sqYmap , c =
830+ self .rad2deg * self .sqSlopeMap ,
831+ cmap = "nipy_spectral" ,s = 20 )
832+ if maxGradient > 0.0 :
833+ cc .set_clim (0 ,maxGradient )
834+ ax .set_aspect ('equal' )
835+ cbar = fig .colorbar (cc )
836+ cbar .set_label ('Slope Gradient [deg]' , fontsize = fontsize )
837+ ax .set_aspect ('equal' )
838+ ax .set_xlim ([self .xMap [0 ,0 ], self .xMap [- 1 ,- 1 ]])
839+ ax .set_ylim ([self .yMap [0 ,0 ], self .yMap [- 1 ,- 1 ]])
840+ ax .set_xlabel ('X-axis [m]' , fontsize = fontsize )
841+ ax .set_ylabel ('Y-axis [m]' , fontsize = fontsize )
842+ plt .show ()
843+
844+ def showHexSteepnessMap (self , fontsize ):
788845 fig , ax = plt .subplots (constrained_layout = True )
789846 cc = ax .scatter (self .hexXmap , self .hexYmap , c = self .rad2deg * self .hexSlopeMap , cmap = "nipy_spectral" ,s = 20 )
790847 ax .set_aspect ('equal' )
791848 cbar = fig .colorbar (cc )
792- cbar .set_label ('Slope (deg)' )
849+ cbar .set_label ('Slope (deg)' , fontsize = fontsize )
793850 ax .set_aspect ('equal' )
794851 ax .set_xlim ([self .xMap [0 ,2 ], self .xMap [- 1 ,- 4 ]])
795852 ax .set_ylim ([self .yMap [0 ,0 ], self .yMap [- 1 ,- 1 ]])
796- ax .set_xlabel ('X-axis [m]' )
797- ax .set_ylabel ('Y-axis [m]' )
853+ ax .set_xlabel ('X-axis [m]' , fontsize = fontsize )
854+ ax .set_ylabel ('Y-axis [m]' , fontsize = fontsize )
798855 plt .show ()
799856
800857
0 commit comments