zhm-real 5 лет назад
Родитель
Сommit
630ff88025

+ 6 - 1
Search-based Planning/.idea/workspace.xml

@@ -21,6 +21,11 @@
   <component name="ChangeListManager">
     <list default="true" id="025aff36-a6aa-4945-ab7e-b2c625055f47" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/a_star.py" beforeDir="false" afterPath="$PROJECT_DIR$/a_star.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/bfs.py" beforeDir="false" afterPath="$PROJECT_DIR$/bfs.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/dfs.py" beforeDir="false" afterPath="$PROJECT_DIR$/dfs.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/dijkstra.py" beforeDir="false" afterPath="$PROJECT_DIR$/dijkstra.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/plotting.py" beforeDir="false" afterPath="$PROJECT_DIR$/plotting.py" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -49,7 +54,7 @@
     <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
     <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
     <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../PythonRobotics/PathPlanning" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
     <property name="restartRequiresConfirmation" value="false" />
     <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
   </component>

+ 10 - 5
Search-based Planning/a_star.py

@@ -13,7 +13,7 @@ class Astar:
         self.u_set = self.Env.motions  # feasible input set
         self.obs = self.Env.obs  # position of obstacles
 
-        [self.path, self.policy, self.visited] = self.searching(self.xI, self.xG, heuristic_type)
+        self.path, self.policy, self.visited = self.searching(self.xI, self.xG, heuristic_type)
 
         self.fig_name = "A* Algorithm"
         self.plotting.animation(self.path, self.visited, self.fig_name)  # animation generate
@@ -51,7 +51,8 @@ class Astar:
 
         return path, policy, visited
 
-    def extract_path(self, xI, xG, parent, policy):
+    @staticmethod
+    def extract_path(xI, xG, parent, policy):
         """
         Extract the path based on the relationship of nodes.
 
@@ -69,11 +70,14 @@ class Astar:
             x_current = parent[x_current]
             path_back.append(x_current)
             acts_back.append(policy[x_current])
-            if x_current == xI: break
+
+            if x_current == xI:
+                break
 
         return list(path_back), list(acts_back)
 
-    def get_cost(self, x, u):
+    @staticmethod
+    def get_cost(x, u):
         """
         Calculate cost for this motion
 
@@ -85,7 +89,8 @@ class Astar:
 
         return 1
 
-    def Heuristic(self, state, goal, heuristic_type):
+    @staticmethod
+    def Heuristic(state, goal, heuristic_type):
         """
         Calculate heuristic.
 

+ 5 - 2
Search-based Planning/bfs.py

@@ -46,7 +46,8 @@ class BFS:
 
         return path, policy, visited
 
-    def extract_path(self, xI, xG, parent, policy):
+    @staticmethod
+    def extract_path(xI, xG, parent, policy):
         """
         Extract the path based on the relationship of nodes.
 
@@ -64,7 +65,9 @@ class BFS:
             x_current = parent[x_current]
             path_back.append(x_current)
             acts_back.append(policy[x_current])
-            if x_current == xI: break
+
+            if x_current == xI:
+                break
 
         return list(path_back), list(acts_back)
 

+ 5 - 2
Search-based Planning/dfs.py

@@ -46,7 +46,8 @@ class DFS:
 
         return path, policy, visited
 
-    def extract_path(self, xI, xG, parent, policy):
+    @staticmethod
+    def extract_path(xI, xG, parent, policy):
         """
         Extract the path based on the relationship of nodes.
 
@@ -64,7 +65,9 @@ class DFS:
             x_current = parent[x_current]
             path_back.append(x_current)
             acts_back.append(policy[x_current])
-            if x_current == xI: break
+
+            if x_current == xI:
+                break
 
         return list(path_back), list(acts_back)
 

+ 4 - 2
Search-based Planning/dijkstra.py

@@ -51,7 +51,8 @@ class Dijkstra:
 
         return path, policy, visited
 
-    def get_cost(self, x, u):
+    @staticmethod
+    def get_cost(x, u):
         """
         Calculate cost for this motion
 
@@ -63,7 +64,8 @@ class Dijkstra:
 
         return 1
 
-    def extract_path(self, xI, xG, parent, policy):
+    @staticmethod
+    def extract_path(xI, xG, parent, policy):
         """
         Extract the path based on the relationship of nodes.
 

+ 1 - 1
Search-based Planning/plotting.py

@@ -2,7 +2,7 @@ import matplotlib.pyplot as plt
 import env
 
 
-class Plotting():
+class Plotting:
     def __init__(self, xI, xG):
         self.xI, self.xG = xI, xG
         self.env = env.Env()