Skip to content

Instantly share code, notes, and snippets.

@harmishhk
Last active August 29, 2015 14:25
Show Gist options
  • Save harmishhk/dd6f8e40c6dc3f3ff44c to your computer and use it in GitHub Desktop.
Save harmishhk/dd6f8e40c6dc3f3ff44c to your computer and use it in GitHub Desktop.
plot test laser scan data and human
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")))))
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment