Representing units of measure

This module provides functionality to describe and reason about units of measure attached to numerical values. Transparent conversion between compatible units (e.g. lengths, time intervals, etc) is provided as well as explicit conversion methods. Full backwards compatibility is ensured by treating values without units as being in the respective SI base units (which, by convention, was used so far). It is based on a large, standard QUDT measurement units ontology by NASA.

Functionality

Assumptions

* If no unit is given, the default SI base unit (meter, second, kilogram) is used

Usage

 $ roscd knowrob_common
 $ rosrun rosprolog rosprolog knowrob_common
 
 ?- owl_parse('package://knowrob_common/owl/knowrob_units.owl').
 ?- consult('prolog/knowrob_units.pl').
 
 % read information that is asserted for a test instance
 ?- rdf_has('http://knowrob.org/kb/knowrob_units.owl#test-inst',
            'http://knowrob.org/kb/knowrob_units.owl#length', O).
 O = literal(type('http://qudt.org/vocab/unit#Centimeter','12.0')) .
 
 % manual conversion into other units
 ?- convert_to_unit($O, 'http://qudt.org/vocab/unit#Kilometer', P).
 P = 0.00012.
 
 ?- convert_to_unit($O, 'http://qudt.org/vocab/unit#Meter', P).
 P = 0.12.
 
 ?- convert_to_unit($O, 'http://qudt.org/vocab/unit#Millimeter', P).
 P = 120.0.

The integration with the rdf_triple computables allows to transparently convert values into the desired unit of measure:

 % transparent conversion during the query  
 ?- rdf_triple('http://knowrob.org/kb/knowrob_units.owl#length', 
               'http://knowrob.org/kb/knowrob_units.owl#test-inst', 
                literal(type('http://qudt.org/vocab/unit#Meter', Val))).
 Val = 0.12 ;
 
 ?- rdf_triple('http://knowrob.org/kb/knowrob_units.owl#length', 
               'http://knowrob.org/kb/knowrob_units.owl#test-inst', 
                literal(type('http://qudt.org/vocab/unit#Kilometer', Val))).
 Val = 0.00012 ;

Literature