klampt.vis.editors module

Functions for visual editing. Used by the klampt.io.resource module in resource.get(...) and resource.edit(...).

A couple editors, SelectionEditor and WorldEditor, cannot be launched from the resource module. To use these, call:

from klampt.vis import editors
ed = editors.SelectionEditor("Some links",[],"Select the links that you want to modify",world))
indices = editors.run(ed)

Classes:

VisualEditorBase(name, value, description, world)

A base class for editing resources.

ConfigEditor(name, value, description, world)

Edits a Config object.

ConfigsEditor(name, value, description, world)

Edits a Configs object.

TrajectoryEditor(name, value, description, world)

Edits a Trajectory, RobotTrajectory, or SE3Trajectory object.

SelectionEditor(name, value, description, world)

Edits a list of indices selecting some links of a robot.

PointEditor(name, value, description, world)

Edits a 3-D point.

RigidTransformEditor(name, value, …[, frame])

Edits a 3-D transform.

AABBEditor(name, value, description, world)

Edits a 3D axis-aligned bounding box (bmin,bmax).

SphereEditor(name, value, description, world)

Edits a sphere represented by a tuple (center,radius).

GeometricPrimitiveEditor(name, value, …[, …])

Edits a GeometricPrimitive.

ObjectTransformEditor(name, value, …)

Edits rigid object transforms.

WorldEditor(name, value, description)

Edits poses of robots, rigid objects, and terrains in a world.

SensorEditor(name, value, description, world)

Edits a SimRobotSensor.

Functions:

run(editorObject)

Launches a visual editor.

class klampt.vis.editors.VisualEditorBase(name, value, description, world)[source]

Bases: klampt.vis.glcommon.GLWidgetPlugin

A base class for editing resources. Used in conjunction with run().

Methods:

instructions()

rtype

Optional[str]

loadable()

Whether Load.

savable()

Whether Save.

display()

rtype

bool

update_gui_from_value()

Called when the value is externally changed (from Load…)

update_value_from_gui()

