Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions levels/level0.json
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
{
"nodes": {
"1": {
"y": 0.5,
"x": 0.25,
"type": "root"
},
"2": {
"y": 0.5,
"x": 0.75,
"type": "goal"
}
}
}
{"obstacles": {"3": {"width": 0.50625, "y": 0.7418181818181818, "x": -0.005, "height": 0.045454545454545456}, "0": {"width": 0.4175, "y": 0.48, "x": 0.375, "height": 0.15272727272727274}, "4": {"width": 0.235, "y": 0.2309090909090909, "x": 0.04, "height": 0.3018181818181818}, "1": {"width": 0.0275, "y": 0.09818181818181818, "x": 0.725, "height": 0.29818181818181816}, "2": {"width": 0.0625, "y": 0.6781818181818182, "x": 0.83375, "height": 0.27090909090909093}}, "nodes": {"1": {"type": "root", "y": 0.9618517010841457, "x": 0.9302955500129387}, "2": {"type": "goal", "y": 0.03881026832698498, "x": 0.5987673939370376}}}
1 change: 1 addition & 0 deletions levels/level5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"obstacles": {"22": {"height": 0.18181818181818182, "y": 0.3927272727272727, "x": 0.20375, "width": 0.04125}, "25": {"height": 0.04, "y": 0.45636363636363636, "x": 0.3175, "width": 0.09125}, "9": {"height": 0.06545454545454546, "y": 0.8345454545454546, "x": 0.605, "width": 0.03375}, "24": {"height": 0.03636363636363636, "y": 0.5436363636363636, "x": 0.3, "width": 0.11}, "2": {"height": 0.04727272727272727, "y": 0.7818181818181819, "x": 0.31375, "width": 0.07125}, "16": {"height": 0.05454545454545454, "y": 0.7981818181818182, "x": 0.64875, "width": 0.05125}, "14": {"height": 0.04, "y": 0.8454545454545455, "x": 0.68875, "width": 0.0275}, "31": {"height": 0.04, "y": 0.48, "x": 0.5375, "width": 0.0925}, "5": {"height": 0.11454545454545455, "y": 0.8127272727272727, "x": 0.49, "width": 0.045}, "18": {"height": 0.056363636363636366, "y": 0.9181818181818182, "x": 0.815, "width": 0.0875}, "27": {"height": 0.15818181818181817, "y": 0.3890909090909091, "x": 0.45625, "width": 0.02625}, "30": {"height": 0.15454545454545454, "y": 0.4290909090909091, "x": 0.5225, "width": 0.03125}, "7": {"height": 0.04181818181818182, "y": 0.9163636363636364, "x": 0.5775, "width": 0.0325}, "17": {"height": 0.14181818181818182, "y": 0.8090909090909091, "x": 0.80125, "width": 0.0275}, "6": {"height": 0.05818181818181818, "y": 0.92, "x": 0.4175, "width": 0.1225}, "33": {"height": 0.04, "y": 0.5363636363636364, "x": 0.66875, "width": 0.10125}, "4": {"height": 0.04909090909090909, "y": 0.7872727272727272, "x": 0.42375, "width": 0.11125}, "28": {"height": 0.04727272727272727, "y": 0.3781818181818182, "x": 0.52625, "width": 0.08375}, "32": {"height": 0.19090909090909092, "y": 0.38545454545454544, "x": 0.6625, "width": 0.03625}, "13": {"height": 0.04, "y": 0.8709090909090909, "x": 0.7, "width": 0.02875}, "37": {"height": 0.19272727272727272, "y": 0.38, "x": 0.89625, "width": 0.03}, "29": {"height": 0.1, "y": 0.3890909090909091, "x": 0.60375, "width": 0.03625}, "19": {"height": 0.04727272727272727, "y": 0.8290909090909091, "x": 0.8075, "width": 0.09375}, "11": {"height": 0.04, "y": 0.9218181818181819, "x": 0.71, "width": 0.03625}, "39": {"height": 0.04363636363636364, "y": 0.33454545454545453, "x": 0.8075, "width": 0.1375}, "23": {"height": 0.17636363636363636, "y": 0.39636363636363636, "x": 0.3025, "width": 0.03125}, "3": {"height": 0.14545454545454545, "y": 0.7854545454545454, "x": 0.41375, "width": 0.035}, "8": {"height": 0.03636363636363636, "y": 0.889090909090909, "x": 0.595, "width": 0.03625}, "26": {"height": 0.04, "y": 0.5454545454545454, "x": 0.43375, "width": 0.07875}, "12": {"height": 0.04181818181818182, "y": 0.8963636363636364, "x": 0.7075, "width": 0.03125}, "0": {"height": 0.18, "y": 0.7709090909090909, "x": 0.2025, "width": 0.03375}, "20": {"height": 0.08181818181818182, "y": 0.7490909090909091, "x": 0.8, "width": 0.03}, "34": {"height": 0.1618181818181818, "y": 0.3890909090909091, "x": 0.74625, "width": 0.03125}, "10": {"height": 0.04909090909090909, "y": 0.8, "x": 0.6325, "width": 0.0275}, "36": {"height": 0.2018181818181818, "y": 0.37636363636363634, "x": 0.81125, "width": 0.035}, "21": {"height": 0.056363636363636366, "y": 0.72, "x": 0.80625, "width": 0.1}, "38": {"height": 0.045454545454545456, "y": 0.5363636363636364, "x": 0.80375, "width": 0.135}, "1": {"height": 0.16, "y": 0.7836363636363637, "x": 0.28375, "width": 0.03}, "40": {"height": 0.04, "y": 0.4309090909090909, "x": 0.79875, "width": 0.14875}, "15": {"height": 0.05090909090909091, "y": 0.8163636363636364, "x": 0.675, "width": 0.0425}, "35": {"height": 0.05272727272727273, "y": 0.38181818181818183, "x": 0.66875, "width": 0.0975}}, "nodes": {"1": {"y": 0.040133394017625945, "x": 0.6433954861617589, "type": "root"}, "2": {"y": 0.9167312382997375, "x": 0.34488187650465124, "type": "goal"}}}
50 changes: 48 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__author__ = 'Murray Tannock'
import sys
import random
import time
from itertools import cycle

