Skip to content

Provides visualization tools for AutomotiveDrivingModels. Built on Cairo

License

Notifications You must be signed in to change notification settings

aslandery/AutoViz.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoViz

Build Status Coverage Status

A package for rendering simple scenes primarily consisting of cars on roadways using Cairo.

AutoViz is undergoing significant changes. If you are looking for the version before these changes that is designed around AutomotiveDrivingModels.jl, please checkout the v0.6.0 tag.

AutoViz

Usage

The main function is

render(scene)

where scene is an iterable of renderable objects including cars and roadways.

Example:

roadway = gen_straight_roadway(3, 100.0)
car = ArrowCar([0.0, 0.0], 0.0, color=colorant"blue") # [north, east], angle
render([roadway, car, "some text"])

In a jupyter notebook, an image will appear, otherwise see the Saving images section below. A short tutorial is located in notebooks/tutorial.ipynb.

Renderable

What does it mean to be "renderable"?

An object is directly renderable if the function render!(rm::RenderModel, object) is implemented for it.

An object is renderable by conversion if convert(Renderable, object) returns a directly renderable object.

When render() is invoked, direct renderability is checked with isrenderable(object), which defaults to method_exists(render!, Tuple{RenderModel, typeof(object)}). If this check fails, a conversion attempt is made with convert(Renderable, object).

Roadways and ArrowCars

The primary basic directly renderable types are Roadway (now from AutomotiveDrivingModels; soon from Roadways.jl) and ArrowCar.

ArrowCars are the pink cars with arrows that are in everyone's videos. You can construct one like this:

using Colors
using AutoViz

# x, y, angle and velocity are from your simulation

ArrowCar(x, y, angle; color=colorant"green", text="v: $velocity")

How to make types renderable

There are two ways to make renderable types.

  1. You can make your existing types renderable by conversion by defining convert(::Type{Renderable}, ::MyType) which should return a directly renderable object, e.g. an ArrowCar.
  2. You can make types directly renderable by defining render!(::RenderModel, ::MyType). To make things easier for the compiler, you can also define isrenderable(::Type{MyType}) = true. If you want to allow others to convert to this type to make their types renderable by conversion, make your type a subtype of Renderable.

Overlays

Overlays will function as in the previous version of AutoViz. They will be rendered last with render!(rendermodel, overlay, scene).

Additional keyword arguments for render()

The following additional keyword arguments will accepted by render():

  • canvas_width
  • canvas_height
  • rendermodel
  • overlays
  • cam - a camera controlling the field of view as in the previous version of AutoViz

Saving images

Png images can be saved with write_to_png(render(scene), "filename.png"). Gif animations may be created with e.g. Reel.jl.

RenderModels

The mid-level interface for this package (which is what you will use when you write render!() for your types or when you write an overlay) revolves around adding instructions to a RenderModel. Each instruction consists of a function and a tuple of arguments for the function. This is not documented in this readme, but it is fairly easy to figure out by reading rendermodels.jl, overlays.jl, and arrowcar.jl.

About

Provides visualization tools for AutomotiveDrivingModels. Built on Cairo

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 68.6%
  • Julia 31.4%