Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tawheeler/AutoViz.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
tawheeler committed Jun 16, 2017
2 parents 485300d + 1dd3bc2 commit 858524a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/2d/overlays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,53 +172,53 @@ function render!(rendermodel::RenderModel, overlay::NeighborsOverlay, scene::Sce
fore_L = get_neighbor_fore_along_left_lane(scene, vehicle_index, roadway, VehicleTargetPointFront(), VehicleTargetPointRear(), VehicleTargetPointFront())
if fore_L.ind != 0
veh_oth = scene[fore_L.ind]
A = get_front_center(veh_ego)
B = get_rear_center(veh_oth)
A = get_front(veh_ego)
B = get_rear(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_L, overlay.line_width))
drawtext(@sprintf("d fore left: %10.3f", fore_L.Δs), yₒ + 0*Δy, rendermodel, textparams)
end

fore_M = get_neighbor_fore_along_lane(scene, vehicle_index, roadway, VehicleTargetPointFront(), VehicleTargetPointRear(), VehicleTargetPointFront())
if fore_M.ind != 0
veh_oth = scene[fore_M.ind]
A = get_front_center(veh_ego)
B = get_rear_center(veh_oth)
A = get_front(veh_ego)
B = get_rear(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_M, overlay.line_width))
drawtext(@sprintf("d fore middle: %10.3f", fore_M.Δs), yₒ + 1*Δy, rendermodel, textparams)
end

fore_R = get_neighbor_fore_along_right_lane(scene, vehicle_index, roadway, VehicleTargetPointFront(), VehicleTargetPointRear(), VehicleTargetPointFront())
if fore_R.ind != 0
veh_oth = scene[fore_R.ind]
A = get_front_center(veh_ego)
B = get_rear_center(veh_oth)
A = get_front(veh_ego)
B = get_rear(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_R, overlay.line_width))
drawtext(@sprintf("d fore right: %10.3f", fore_R.Δs), yₒ + 2*Δy, rendermodel, textparams)
end

rear_L = get_neighbor_rear_along_left_lane(scene, vehicle_index, roadway, VehicleTargetPointRear(), VehicleTargetPointFront(), VehicleTargetPointRear())
if rear_L.ind != 0
veh_oth = scene[rear_L.ind]
A = get_rear_center(veh_ego)
B = get_front_center(veh_oth)
A = get_rear(veh_ego)
B = get_front(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_L, overlay.line_width))
drawtext(@sprintf("d rear left: %10.3f", rear_L.Δs), yₒ + 3*Δy, rendermodel, textparams)
end

rear_M = get_neighbor_rear_along_lane(scene, vehicle_index, roadway, VehicleTargetPointRear(), VehicleTargetPointFront(), VehicleTargetPointRear())
if rear_M.ind != 0
veh_oth = scene[rear_M.ind]
A = get_rear_center(veh_ego)
B = get_front_center(veh_oth)
A = get_rear(veh_ego)
B = get_front(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_M, overlay.line_width))
drawtext(@sprintf("d rear middle: %10.3f", rear_M.Δs), yₒ + 4*Δy, rendermodel, textparams)
end

rear_R = get_neighbor_rear_along_right_lane(scene, vehicle_index, roadway, VehicleTargetPointRear(), VehicleTargetPointFront(), VehicleTargetPointRear())
if rear_R.ind != 0
veh_oth = scene[rear_R.ind]
A = get_rear_center(veh_ego)
B = get_front_center(veh_oth)
A = get_rear(veh_ego)
B = get_front(veh_oth)
add_instruction!(rendermodel, render_line_segment, (A.x, A.y, B.x, B.y, overlay.color_R, overlay.line_width))
drawtext(@sprintf("d rear right: %10.3f", rear_R.Δs), yₒ + 5*Δy, rendermodel, textparams)
end
Expand Down Expand Up @@ -357,7 +357,7 @@ end
# # accel_n_test = rand(track_longitudinal!(reset_hidden_state!(mobil.mlon), scene, roadway, id, vehicle_index))
# drawtext(@sprintf("accel n test: %10.3f", accel_n_test), yₒ + 10*textparams.y_jump, rendermodel, textparams)

# body = inertial2body(get_rear_center(scene[rear_L.ind]), get_front_center(veh_ego)) # project target to be relative to ego
# body = inertial2body(get_rear(scene[rear_L.ind]), get_front(veh_ego)) # project target to be relative to ego
# s_gap = body.x
# drawtext(@sprintf("s_gap L: %10.3f", s_gap), yₒ + 9*textparams.y_jump, rendermodel, textparams)

Expand Down Expand Up @@ -457,4 +457,4 @@ function render!(rendermodel::RenderModel, overlay::MarkerDistOverlay, scene::Sc
end

rendermodel
end
end
9 changes: 9 additions & 0 deletions src/2d/vehicles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ function render!(
p = veh.state.posG
add_instruction!(rendermodel, render_vehicle, (p.x, p.y, p.θ, veh.def.length, veh.def.width, color))
return rendermodel
end
function render!(
rendermodel::RenderModel,
veh::Entity{VehicleState, BicycleModel, Int},
color::Colorant=RGB(rand(), rand(), rand())
)

veh2 = Vehicle(veh.state, veh.def.def, veh.id)
render!(rendermodel, veh2, color)
end

0 comments on commit 858524a

Please sign in to comment.