Skip to content
Snippets Groups Projects
Commit ea906650 authored by hagrid67's avatar hagrid67
Browse files

added Jeremy to authors

moved xticks, yticks to middle of grid squares
added more image tests
parent a42aed45
No related branches found
No related tags found
No related merge requests found
...@@ -52,5 +52,6 @@ Authors ...@@ -52,5 +52,6 @@ Authors
* Sharada Mohanty <mohanty@aicrowd.com> * Sharada Mohanty <mohanty@aicrowd.com>
* Giacomo Spigler <giacomo.spigler@gmail.com> * Giacomo Spigler <giacomo.spigler@gmail.com>
* Mattias Ljungström <ml@mljx.io> * Mattias Ljungström <ml@mljx.io>
* Jeremy Watson
<please fill yourself in> <please fill yourself in>
...@@ -125,7 +125,7 @@ class RenderTool(object): ...@@ -125,7 +125,7 @@ class RenderTool(object):
else: else:
return gTransRCAg return gTransRCAg
def plotAgent(self, rcPos, iDir, sColor): def plotAgent(self, rcPos, iDir, sColor="r"):
""" """
Plot a simple agent. Plot a simple agent.
Assumes a working matplotlib context. Assumes a working matplotlib context.
...@@ -278,14 +278,22 @@ class RenderTool(object): ...@@ -278,14 +278,22 @@ class RenderTool(object):
visit = visitDest visit = visitDest
xyPrev = None xyPrev = None
while visit.prev is not None: while visit.prev is not None:
# rDist = np.linalg.norm(array(visit.xy) - array(xyTarg))
# xLoc = rDist + visit.iDir / 4
# print (visit.xy)
xy = np.matmul(visit.rc, rt.grc2xy) + rt.xyHalf xy = np.matmul(visit.rc, rt.grc2xy) + rt.xyHalf
if xyPrev is not None: if xyPrev is not None:
plt.plot([xy[0], xyPrev[0]], dx, dy = (xyPrev - xy) / 20
[xy[1], xyPrev[1]], xyLine = array([xy, xyPrev]) + array([dy, dx])
color="r", alpha=0.5, lw=3)
plt.plot(*xyLine.T, color="r", alpha=0.5, lw=1)
xyMid = np.sum(xyLine * [[1/4], [3/4]], axis=0)
xyArrow = array([
xyMid + [-dx-dy, +dx-dy],
xyMid,
xyMid + [-dx+dy, -dx-dy]
])
plt.plot(*xyArrow.T, color="r")
visit = visit.prev visit = visit.prev
xyPrev = xy xyPrev = xy
...@@ -411,10 +419,13 @@ class RenderTool(object): ...@@ -411,10 +419,13 @@ class RenderTool(object):
plt.xlim([0, env.width * cell_size]) plt.xlim([0, env.width * cell_size])
plt.ylim([-env.height * cell_size, 0]) plt.ylim([-env.height * cell_size, 0])
plt.xticks(np.linspace(0, env.width * cell_size, env.width+1)) gTicks = (np.arange(0, env.height) + 0.5) * cell_size
plt.yticks(np.linspace(-env.height * cell_size, 0, env.height+1), gLabels = np.arange(0, env.height)
np.abs(np.linspace(-env.height * cell_size, plt.xticks(gTicks, gLabels)
0, env.height+1)))
gTicks = np.arange(-env.height * cell_size, 0) + cell_size/2
gLabels = np.arange(env.height, 0, -1)
plt.yticks(gTicks, gLabels)
plt.xlim([0, env.width * cell_size]) plt.xlim([0, env.width * cell_size])
plt.ylim([-env.height * cell_size, 0]) plt.ylim([-env.height * cell_size, 0])
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -58,5 +58,27 @@ def test_render_env(): ...@@ -58,5 +58,27 @@ def test_render_env():
checkFrozenImage("basic-env.png") checkFrozenImage("basic-env.png")
plt.figure(figsize=(10,10))
oRT.renderEnv()
lVisits = oRT.plotTreeOnRail(
oEnv.agents_position[0],
oEnv.agents_direction[0],
nDepth=17)
checkFrozenImage("env-tree-spatial.png")
plt.figure(figsize=(8,8))
xyTarg = oRT.env.agents_target[0]
visitDest = oRT.plotTree(lVisits, xyTarg)
checkFrozenImage("env-tree-graph.png")
oFig = plt.figure(figsize=(10,10))
oRT.renderEnv()
oRT.plotPath(visitDest)
checkFrozenImage("env-path.png")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment