In [ ]:
print("hello world!")
workspace()
using PyCall
using PyPlot
x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x));
plot(x, y, color="red", linewidth=2.0, linestyle="--")
title("A sinusoidally modulated sinusoid")
print("Hit <enter> to continue")
readline()
#@pyimport matplotlib.pyplot as plt
fig1 = gcf()
#ax1 = fig1[:add_subplot](111, aspect="equal")
#c = patch.Circle([0.5,0.5],0.4,fc="blue",ec="red",linewidth=.5,zorder=0)
#ax1[:add_patch](c)
#show(fig1);
#using PyPlot
#using PyCall
#@pyimport matplotlib.patches as patch
http://coecsl.ece.illinois.edu/ge423/spring13/RickRekoskeAvoid/rrt.html
We'll divide the code into four parts:
Step 2: Benchmark and collect data Plot data
Pseudocode
$$ \\mathrm{sum}(a) = \\sum_{i=1}^n a_i. $$
In [107]:
workspace()
In [68]:
struct Room #corners of the room
x1::Int
y1::Int #bottom left corner?
x2::Int
y2::Int
end
struct Node
id::Int
iPrev::Int #parent
state::Tuple{Int,Int}
end
struct Edge
startnode::Int
endnode::Int
end
struct rrt
nodeslist::Array{Node}
edgeslist::Array{Edge}
end
struct obstacle
end
struct robot
end
foo = Node(0,10,(1,2))
print(foo, "\n Type ", typeof(foo))
function inCollisionObstacle(rob,obstacle)
end
function planPath(start, goal, ballradius, maxiters)
end
function AddNode(rrt, id, iPrev)
end
Out[68]:
In [1]:
function collides(newPoint)
False
end
function collides(Node)
function distance()
end
function nn() #nearest neighbors
end
type Obstacle
x
y
end
room = Room(0,0,10,10)
In [112]:
In [113]:
function main()
#dostuff
# Draw the walls
# Apply circles to represent the obstacles
# Set location of start and end goals
## ball radius, etc.
## safety margin around the ball, threshold for reaching end state,
## max # of itereations
room = Room(0,0,10,10)
p_start = [0;11];
p_goal = [0;-1];
rob.ballradius = 0.5;
rob.p = p_start;
# Draw the start and the goal, with circles too!
circle(rob.p(1,1),rob.p(2,1),rob.ballradius,'g');
circle(p_goal(1,1),p_goal(2,1),rob.ballradius,'r');
# Plan path
P = PlanPathRRT(rob,obst,param,p_start,p_goal);
# Plot the path
for i=2:length(P)
plot([P(1,i);P(1,i-1)],[P(2,i);P(2,i-1)],'g','LineWidth',3);
end
end
In [3]:
In [ ]: