API

List of functions and datastructure available in AutomotiveVisualization

AutomotiveVisualization.ArrowCarType

A basic drawable rectangle representing a car. An arrow indicates the heading direction of the car.

ArrowCar{A<:AbstractArray{Float64}, C<:Colorant} <: Renderable
ArrowCar(pos::AbstractArray, angle::Float64=0.0; length = 4.8, width = 1.8,  color=colortheme["COLOR_CAR_OTHER"], text="", id=0)
ArrowCar(x::Real, y::Real, angle::Float64=0.0; length = 4.8, width = 1.8,  color=colortheme["COLOR_CAR_OTHER"], text="", id=0)
source
AutomotiveVisualization.BlinkerOverlayType
BlinkerOverlay

Displays a circle on one of the top corner of a vehicle to symbolize a blinker. fields:

  • on: turn the blinker on
  • right: blinker on the top right corner, if false, blinker on the left
  • veh: the vehicle for which to display the blinker
  • color: the color of the blinker
  • size: the size of the blinker
source
AutomotiveVisualization.CameraStateType
CameraState(;
    position::VecE2      = VecE2(0.,0.),
    zoom::Real           = 1.,
    rotation::Real       = 0.,
    canvas_width::Int64  = DEFAULT_CANVAS_WIDTH
    canvas_height::Int64 = DEFAULT_CANVAS_HEIGHT
)

Representation of the internal camera state.

  • position::VecE2: the (x,y) position of the camera in [metre]. The x-direction is measured to the east, y direction to the north.
  • zoom::Real: the zoom level of the camera, expressed in [pixels / metre]
  • rotation::Real: the rotation angle of the camera in [radian]
  • canvas_width::Int64: the canvas width in [pixel]
  • canvas_height::Int64: the canvas width in [pixel]
source
AutomotiveVisualization.ComposedCameraType
ComposedCamera <: Camera

Composition of several cameras. The update_camera actions of the individual cameras are applied in the order in which they are saved in the cameras array. States of individual cameras are ignored, the state of the composed camera is the one that will be used for rendering.

Example Usage

cam = ComposedCamera(cameras=[SceneFollowCamera(), ZoomingCamera()])
AutomotiveVisualization.FancyCarType

A drawable 'fancy' svg image of a race car. The car is placed at the position of entity and the width and length are scaled accordingly. The color of the car can be specified using the color keyword.

source
AutomotiveVisualization.FancyPedestrianType

A drawable 'fancy' svg image of a pedestrian. The pedestrian is placed at the position of entity and the width and length of the original image are scaled accordingly. The color of the pedestrian can be specified using the color keyword.

source
AutomotiveVisualization.HistogramOverlayType
HistogramOverlay

Display a bar at the specified position pos, the bar is of size width, height and is filled up to a given proportion of its height. The fill proportion is set using val, it should be a number between 0 and 1. If it is 0, the bar is not filled, if it is 1 it is filled to the top.

Fields

  • pos::VecE2{Float64} = VecE2(0.,0.)
  • coordinate_system::Symbol = :scene
  • label::String = "histogram"
  • val::Float64 = 0.5 should be between 0 and 1
  • width::Float64 = 2.
  • height::Float64 = 5.
  • fill_color::Colorant = colorant"blue"
  • line_color::Colorant = colorant"white"
  • font_size::Int64 = 15 # [pix]
  • label_pos::VecSE2{Float64} = pos + VecSE2(0., -height/2) position of the label
source
AutomotiveVisualization.IDOverlayType
IDOverlay

Display the ID on top of each entity in a scene. The text can be customized with the color::Colorant (default=white) and font_size::Int64 (default=15) keywords. The position of the ID can be adjusted using x_off::Float64 and y_off::Float64 (in camera coordinates).

Fields

  • color::Colorant = colorant"white"
  • font_size::Int = 15
  • x_off::Float64 = 0.
  • y_off::Float64 = 0.
source
AutomotiveVisualization.NeighborsOverlayType
NeighborsOverlay

Draws a line between a vehicle and its neighbors. The neighbors are linked with different colors depending on their lanes.

Fields

  • target_id::Int
  • color_L::Colorant = colorant"blue"
  • color_M::Colorant = colorant"green
  • color_R::Colorant = colorant"red"
  • line_width::Float64 = 0.5
  • textparams::TextParams = TextParams()
source
AutomotiveVisualization.RenderModelType
RenderModel

