When building a large, complex robot system, you will typically encounter dozens or hundreds of robot configurations, transforms, inverse kinematics constraints, and paths. Klamp’t has many functions to help make managing these elements easier.
Visual editing is a sort of what-you-see-is-what-you-get (WYSIWYG) editing approach for robotics, and Klamp’t tries to make visual editing part of the robot hacking workflow in as painless a manner as possible.
This is made more convenient through the Klamp’t resource management mechanism. When working on a large project, it is recommended that configurations, paths, holds, etc. be stored in dedicated sub-project folders to avoid polluting the main Klamp’t folder. Resources are compatible with the RobotPose app, as well as the C++ and Python APIs.
The klampt.io.resource module allows you to easily load, save, or edit resources. Visual editing is supported for Config, Configs, Vector, and RigidTransform types. As an example, the below code loads an xform resource, and visually edits it if it doesnt exist:
from klampt.io import resource from klampt.math import se3 resource.get("test.xform",type="RigidTransform",default=se3.identity())
Klampt-examples/Python/demos/resourcetest.py demo for more
examples about how to use this module.
Currently supported types include:
- Config (.config)
- Configs (.configs): A configuration list
- Trajectory (.path): A piecewise linear trajectory object
- MultiPath (.xml): See klampt.model.multipath
- Hold (.hold)
- Stance (.stance)
- Grasp (.xml)
- GeometricPrimitive (.geom)
- TriMesh (.off, .tri, etc.)
- PointCloud (.pcd)
- Robot (.rob)
- RigidObject (.obj)
- World (.xml)
Klamp’t also supports the following additional types which do not have a dedicated file extension:
Visual editing and visualization support¶
The resource types that can be visually edited include
|Anything in the coordinates module||Y||N||N|
The object types with a Y in the first column can be visually inspected
vis.add(name,object). In the second column, you can edit them
resource.edit on a supported object will
use the corresponding classes in vis.editors. In addition, you can also
use the following editors:
- ObjectTransformEditor: edit RigidObject transforms
- SelectionEditor: edit subsets of a RobotModel
As an example, you can run
import klampt from klampt.vis import editors world = klampt.WorldModel() if not world.readFile("Klampt-examples/data/robots/baxter.rob"): raise RuntimeError("Can't read the Baxter file") links = editors.run(editors.SelectionEditor("active_ik_links", value=[15,16,17,18,19,20], description="Robot arm links for IK", world=world)) print "Selected links",links
The editor will pop up as follows, and you may click on links in the scene or in the list to change the selected links:
Resource browsing app¶
The Klamp’t Python API comes with the
klampt_browser script to quickly
browse through resources, and even edit them. It allows you to navigate
a directory tree and select multiple objects and resources to display.
If you have selected resources of any type that can be edited in the
module (see list above), you can click the “Edit” button and then save the
edited value to disk.
See the klampt_browser docs for more details.