Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorials:intermediate:json_prolog [2019/04/24 11:37] – [Importing a package with queries] gkazhoyatutorials:intermediate:json_prolog [2019/04/24 11:46] gkazhoya
Line 175: Line 175:
        (NIL)        (NIL)
 </code> </code>
 +
 +In JSON Prolog ''(NIL)'' means success, and ''NIL'' means failure. This is explained in detail [[tutorials/intermediate/json_prolog?&#nil_vs_nil|in the next section]].
          
 This allows us to use the ''knowrob_common'' package, which allows us to access many utility functions and also the most commonly used queries of KnowRob. This allows us to use the ''knowrob_common'' package, which allows us to access many utility functions and also the most commonly used queries of KnowRob.
Line 181: Line 183:
  
 <code lisp> <code lisp>
-    CL-USER (json-prolog:prolog-simple "lowercase('HELLOWORLD',Result)") +    CL-USER (json-prolog:prolog-simple "lowercase('HELLOWORLD',RESULT)") 
-       (((|?Result| . |''helloworld''|))+       (((?RESULT . |''helloworld''|))
         . #S(CRAM-UTILITIES::LAZY-CONS-ELEM         . #S(CRAM-UTILITIES::LAZY-CONS-ELEM
               :GENERATOR #<CLOSURE (LAMBDA () :IN JSON-PROLOG::PROLOG-RESULT->BDGS)               :GENERATOR #<CLOSURE (LAMBDA () :IN JSON-PROLOG::PROLOG-RESULT->BDGS)
Line 188: Line 190:
 </code> </code>
  
-This query converts the first elements upper case letters into lower case, and stores the obtained result in the ''Result'' variable.+This query converts the first elements upper case letters into lower case, and stores the obtained result in the ''RESULT'' variable.
  
-An overview of the currently available packages and their queries can be found [[http://www.knowrob.org/api | here]]. If when loading a package Emacs only returns ''NIL'' then it might be that the package does not exist or is not found on your system. In such cases, you can check the terminal in which json-prolog was launched. If it cannot be found, you will see the following error: +An overview of the currently available packages and their queries can be found [[http://www.knowrob.org/api|here]]. If when loading a package Emacs only returns ''NIL'' then it might be that the package does not exist or is not found on your system. In such cases, you can check the terminal in which json-prolog was launched. If it cannot be found, you will see the following error: 
 <code bash> <code bash>
    [rospack] Error: package 'knowrob_maps_tools' not found    [rospack] Error: package 'knowrob_maps_tools' not found
Line 199: Line 201:
          
 <code lisp> <code lisp>
- 
     Prolog query failed: PrologException: error(existence_error(procedure, '/'(u_load_episodes, 1)), context(':'(system, '/'(call, 1)), _1))     Prolog query failed: PrologException: error(existence_error(procedure, '/'(u_load_episodes, 1)), context(':'(system, '/'(call, 1)), _1))
     [Condition of type SIMPLE-ERROR]     [Condition of type SIMPLE-ERROR]
-     
 </code> </code>
          
-and if you check your terminal, in which the **json_prolog** node is running, there will be a huge java print as well, basically explaining the same thing.+and if you check your terminal, in which the ''json_prolog'' node is running, there will be a huge java print as well, basically explaining the same thing.
      
-     + 
-==== Some more information about Prolog in LISP ====+==== Case-sensitive variable names ==== 
 + 
 +In the former query we got a weird result from Prolog which looked like this: ''|''helloworld''|''
 + 
 + 
 +==== (NIL) vs NIL ====
          
 If we want to check, if a certain number is member of the list, we must declare the variable accordingly. e.g. If we want to check, if a certain number is member of the list, we must declare the variable accordingly. e.g.