code cleanup

This commit is contained in:
Atsushi Sakai
2019-02-02 10:38:37 +09:00
parent 8542504b80
commit f9a4fc1580
3 changed files with 19 additions and 17 deletions

View File

@@ -75,7 +75,7 @@ class RRT():
return path
def choose_parent(self, newNode, nearinds):
if len(nearinds) == 0:
if not nearinds:
return newNode
dlist = []

View File

@@ -5,16 +5,18 @@ Path Planning Sample Code with RRT for car like robot.
author: AtsushiSakai(@Atsushi_twi)
"""
import matplotlib.pyplot as plt
import numpy as np
import copy
import math
import random
import sys
sys.path.append("../ReedsSheppPath/")
import random
import math
import copy
import numpy as np
import reeds_shepp_path_planning
import matplotlib.pyplot as plt
try:
import reeds_shepp_path_planning
except:
raise
show_animation = True
STEP_SIZE = 0.1
@@ -80,7 +82,7 @@ class RRT():
return path
def choose_parent(self, newNode, nearinds):
if len(nearinds) == 0:
if not nearinds:
return newNode
dlist = []
@@ -166,7 +168,7 @@ class RRT():
# print("OK YAW TH num is")
# print(len(fgoalinds))
if len(fgoalinds) == 0:
if not fgoalinds:
return None
mincost = min([self.nodeList[i].cost for i in fgoalinds])
@@ -194,9 +196,9 @@ class RRT():
nnode = len(self.nodeList)
r = 50.0 * math.sqrt((math.log(nnode) / nnode))
# r = self.expandDis * 5.0
dlist = [(node.x - newNode.x) ** 2 +
(node.y - newNode.y) ** 2 +
(node.yaw - newNode.yaw) ** 2
dlist = [(node.x - newNode.x) ** 2
+ (node.y - newNode.y) ** 2
+ (node.yaw - newNode.yaw) ** 2
for node in self.nodeList]
nearinds = [dlist.index(i) for i in dlist if i <= r ** 2]
return nearinds
@@ -247,9 +249,9 @@ class RRT():
# input()
def GetNearestListIndex(self, nodeList, rnd):
dlist = [(node.x - rnd.x) ** 2 +
(node.y - rnd.y) ** 2 +
(node.yaw - rnd.yaw) ** 2 for node in nodeList]
dlist = [(node.x - rnd.x) ** 2
+ (node.y - rnd.y) ** 2
+ (node.yaw - rnd.yaw) ** 2 for node in nodeList]
minind = dlist.index(min(dlist))
return minind

View File

@@ -13,7 +13,7 @@ environment:
init:
- "ECHO %MINICONDA% %PYTHON_VERSION% %PYTHON_ARCH%"
install:
# If there is a newer build queued for the same PR, cancel this one.
# The AppVeyor 'rollout builds' option is supposed to serve the same