Model to keep track of rendering instructions and background color.

  • instruction_set::AbstractVector{Tuple}: set of render instructions (function, array of inputs sans ctx, coordinate_system)
  • background_color::RGB: background color

Fields

  • instruction_set :: AbstractVector{Tuple} = Array{Tuple}(undef, 0)
  • background_color :: RGB = colortheme["background"]
source
AutomotiveVisualization.SceneFollowCameraType
SceneFollowCamera

Camera centered over all vehicles.

By default, the scene is tracked in x and y direction and the zoom level is adapted to fit all vehicles in the scene. Tracking in either direction can be disabled by setting the x or y keys to a desired value. The zoom level can be fixed by passing a value to zoom. The value of padding specifies the width of the additional border around the zoomed-in area.

AutomotiveVisualization.StaticCameraType
StaticCamera <: Camera

Fix the position and the zoom as specified in the constructor.

Constructor

StaticCamera(position::VecE2=(0,0), zoom::Real=4)

AutomotiveVisualization.TargetFollowCameraType
TargetFollowCamera <: Camera

Camera which follows the vehicle with ID target_id. By default, the target vehicle is tracked in x and y direction. Tracking in either direction can be disabled by setting the x or y keys to a desired value.

Constructor

TargetFollowCamera(target_id; x=NaN, y=NaN, kwargs...)

AutomotiveVisualization.TextOverlayType
TextOverlay

Displays some text at the desired location. The coordinates and size units are in pixels by default. The option coordinate_system allows to use different units.

Fields

  • text::Vector{String}
  • color::Colorant = colorant"white"
  • font_size::Int = 10
  • pos::VecE2 = VecE2(10, font_size)
  • line_spacing::Float64 = 1.5 multiple of font_size
  • coordinate_system::Symbol=:camera_pixels
source
AutomotiveVisualization.VelocityArrowType

A drawable arrow representing the current velocity vector of an entity. The arrow points to the location where the vehicle will be one second in the future (assuming linear motion).

source
AutomotiveVisualization.add_instruction!Method

Add an instruction to the rendermodel

INPUT: rendermodel - the RenderModel we are adding the instruction to f - the function to be called, the first argument must be a CairoContext args - tuple of input arguments to f, skipping the CairoContext coordinatesystem - in which coordinate system are the coordinates given (one of :scene, :camerapixels, :camerarelative) :scene - coordinates are physical coordinates in the world frame in unit [meters] `:camerapixels- coordinates are in pixels and relative to the rectangle selected by the camera in unit [pixels]:camera_relative` - coordinates are in percentages in the range 0 to 1 of the rectangle selected by the camera

ex: addinstruction!(rendermodel, rendertext, ("hello world", 10, 20, 15, [1.0,1.0,1.0]))

AutomotiveVisualization.id_to_colorMethod
id_to_color(id)

Random color based on hash code of the ID see https://stackoverflow.com/questions/11120840/hash-string-into-rgb-color

AutomotiveVisualization.isrenderableFunction

Return true if an object or type is directly renderable, false otherwise.

New types should implement the isrenderable(t::Type{NewType}) method.

AutomotiveVisualization.renderMethod
render(
    renderables::AbstractVector;
    camera::Union{Nothing, Camera} = nothing,
    canvas_width::Int64 = (camera === nothing ? DEFAULT_CANVAS_WIDTH : canvas_width(camera)),
    canvas_height::Int64 = (camera === nothing ? DEFAULT_CANVAS_HEIGHT : canvas_height(camera)),
    surface::CairoSurface = CairoSVGSurface(IOBuffer(), canvas_width, canvas_height)
)

Draw all renderables to a surface of dimensions canvas_width x canvas_height. All renderables must implement the add_renderable! function which adds rendering instructions to the render model.

The provided camera should be updated using the update_camera!() function before calling render. If no camera is provided, the render function will default to fitting all renderable objects to the canvas.

AutomotiveVisualization.RenderableOverlayType
RenderableOverlay

Decorator which allows to use legacy overlay objects together with the method render([Renderables])

This is required primarily for allowing backward compatibility with overlays that use the old rendering interface.

usage: RenderableOverlay(o::Overlay, scene::Scene, roadway::Roadway)

AutomotiveVisualization.camera_fit_to_contentFunction
camera_fit_to_content(rendermodel::RenderModel, ctx::CairoContext, canvas_width::Integer = DEFAULT_CANVAS_WIDTH, canvas_height::Integer = DEFAULT_CANVAS_HEIGHT; percent_border::Real = 0.0)

Helper function that determines camera parameters such that all rendered content fits on the canvas.