Called when the value is requested (from Save.

add_dialog_items(parent[, ui])

display_screen()

instructions()[source]
Return type

Optional[str]

loadable()[source]

Whether Load… should be shown

Return type

bool

savable()[source]

Whether Save… should be shown

Return type

bool

display()[source]
Return type

bool

update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

update_value_from_gui()[source]

Called when the value is requested (from Save… and OK)

add_dialog_items(parent, ui='qt')[source]
display_screen()[source]
class klampt.vis.editors.ConfigEditor(name, value, description, world, robot=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a Config object.

Either a world or a RobotModel or SubRobotModel must be provided.

Methods:

instructions()

mousefunc(button, state, x, y)

display()

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
display()[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.ConfigsEditor(name, value, description, world, robot=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a Configs object. The GUI lets the user select which index to edit, and then can click and drag on the robot widget to pose the selected configuration.

Either a world or a RobotModel or SubRobotModel must be provided.

Methods:

instructions()

add_dialog_items(parent[, ui])

insert()

delete()

index_changed(index)

mousefunc(button, state, x, y)

keyboardfunc(c, x, y)

display()

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
add_dialog_items(parent, ui='qt')[source]
insert()[source]
delete()[source]
index_changed(index)[source]
mousefunc(button, state, x, y)[source]
keyboardfunc(c, x, y)[source]
display()[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.TrajectoryEditor(name, value, description, world, robot=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a Trajectory, RobotTrajectory, or SE3Trajectory object.

If a Trajectory is given, then it must either be attached to a robot or a 1D, 2D, or 3D trajectory.

Methods:

attach(object[, relativePose])

For an SE3 trajectory, shows the given object relative to the edited transform trajectory

milestone_to_poser(m)

poser_to_milestone()

instructions()

add_dialog_items(parent[, ui])

insert()

delete()

index_changed(index)

duration_changed(value)

time_driver_changed(value)

anim_selector_changed(value)

toggle_play(value)

on_durations_changed()

Update the trajectory times

update_anim_trajectory()

mousefunc(button, state, x, y)

keyboardfunc(c, x, y)

display()

idle()

update_gui_from_value()

Called when the value is externally changed (from Load…)

attach(object, relativePose=None)[source]

For an SE3 trajectory, shows the given object relative to the edited transform trajectory

milestone_to_poser(m)[source]
poser_to_milestone()[source]
instructions()[source]
add_dialog_items(parent, ui='qt')[source]
insert()[source]
delete()[source]
index_changed(index)[source]
duration_changed(value)[source]
time_driver_changed(value)[source]
anim_selector_changed(value)[source]
toggle_play(value)[source]
on_durations_changed()[source]

Update the trajectory times

update_anim_trajectory()[source]
mousefunc(button, state, x, y)[source]
keyboardfunc(c, x, y)[source]
display()[source]
idle()[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.SelectionEditor(name, value, description, world, robot=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a list of indices selecting some links of a robot.

Methods:

instructions()

add_dialog_items(parent[, ui])

clear()

select_all()

click_world(x, y)

Helper: returns a list of world objects sorted in order of increasing distance.

click_robot(x, y)

Helper: returns a list of robot objects sorted in order of increasing distance.

selection_list_changed()

add_selection(id)

remove_selection(id)

toggle_selection(id)

mousefunc(button, state, x, y)

keyboardfunc(c, x, y)

display()

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
add_dialog_items(parent, ui='qt')[source]
clear()[source]
select_all()[source]
click_world(x, y)[source]

Helper: returns a list of world objects sorted in order of increasing distance.

click_robot(x, y)[source]

Helper: returns a list of robot objects sorted in order of increasing distance.

selection_list_changed()[source]
add_selection(id)[source]
remove_selection(id)[source]
toggle_selection(id)[source]
mousefunc(button, state, x, y)[source]
keyboardfunc(c, x, y)[source]
display()[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.PointEditor(name, value, description, world, frame=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a 3-D point.

If frame is given, then it is a klampt.math.se3 element, and the input and output are measured with respect to that frame. However, the editing is done in world coordinates.

Methods:

instructions()

mousefunc(button, state, x, y)

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.RigidTransformEditor(name, value, description, world, frame=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a 3-D transform.

If frame is given, then it is klampt.math.se3 element, and the input and output are measured with respect to that frame. However, the editing is done in world coordinates.

Visualization objects can be attached to the edited transform using the attach() method.

Methods:

disableTranslation()

disableRotation()

disable_translation()

Turns off editing of translation.

disable_rotation()

Turns off editing of rotation.

attach(object[, relativePose])

Attaches an object to visually move along with the edited transform.

instructions()

mousefunc(button, state, x, y)

motionfunc(x, y, dx, dy)

display()

update_gui_from_value()

Called when the value is externally changed (from Load…)

disableTranslation()[source]
disableRotation()[source]
disable_translation()[source]

Turns off editing of translation.

disable_rotation()[source]

Turns off editing of rotation.

attach(object, relativePose=None)[source]

Attaches an object to visually move along with the edited transform.

Parameters
  • object (RigidObjectModel or Geometry3D) – the object to move

  • relativePose (se3 element, optional) – if given, the relative pose of the object w.r.t. the transform

instructions()[source]
mousefunc(button, state, x, y)[source]
motionfunc(x, y, dx, dy)[source]
display()[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.AABBEditor(name, value, description, world, frame=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a 3D axis-aligned bounding box (bmin,bmax).

If frame is given, then it is klampt.math.se3 element, and the input and output are measured with respect to that frame. However, the editing is done in world coordinates.

Methods:

instructions()

mousefunc(button, state, x, y)

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.SphereEditor(name, value, description, world, frame=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a sphere represented by a tuple (center,radius).

If frame is given, then it is klampt.math.se3 element, and the input and output are measured with respect to that frame. However, the editing is done in world coordinates.

Methods:

instructions()

mousefunc(button, state, x, y)

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.GeometricPrimitiveEditor(name, value, description, world, frame=None)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits a GeometricPrimitive.

Can only handle Point, Sphere, AABB, and Box types for now.

If frame is given, then it is klampt.math.se3 element, and the input and output are measured with respect to that frame. However, the editing is done in world coordinates.

Methods:

instructions()

mousefunc(button, state, x, y)

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.ObjectTransformEditor(name, value, description, world, object)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits rigid object transforms.

value is the klampt.math.se3 transform.

object is the :class:~klampt.RigidObjectModel`.

Methods:

instructions()

mousefunc(button, state, x, y)

update_gui_from_value()

Called when the value is externally changed (from Load…)

instructions()[source]
mousefunc(button, state, x, y)[source]
update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

class klampt.vis.editors.WorldEditor(name, value, description)[source]

Bases: klampt.vis.editors.VisualEditorBase

Edits poses of robots, rigid objects, and terrains in a world.

Note

Edits to robot and rigid object poses are done immediately, but since terrains do not have poses, their actual geometry needs to be updated. To apply the edited poses to the terrain geometries, call update_value_from_gui() after the editor has been run.

Methods:

loadable()

Whether Load.

savable()

Whether Save.

display()

update_value_from_gui()

Applies the transforms to all the terrain geometries.

instructions()

motionfunc(button, state, x, y)

loadable()[source]

Whether Load… should be shown

savable()[source]

Whether Save… should be shown

display()[source]
update_value_from_gui()[source]

Applies the transforms to all the terrain geometries.

instructions()[source]
motionfunc(button, state, x, y)[source]
class klampt.vis.editors.SensorEditor(name, value, description, world)[source]

Bases: klampt.vis.editors.RigidTransformEditor

Edits a SimRobotSensor.

Assumes that the sensor is attached to the first robot in the world, if world is provided.

Methods:

initialize()

Called by backend after the GL context is created but before the event loop starts.

loadable()

Whether Load.

savable()

Whether Save.

add_dialog_items(parent[, ui])

refresh_visualization()

display()

on_setting_selected()

on_setting_edited()

instructions()

mousefunc(button, state, x, y)

motionfunc(x, y, dx, dy)

update_value_from_gui()

Called when the value is requested (from Save.

update_gui_from_value()

Called when the value is externally changed (from Load…)

initialize()[source]

Called by backend after the GL context is created but before the event loop starts.

loadable()[source]

Whether Load… should be shown

savable()[source]

Whether Save… should be shown

add_dialog_items(parent, ui='qt')[source]
refresh_visualization()[source]
display()[source]
on_setting_selected()[source]
on_setting_edited()[source]
instructions()[source]
mousefunc(button, state, x, y)[source]
motionfunc(x, y, dx, dy)[source]
update_value_from_gui()[source]

Called when the value is requested (from Save… and OK)

update_gui_from_value()[source]

Called when the value is externally changed (from Load…)

klampt.vis.editors.run(editorObject)[source]

Launches a visual editor.

Parameters

editorObject (VisualEditorBase) – some subclass of VisualEditorBase

Returns

A pair (res,value) containing:

  • res (bool):True / False if OK / Cancel was pressed, respectively,

  • value: the return value of the editor object

Return type

tuple

Return type

Tuple[bool, Any]