PDDLViz.colorschemes
— ConstantA dictionary of ColorScheme
s provided by PDDLViz.
PDDLViz.AnimSolveCallback
— TypeAnimSolveCallback{R <: Renderer}
A callback for anim_solve
that animates the solving process of a SymbolicPlanners.jl [Planner
]. The behavior of this callback can be customized on a per-renderer and per-planner
basis by defining a new method for
(cb::AnimSolveCallback{R <: Renderer)(planner::Planner, args...)`.
PDDLViz.Animation
— TypeAnimation
Displayable animation which wraps a VideoStream
object. Can be displayed with show(io, MIME"text/html"(), anim)
, or saved with save(path, anim)
.
PDDLViz.BasicGraphic
— TypeBasicGraphic(shape; attributes...)
Basic graphic type, containing a primitive shape and a dictionary of attributes.
PDDLViz.Canvas
— TypePDDLViz.Controller
— TypeController
Abstract supertype for all controllers. When attached to a canvas, a controller interprets user input as PDDL actions and updates the canvas accordingly.
Can be attached to a canvas using add_controller!
, and removed using remove_controller
.
PDDLViz.GraphworldRenderer
— TypeGraphworldRenderer(; options...)
Customizable renderer for domains with fixed locations connected in a graph.
General options
resolution::Tuple{Int64, Int64}
: Default figure resolution, in pixels.graph_layout::Union{Function, NetworkLayout.AbstractLayout}
: Function orAbstractLayout
that maps a graph to node locations.is_directed::Bool
: Whether the graph edges are directed.location_types::Vector{Symbol}
: PDDL object types that correspond to fixed locations.movable_types::Vector{Symbol}
: PDDL object types that correspond to movable objects.edge_fn::Function
: Function(dom, state, a, b) -> Bool
that checks if(a, b)
is present.edge_label_fn::Function
: Function(dom, state, a, b) -> String
that returns a label for(a, b)
.at_loc_fn::Function
: Function(dom, state, x, loc) -> Bool
that returns ifx
is atloc
.loc_renderers::Dict{Symbol, Function}
: Per-type location renderers, of the form(domain, state, loc) -> Graphic
.obj_renderers::Dict{Symbol, Function}
: Per-type object renderers, of the form(domain, state, obj) -> Graphic
.graph_options::Dict{Symbol, Any}
: Default options for graph rendering, passed to thegraphplot
recipe.state_options::Dict{Symbol, Any}
: Default options for state rendering.
State options
These options can be passed as keyword arguments to render_state
:
show_location_graphics = true
: Whether to show location graphics.show_location_labels = true
: Whether to show location labels.show_movable_graphics = true
: Whether to show movable object graphics.show_movable_labels = true
: Whether to show movable object labels.show_edge_labels = false
: Whether to show edge labels.location_node_color = :black
: Color of location nodes.location_edge_color = :black
: Color of edges between locations.movable_node_color = :gray
: Color of movable object nodes.movable_edge_color = (:mediumpurple, 0.75)
: Color of edges between locations and movable objects.movable_spring_constant = 0.3
: Controls how much movable objects are repelled from other nodes.label_offset_mult = 0.2
: Multiplier for the offset of labels from their corresponding objects. Larger values move the labels further away.
PDDLViz.GridworldRenderer
— TypeGridworldRenderer(; options...)
Customizable renderer for 2D gridworld domains.
General options
resolution::Tuple{Int64, Int64}
: Default figure resolution, in pixels.grid_fluents::Vector{Julog.Term}
: PDDL fluents that represent the grid layers (walls, etc).grid_colors::Vector
: Colors for each grid layer.has_agent::Bool
: Whether the domain has an agent not associated with a PDDL object.get_agent_x::Function
: Function that returns the PDDL fluent for the agent's x position.get_agent_y::Function
: Function that returns the PDDL fluent for the agent's y position.get_obj_x::Function
: Takes an object constant and returns the PDDL fluent for its x position.get_obj_y::Function
: Takes an object constant and returns the PDDL fluent for its y position.agent_renderer::Function
: Agent renderer, of the form(domain, state) -> Graphic
.obj_renderers::Dict{Symbol, Function}
: Per-type object renderers, of the form(domain, state, obj) -> Graphic
.obj_type_z_order::Vector{Symbol}
: Z-order for object types, from bottom to top.locations::Vector{Tuple}
: List of(x, y, label, color)
tuples to label locations on the grid.show_inventory::Bool
: Whether to show an object inventory for each function ininventory_fns
.inventory_fns::Vector{Function}
: Inventory indicator functions of the form(domain, state, obj) -> Bool
.inventory_types::Vector{Symbol}
: Types of objects that can be each inventory.inventory_labels::Vector{String}
: Axis titles / labels for each inventory.state_options::Dict{Symbol, Any}
: Default options for state rendering.trajectory_options::Dict{Symbol, Any}
: Default options for trajectory rendering.anim_options::Dict{Symbol, Any}
: Default options for animation rendering.
State options
These options can be passed as keyword arguments to render_state
:
show_grid::Bool = true
: Whether to show grid variables (walls, etc).show_agent::Bool = true
: Whether to show the agent.show_objects::Bool = true
: Whether to show objects.show_locations::Bool = true
: Whether to show locations.show_inventory::Bool = true
: Whether to show inventories.caption = nothing
: Caption to display below the figure.caption_font = :regular
: Font for the caption.caption_size = 24
: Font size for the caption.caption_color = :black
: Font color for the caption.caption_padding = 12
: Padding for the caption.caption_rotation = 0
: Rotation for the caption.
Trajectory options
These options can be passed as keyword arguments to render_trajectory
:
:agent_color = black
: Marker color of agent tracks.:agent_start_color = agent_color
: Marker color of agent tracks at the start of the trajectory, which fade into the main color.:tracked_objects = Const[]
: Moving objects to plot marker tracks for.:object_colors = Symbol[]
: Marker colors to use for tracked objects.:object_start_colors = object_colors
: Marker colors to use for tracked objects at the start of the trajectory, which fade into the main color.:tracked_types = Symbol[]
: Types of objects to track.:type_colors = Symbol[]
: Marker colors to use for tracked object types.:type_start_colors = type_colors
: Marker colors to use for tracked object types at the start of the trajectory, which fade into the main color.:track_arrowmarker = '▶'
: Marker to use for directed tracks.:track_stopmarker = '⦿'
: Marker to use for stationary tracks.:track_markersize = 0.3
: Size of track markers.
Animation options
These options can be passed as keyword arguments to animation functions:
captions = nothing
: Captions to display for each timestep, e.g.,["t=1", "t=2", ...]
. Can be provided as a vector of strings, or a dictionary mapping timesteps to strings. Ifnothing
, no captions are displayed.trail_length = 0
: Length of trail tracks to display for each agent or tracked object. If0
, no trail tracks are displayed.
PDDLViz.KeyboardController
— TypeKeyboardController(options...)
KeyboardController(
key1 => act1, key2 => act2, ...,
extra_key1, extra_key2, ...;
exclusive=true, callback=nothing
)
A controller that maps keyboard input to PDDL actions.
Options
keymap
: A dictionary mapping keyboard keys to PDDL actions.extrakeys
: Keys mapped to remaining available actions (default: number keys).extraprocess
: Function(state, acts) -> acts
that filters/processes remaining actions.restart_key
: Restart button if an initial state is specified.exclusive
: Whether an action is executed only if no other keys are pressed.callback
: Post-action callbackf(canvas, domain, state, act, next_state)
.obsfunc
PDDLViz.MarkerGraphic
— TypeMarkerGraphic(marker, x, y, [w=1.0, h=w]; attributes...)
A marker graphic with a given position and size, rendered using scatter
with the corresponding marker type.
PDDLViz.MultiGraphic
— TypeMultiGraphic(graphics; attributes...)
Composite graphic type, containing a tuple of graphics in depth-order and a dictionary of attributes.
PDDLViz.Renderer
— TypeRenderer
A Renderer
defines how a PDDL State
for a specific Domain
should be rendered. A concrete sub-type of Renderer
should be implemented for a PDDL domain (or family of PDDL domains, e.g. 2D gridworlds) for users who wish to visualize that domain.
(r::Renderer)(domain::Domain, args...; options...)
(r::Renderer)(canvas::Canvas, domain::Domain, args...; options...)
Once a Renderer
has been constructed, it can be used to render PDDL states and other entities by calling it with the appropriate arguments.
PDDLViz.TextGraphic
— TypeTextGraphic(str, x, y, [fontsize]; attributes...)
A text graphic with a given position and [fontsize], rendered using the text
plotting command.
GeometryBasics.coordinates
— MethodReturn the coordinates of a graphic.
PDDLViz.BoxGraphic
— FunctionBox prefab graphic, consisting of a box with a lid.
PDDLViz.CircleShape
— MethodConstruct a circle centered at x
and y
with radius r
.
PDDLViz.CityGraphic
— FunctionCity prefab graphic, made of three rectangles.
PDDLViz.GemGraphic
— FunctionGem prefab graphic, consisting of a N-gon and a smaller N-gon inside it.
PDDLViz.HeptagonShape
— MethodConstruct a heptagon centered at x
and y
with radius r
.
PDDLViz.HexagonShape
— MethodConstruct a hexagon centered at x
and y
with radius r
.
PDDLViz.HumanGraphic
— FunctionHuman prefab graphic, made of a oval head and triangle body.
PDDLViz.KeyGraphic
— FunctionKey prefab graphic, consisting of a key with a handle and two teeth.
PDDLViz.LockedDoorGraphic
— FunctionLocked door prefab graphic, consisting of square with a keyhole in it.
PDDLViz.NgonShape
— MethodConstruct a n
-sided regular polygon centered at x
and y
with radius 1
.
PDDLViz.OctagonShape
— MethodConstruct an octagon centered at x
and y
with radius r
.
PDDLViz.PentagonShape
— MethodConstruct a pentagon centered at x
and y
with radius r
.
PDDLViz.PolygonShape
— MethodConstruct a polygon from a list of vertices.
PDDLViz.QuestionBoxGraphic
— FunctionQuestion box prefab graphic, consisting of a box with a lid and question mark.
PDDLViz.RectShape
— MethodConstruct a rectangle centered at x
and y
with width w
and height h
.
PDDLViz.RobotGraphic
— FunctionRobot prefab graphic
PDDLViz.SquareShape
— MethodConstruct a square centered at x
and y
with side length l
.
PDDLViz.TrapezoidShape
— FunctionConstruct a trapezoid at x
and y
with top and bottom width a
, bottom width b
, and height h
. The top can be shifted by an offset
(zero by default).
PDDLViz.TriangleShape
— MethodConstruct a triangle centered at x
and y
with radius r
.
PDDLViz.add_controller!
— Functionadd_controller!(canvas, controller, domain, [init_state];
show_controls::Bool=false)
Adds a controller
to a canvas
for a given PDDL domain
. An initial state init_state
can be specified to enable restart functionality.
PDDLViz.anim_initialize!
— Methodanim_initialize!(canvas, renderer, domain, state;
callback=nothing, overlay=nothing, kwargs...)
Initializes an animation that will be rendered on the canvas
. Called by anim_plan
and anim_trajectory
as an initialization step.
By default, this just renders the initial state
on the canvas
. This function can be overloaded for different Renderer
types to implement custom initializations, e.g., to add captions or other overlays.
PDDLViz.anim_plan!
— Functionanim_plan([path], renderer, domain, state, actions;
format="mp4", framerate=5, show=false,
record_init=true, options...)
anim_plan!([anim|path], canvas, renderer, domain, state, actions;
format="mp4", framerate=5, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate a series of actions
in a PDDL domain
starting from state
(updating the canvas
if one is provided). An Animation
object is returned, which can be saved or displayed.
An existing anim
can provided as the first argument, so that frames are appended to that animation (format and frame rates are ignored in this case). Alternatively, if a path
is specified, the animation is saved to that file, and the path
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_plan
— Methodanim_plan([path], renderer, domain, state, actions;
format="mp4", framerate=5, show=false,
record_init=true, options...)
anim_plan!([anim|path], canvas, renderer, domain, state, actions;
format="mp4", framerate=5, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate a series of actions
in a PDDL domain
starting from state
(updating the canvas
if one is provided). An Animation
object is returned, which can be saved or displayed.
An existing anim
can provided as the first argument, so that frames are appended to that animation (format and frame rates are ignored in this case). Alternatively, if a path
is specified, the animation is saved to that file, and the path
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_refine!
— Methodanim_refine!([path], renderer,
sol, planner, domain, state, spec;
format="mp4", framerate=30, show=false,
record_init=true, options...)
anim_refine!([anim|path], canvas, renderer,
sol, planner, domain, state, spec;
format="mp4", framerate=30, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate the refinement of an existing solution by a SymbolicPlanners.jl planner
in a PDDL domain
(updating the canvas
if one is provided).
Returns a tuple (anim, sol)
where anim
is an Animation
object containing the animation, and sol
is the solution returned by planner
. If anim
is provided as the first argument, then additional frames are added to the animation. Alternatively, if a path
is provided, the animation is saved to that file, and (path, sol)
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_solve!
— Functionanim_solve([path], renderer, planner, domain, state, spec;
format="mp4", framerate=30, show=false,
record_init=true, options...)
anim_solve!([anim|path], canvas, renderer,
planner, domain, state, spec;
format="mp4", framerate=30, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate the solving process of a SymbolicPlanners.jl planner
in a PDDL domain
(updating the canvas
if one is provided).
Returns a tuple (anim, sol)
where anim
is an Animation
object containing the animation, and sol
is the solution returned by planner
. If anim
is provided as the first argument, then additional frames are added to the animation. Alternatively, if a path
is provided, the animation is saved to that file, and (path, sol)
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_solve
— Methodanim_solve([path], renderer, planner, domain, state, spec;
format="mp4", framerate=30, show=false,
record_init=true, options...)
anim_solve!([anim|path], canvas, renderer,
planner, domain, state, spec;
format="mp4", framerate=30, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate the solving process of a SymbolicPlanners.jl planner
in a PDDL domain
(updating the canvas
if one is provided).
Returns a tuple (anim, sol)
where anim
is an Animation
object containing the animation, and sol
is the solution returned by planner
. If anim
is provided as the first argument, then additional frames are added to the animation. Alternatively, if a path
is provided, the animation is saved to that file, and (path, sol)
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_trajectory
— Functionanim_trajectory([path], renderer, domain, trajectory, [actions];
format="mp4", framerate=5, show=false,
record_init=true, options...)
anim_trajectory!([anim|path], canvas, renderer,
domain, trajectory, [actions];
format="mp4", framerate=5, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate a trajectory
in a PDDL domain
(updating the canvas
if one is provided). An Animation
object is returned, which can be saved or displayed.
An existing anim
can provided as the first argument, so that frames are appended to that animation (format and frame rates are ignored in this case). Alternatively, if a path
is specified, the animation is saved to that file, and the path
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_trajectory!
— Functionanim_trajectory([path], renderer, domain, trajectory, [actions];
format="mp4", framerate=5, show=false,
record_init=true, options...)
anim_trajectory!([anim|path], canvas, renderer,
domain, trajectory, [actions];
format="mp4", framerate=5, show=is_displayed(canvas),
record_init=true, options...)
Uses renderer
to animate a trajectory
in a PDDL domain
(updating the canvas
if one is provided). An Animation
object is returned, which can be saved or displayed.
An existing anim
can provided as the first argument, so that frames are appended to that animation (format and frame rates are ignored in this case). Alternatively, if a path
is specified, the animation is saved to that file, and the path
is returned.
Note that once an animation is displayed or saved, no frames can be added to it.
PDDLViz.anim_transition!
— Methodanim_transition!(canvas, renderer, domain, state, [action, t];
callback=nothing, overlay=nothing, kwargs...)
Animates a transition from the current state stored in the canvas
to the newly provided state
(via action
at timestep t
if provided). Called by anim_plan
and anim_trajectory
to animate a series of state transitions.
By default, this updates the canvas
with the new state
, then runs the overlay
and callback
functions (if provided) on canvas
(e.g. to ovelay annotations, or to record a frame).
This function can be overloaded for different Renderer
types to implement custom transitions, e.g., transitions that involve multiple frames.
PDDLViz.boundingbox
— MethodReturn the bounding box of a graphic.
PDDLViz.centroid
— MethodReturn the centroid of a graphic.
PDDLViz.darken
— MethodDarken a RGB(A) color by a given amount.
PDDLViz.default_anim_options
— Methodcaptions = nothing
: Captions to display for each timestep, e.g.,["t=1", "t=2", ...]
. Can be provided as a vector of strings, or a dictionary mapping timesteps to strings. Ifnothing
, no captions are displayed.trail_length = 0
: Length of trail tracks to display for each agent or tracked object. If0
, no trail tracks are displayed.
PDDLViz.default_state_options
— Methodshow_location_graphics = true
: Whether to show location graphics.show_location_labels = true
: Whether to show location labels.show_movable_graphics = true
: Whether to show movable object graphics.show_movable_labels = true
: Whether to show movable object labels.show_edge_labels = false
: Whether to show edge labels.location_node_color = :black
: Color of location nodes.location_edge_color = :black
: Color of edges between locations.movable_node_color = :gray
: Color of movable object nodes.movable_edge_color = (:mediumpurple, 0.75)
: Color of edges between locations and movable objects.movable_spring_constant = 0.3
: Controls how much movable objects are repelled from other nodes.label_offset_mult = 0.2
: Multiplier for the offset of labels from their corresponding objects. Larger values move the labels further away.
PDDLViz.default_state_options
— Methodshow_grid::Bool = true
: Whether to show grid variables (walls, etc).show_agent::Bool = true
: Whether to show the agent.show_objects::Bool = true
: Whether to show objects.show_locations::Bool = true
: Whether to show locations.show_inventory::Bool = true
: Whether to show inventories.caption = nothing
: Caption to display below the figure.caption_font = :regular
: Font for the caption.caption_size = 24
: Font size for the caption.caption_color = :black
: Font color for the caption.caption_padding = 12
: Padding for the caption.caption_rotation = 0
: Rotation for the caption.
PDDLViz.default_trajectory_options
— Method:agent_color = black
: Marker color of agent tracks.:agent_start_color = agent_color
: Marker color of agent tracks at the start of the trajectory, which fade into the main color.:tracked_objects = Const[]
: Moving objects to plot marker tracks for.:object_colors = Symbol[]
: Marker colors to use for tracked objects.:object_start_colors = object_colors
: Marker colors to use for tracked objects at the start of the trajectory, which fade into the main color.:tracked_types = Symbol[]
: Types of objects to track.:type_colors = Symbol[]
: Marker colors to use for tracked object types.:type_start_colors = type_colors
: Marker colors to use for tracked object types at the start of the trajectory, which fade into the main color.:track_arrowmarker = '▶'
: Marker to use for directed tracks.:track_stopmarker = '⦿'
: Marker to use for stationary tracks.:track_markersize = 0.3
: Size of track markers.
PDDLViz.lighten
— MethodLighten a RGB(A) color by a given amount.
PDDLViz.new_canvas
— Methodnew_canvas(renderer::Renderer)
new_canvas(renderer::Renderer, figure::Figure)
new_canvas(renderer::Renderer, axis::Axis)
new_canvas(renderer::Renderer, gridpos::GridPosition)
Creates a new Canvas
to be used by renderer
. An existing figure
, axis
, or gridpos
can be specified to use as the base for the new canvas.
PDDLViz.remove_controller!
— Methodremove_controller!(canvas, controller)
Removes a controller
from a canvas
.
PDDLViz.render_controls!
— Methodrender_controls!(canvas, controller, domain)
Renders controls for a controller
to a canvas
.
PDDLViz.render_plan!
— Methodrender_plan!(canvas, renderer, domain, state, actions)
Uses renderer
to render a series of actions
in a PDDL domain
starting from state
. Renders to a canvas
on top of any existing content.
PDDLViz.render_plan
— Methodrender_plan(renderer, domain, state, actions; options...)
Uses renderer
to render a series of actions
in a PDDL domain
starting from state
. Constructs and returns a new Canvas
.
PDDLViz.render_sol!
— Methodrender_sol!(canvas::Canvas, renderer::Renderer,
domain::Domain, state::State, sol::Solution)
Uses renderer
to render a planning solution sol
starting from a state
in a PDDL domain
. Renders to a canvas
on top of any existing content.
PDDLViz.render_sol
— Methodrender_sol(renderer::Renderer,
domain::Domain, state::State, sol::Solution)
Uses renderer
to render a planning solution sol
starting from a state
in a PDDL domain
. Constructs and returns a new Canvas
.
PDDLViz.render_state!
— Methodrender_state!(canvas, renderer, domain, state; options...)
Uses renderer
to render a state
of a PDDL domain
to an existing canvas
, rendering over any existing content.
PDDLViz.render_state
— Methodrender_state(renderer, domain, state)
Uses renderer
to render a state
of a PDDL domain
. Constructs and returns a new Canvas
.
PDDLViz.render_storyboard
— Functionrender_storyboard(anim::Animation, [idxs]; options...)
Renders an Animation
as a series of (bitmap) images in a storyboard. Returns a Figure
where each frame is a subplot.
The frames to render can be specified by idxs
, a vector of indices. If idxs
is not specified, all frames are rendered.
Options
n_rows = 1
: Number of storyboard rows.n_cols = nothing
: Number of storyboard columns (default: number of frames).figscale = 1
: Scales figure size relative to number of pixels required to fit all frames at their full resolution.titles
: List or dictionary of frame titles.subtitles
: List or dictionary of frame subtitles.xlabels
: List or dictionary of x-axis labels per frame.ylabels
: List or dictionary of y-axis labels per frame.
Options that control title and label styling (e.g. titlesize
) can also be specified as keyword arguments. See Axis
for details.
PDDLViz.render_trajectory!
— Methodrender_trajectory!(canvas::Canvas, renderer::Renderer,
domain::Domain, trajectory::AbstractVector{<:State})
Uses renderer
to render a trajectory
of PDDL domain
states. Renders to a canvas
on top of any existing content.
PDDLViz.render_trajectory
— Methodrender_trajectory(renderer::Renderer,
domain::Domain, trajectory::AbstractVector{<:State})
Uses renderer
to render a trajectory
of PDDL domain
states. Constructs and returns a new Canvas
.
PDDLViz.rotate
— FunctionRotate a graphic by θ radians around a point c
.
PDDLViz.scale
— FunctionScale by a horizontal factor x
and vertical factor y
around a point c
.
PDDLViz.set_alpha
— MethodSet the alpha value of a RGB(A) color.
PDDLViz.to_color_obs
— MethodConvert a color or observable to a Observable{RGBA}
.
PDDLViz.translate
— MethodTranslate a graphic by x
and y
units.