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:

  • Draw the course and tHE robot
  • Set start and goal locations
  • Parameters
  • Plan the path (rrt)
  • Check collisions of the edges

Step 2: Benchmark and collect data Plot data

Pseudocode

$$ \\mathrm{sum}(a) = \\sum_{i=1}^n a_i. $$

Pseudocode

T = RRT()

RRT(X_init, K, Δt)
T.init(X_init) 
for k = 1 to K do
    x_rand = random_state()
    x_near = nearest_neighboar(x_rand, T)
    u = select_input(x_rand, x_near)
    x_new = new_state(x_near, u, Δt)
    T.add_vertex(x_new)
    T.add_edge(x_near, x_new, u)
 return T


$X_{init}$


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


Node(0, 10, (1, 2))
 Type Node
Out[68]:
AddNode (generic function with 1 method)

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]:



WARNING: cos{T <: Number}(x::AbstractArray{T}) is deprecated, use cos.(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] cos(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at ./deprecated.jl:57
 [3] include_string(::String, ::String) at ./loading.jl:515
 [4] include_string(::Module, ::String, ::String) at /home/nrw/.julia/v0.6/Compat/src/Compat.jl:464
 [5] execute_request(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.ZMQ.Socket, ::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.IJulia.Msg) at /home/nrw/.julia/v0.6/IJulia/src/execute_request.jl:154
 [6] eventloop(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.ZMQ.Socket) at /home/nrw/.julia/v0.6/IJulia/src/eventloop.jl:8
 [7] (::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.IJulia.##14#17)() at ./task.jl:335
while loading In[112], in expression starting on line 10

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


syntax: invalid character literal

Stacktrace:
 [1] include_string(::String, ::String) at ./loading.jl:515

In [3]:



UndefVarError: figure not defined

Stacktrace:
 [1] include_string(::String, ::String) at ./loading.jl:515

In [ ]: