Reasoning about geometric object models

This module is currently under development and not publicly available. A publication describing this module has been presented at IROS 2013.


Start knowrob_mesh_reasoning

rosmake knowrob_cad_models
roscd knowrob_mesh_reasoning
rosrun rosprolog rosprolog knowrob_mesh_reasoning

Analyze a model by its direct path or a KnowRob identifier (you first have to load an OWL file with the object)

 ?- mesh_annotator_path('package://knowrob_cad_models/models/drinking-vessels/cup2.dae',Mr).
 ?- mesh_annotator(knowrob:'DrinkingBottle', Mr).

Retrieve a list of found annotation types:

 ?- mesh_element_types($Mr, TypeList).
 TypeList = ['Plane','Cone','Sphere','Container'].

Sample call for highlighting all sphere annotations:

 ?- mesh_annotator_path('package://knowrob_mesh_reasoning/models/cup2.dae',Mr).
 PeasyCam v105
 [INFO  14:28:17,955] root - MeshReasoning started. Parsing model ...
 [DEBUG 14:28:18,748] root - Model parsed. Took: 00:00:00.781 (Vertices: 3196, Lines: 0, Triangles: 6332)
 [DEBUG 14:28:18,754] root - Calculating curvature ...
 [DEBUG 14:28:19,271] NeighborAnalyzer - Started
 [DEBUG 14:28:23,860] NeighborAnalyzer - Ended. Took: 00:00:04.588
 [DEBUG 14:28:23,860] PrimitiveAnalyzer - Started
 [DEBUG 14:28:27,788] PrimitiveAnalyzer - Ended. Took: 00:00:03.928
 [DEBUG 14:28:27,788] ContainerAnalyzer - Started
 [DEBUG 14:28:27,791] ContainerAnalyzer - Ended. Took: 00:00:00.002
 Mr = @'J#00000140259203508552'. 
 ?- mesh_find_annotations($Mr,'Sphere',Found).
 Found = @'J#00000140260210192312'.
 ?- mesh_annotator_highlight($Mr,$Found).
 FoundList = [@'J#00000140144111974832',

Clear highlight with


Finding handles (default or by specifying minimum and maximum radius of a handle (unit in meters) or min/max radius and min/max length):

 mesh_find_handle($Mr, Li), listsplit(Li,Lh,Lt), mesh_annotator_highlight($Mr,Lh).
 mesh_find_handle($Mr, Li, 0.1, 0.8), listsplit(Li,Lh,Lt), mesh_annotator_highlight($Mr,Lh).
 mesh_find_handle($Mr, Li, 0.1, 0.8, 0.05, 0.20), listsplit(Li,Lh,Lt), mesh_annotator_highlight($Mr,Lh).

Finding all supporting planes:

 mesh_find_supporting_planes($Mr,Planes), mesh_annotator_highlight($Mr,Planes).


These computables are still work in progress, but they already build up the OWL datastructures of the object and its parts including their properties and relative poses.

Start knowrob_mesh_reasoning

 $ roscd knowrob_mesh_reasoning
 $ rosrun rosprolog rosprolog knowrob_mesh_reasoning

Load example file

 ?- owl_parse('owl/test_objects.owl', false, false, true).

Ask for properPhysicalParts (loads mesh, segments it and creates the parts on the fly)

 ?- rdf_triple(knowrob:properPhysicalParts, knowrob:cabinet1, Parts).

Ask for properties of these parts

 ?- rdf_triple(knowrob:areaOfObject, $Parts, Area).

Currently implemented computables

  • Planar surfaces
    • normalDirection (vector)
    • objectLongSide (vector)
    • objectShortSide (vector)
    • areaOfObject (float)
    • areaCoverage (float)
    • supporting planes (computable class for SupportingPlane)
  • Spheres
    • radius (float)
    • volumeOfObject (float)
    • areaOfObject (float)
    • areaCoverage (float)
    • concavity (computable class for ConcaveTangibleObject)
  • Cones/cylinders
    • radius (as average radius, float)
    • maxRadius (float)
    • minRadius (float)
    • volumeOfObject (float)
    • lengthOfObject (float)
    • longitudinalDirection (vector)
    • areaOfObject (float)
    • areaCoverage (float)
  • Containers
    • longitudinalDirection (opening direction, vector)
    • volumeOfObject (float)
  • Handles (computable class for cylindrical handles, class 'Handle')

CAD models as source of geometric information

CAD models can not only be used for visualization purposes, but can also serve as source of information about the geometry of the objects in the scene. For example, the dimensions of their bounding boxes can be read using the following commands:

Height of the model in meters


Width of the model in meters


Depth of the model in meters


As a reminder, x = width, z = height, and y = depth. For a full list of query predicates check knowrob_cad_models/prolog/

Writing your own CAD model parser

The system comes with parsers for Collada and .ply files. You can, however, easily write your own parser for other file formats.

Structure of a parser

The base class for all parsers should be ModelParser. It contains some essential methods for using parsers and stores a list of Triangles and Lines loaded from the model. Each parser should store the loaded data in the Group (which represents a Triangle/Lines mesh) member variable. Each group can have a name. Its mesh member variable stores the Triangle and Lines information. Triangles can have a texture and a color, Lines only a color.

Model Parser

The model parser is used to parse a CAD Model from a given file and is the base class for all parsers. The parser loads a file and “converts” it so that it can be stored as a list of triangles and lines.

A special feature of the ModelParser is buffering: If a model has been parsed it will be stored in a model buffer. So if the same model should be parsed again it will be taken from this buffer instead of parsing it again. Keep in mind that if you change something in a Group of a specific model it will affect all the other existing instances of this model.

List of available parsers

Currently the following file formats are supported:

Collada Parser

The collada parser uses the dae4j library to parse the Collada XML format. The current version of dae4j has not yet implemented the whole Collada specification, but still seems to the best Collada parser library for Java.

.kmz files are compressed Collada files (zip) and will be extracted into a temporary directory and parsed from there.

How to create a new parser?

Check out ColladaParser for a sample implementation of a parser. The necessary steps for creating a new model parser are:

  • Create a new class and extend it from ModelParser
  • Add your parser to the extension list (In so a file extension will be assigned to your parser:
    • Example:
      extensionAssignment.put("dae", ColladaParser.class);
  • Implement the required methods. These should be self-explaining (see javadoc)
  • Store all data in the Groups member of the ModelParser parent class.