import pyglet
Expand All @@ -17,13 +18,18 @@
import rrtstarinformed
import shared
import jsonify
import json
import glob



methods = [rrt.step, rrtstar.step, rrtstarconstricted.step, rrtstarinformed.step]
meth_cycle = cycle(methods)

fps_display = pyglet.clock.ClockDisplay()

autoMode = False
outputFile = ""
inputMap = ""

def method_cycle():
"""
Expand All @@ -33,6 +39,22 @@ def method_cycle():
return next(meth_cycle)


class Timer:
fstStop = 0
def run(self):
shared.method()
def goal(self, nodeCount):
if self.fstStop == 0:
self.fstStop = nodeCount
def stop(self):
if(outputFile != ""):
with open(outputFile, 'w+') as f:
f.write(json.dumps({'algo':shared.method.__name__, 'map':inputMap, 'time':shared.node_count, 'cost':shared.root_path_length, 'firstFind':self.fstStop }))
exit()


timer = Timer()

# noinspection PyUnusedLocal
def update(dt):
"""
Expand All @@ -43,10 +65,13 @@ def update(dt):
path_cost = None
if shared.running:
if shared.node_count < shared.max_nodes:
shared.method()
timer.run()

gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glLoadIdentity()
if shared.root_path_length != sys.maxsize:
shared.running = autoMode
timer.goal(shared.node_count)
path_cost = pyglet.text.Label("Path Cost: %6.2f" % shared.root_path_length,
font_size=18,
x=shared.window_width // 3, y=24,
Expand Down Expand Up @@ -82,6 +107,7 @@ def update(dt):
0.5, 0.25, 0.0, 0.5,
0.5, 0.25, 0.0, 0.5,
0.5, 0.25, 0.0, 0.5)))
timer.stop()
else:
pyglet.graphics.draw(4, gl.GL_QUADS,
('v2f', (shared.window_width // 5 - 20, 24 - 10,
Expand Down Expand Up @@ -156,6 +182,7 @@ def setup(is_set=(False, False)):
shared.goal = goal
shared.root_path = []
shared.root_path_length = sys.maxsize
shared.running = autoMode


def main(set_nodes):
Expand All @@ -168,6 +195,9 @@ def main(set_nodes):
window.set_fullscreen(shared.fullscreen, shared.screen)
window.set_location(shared.screen.x, shared.screen.height - shared.default_screen.height)
window.set_caption("Rapidly-exploring Random Trees - RRT - Stopped")

for filename in glob.iglob('data/*.json'):
json.parse(open(filename))

# noinspection PyUnusedLocal
@window.event
Expand Down Expand Up @@ -271,10 +301,19 @@ def on_mouse_release(x, y, button, modifiers):
help="use this file to set the environment up")
parser.add_argument("-f", "--fullscreen",
help="run fullscreen on last screen available", action="store_true")
parser.add_argument("-o", "--output",
help="the name of the output file, for the test data")
parser.add_argument("-a", "--algorithm", type=int,
help="0=rrt, 1=rrtstar, 2=rrtstarconstricted, 3=rrtstarinformed")
args = parser.parse_args()
print(args)

shared.continual = args.screensaver
autoMode = True
if shared.continual:
shared.base_max = sys.maxsize
else:
shared.base_max = 2000
shared.fullscreen = args.fullscreen
if shared.fullscreen:
shared.window_width, shared.window_height = shared.screen_width, shared.screen_height
Expand All @@ -284,4 +323,11 @@ def on_mouse_release(x, y, button, modifiers):
shared.y_range = shared.y_domain[1] - shared.y_domain[0]
if args.infile:
nodes_set = jsonify.parse_infile(args.infile)
inputMap = args.infile
if args.algorithm:
shared.method = methods[int(args.algorithm)]

if args.output:
outputFile = args.output

main(nodes_set)
1 change: 1 addition & 0 deletions output/algo0level0try1.json

Large diffs are not rendered by default.

Loading