Last active
August 29, 2015 14:25
-
-
Save harmishhk/dd6f8e40c6dc3f3ff44c to your computer and use it in GitHub Desktop.
plot test laser scan data and human
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Gadfly | |
using Cairo | |
# generate scan data | |
angle_min = -1.5; | |
angle_max = 1.5; | |
angle_increment = 0.1; | |
ranges = [5.0, 5.0, 4.5, 4.0, 3.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.5, 4.0, 3.5, 3.0, 3.5, 4.0, 4.5, 5.0] | |
# put a human | |
human = [1.5, 2.5] | |
human_radius = 0.25 | |
# generate plot data | |
rangex = Array(Float64, 0) | |
rangey = Array(Float64, 0) | |
for i = 1 : length(ranges) | |
angle = angle_min + (i -1) * angle_increment | |
push!(rangex, ranges[i] * cos(angle)) | |
push!(rangey, ranges[i] * sin(angle)) | |
end | |
humanx = Array(Float64, 0) | |
humany = Array(Float64, 0) | |
for i = linrange(-π, π, 20) | |
push!(humanx, human[2] + human_radius * cos(i)) | |
push!(humany, human[1] + human_radius * sin(i)) | |
end | |
# draw plot | |
draw(SVGJS("laser-filter-plot.svg", 40cm, 20cm), plot( | |
layer(x=rangey, y=rangex, Geom.path(), Geom.point), | |
layer(x=humanx, y=humany, Geom.path(), Theme(default_color=color("red"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment