Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:intermediate:json_prolog [2019/04/24 11:43] – [Some more information about Prolog in LISP] gkazhoya | tutorials:intermediate:json_prolog [2022/01/25 16:35] (current) – [Prerequisites] gkazhoya | ||
---|---|---|---|
Line 9: | Line 9: | ||
This tutorial requires CRAM, roslisp_repl and ROS to have already been installed. Go through the previous tutorials and the installation page if you don't have CRAM installed yet. | This tutorial requires CRAM, roslisp_repl and ROS to have already been installed. Go through the previous tutorials and the installation page if you don't have CRAM installed yet. | ||
Make sure you have **Java 8** and **Gradle 5.1** already installed. Otherwise you won't be able to build KnowRob. Other versions could work, but have not been tested yet, so use them at your own risk! | Make sure you have **Java 8** and **Gradle 5.1** already installed. Otherwise you won't be able to build KnowRob. Other versions could work, but have not been tested yet, so use them at your own risk! | ||
- | |||
=== Installation === | === Installation === | ||
Line 28: | Line 27: | ||
=== Launch === | === Launch === | ||
- | In addition to a **roscore** and the **roslisp_repl** you need to launch **json_prolog** in a Terminal with the following command: | + | In addition to a **roscore** and the **roslisp_repl** you need to launch **json_prolog** in a Terminal with the following command: |
+ | <code bash> | ||
+ | $ roslaunch rosprolog rosprolog.launch | ||
+ | </ | ||
+ | or if you're using an older version of KnowRob, then the following command: | ||
<code bash> | <code bash> | ||
$ roslaunch json_prolog json_prolog.launch | $ roslaunch json_prolog json_prolog.launch | ||
Line 176: | Line 179: | ||
</ | </ | ||
- | In JSON Prolog '' | + | In JSON Prolog '' |
| | ||
This allows us to use the '' | This allows us to use the '' | ||
Line 207: | Line 210: | ||
and if you check your terminal, in which the '' | and if you check your terminal, in which the '' | ||
| | ||
- | | + | |
+ | ==== Case-sensitive variable names ==== | ||
+ | |||
+ | In the former query we got a weird result from Prolog which looked like this: | ||
+ | <code lisp> | ||
+ | |'' | ||
+ | </ | ||
+ | What do the pipes stand for in this case? | ||
+ | |||
+ | Lisp is case-insensitive, | ||
+ | |||
+ | <code lisp> | ||
+ | CL-USER> (eq 'hello ' | ||
+ | T | ||
+ | CL-USER> (eq 'hello ' | ||
+ | T | ||
+ | </ | ||
+ | |||
+ | Prolog, on the other hand, is case-sensitive. | ||
+ | And in some cases, one would like to have a case-sensitive variable in Lisp as well. | ||
+ | This is where the pipes come into play: | ||
+ | <code lisp> | ||
+ | CL-USER> (intern " | ||
+ | HELLO | ||
+ | :INTERNAL | ||
+ | CL-USER> (intern " | ||
+ | |Hello| | ||
+ | NIL | ||
+ | </ | ||
+ | The function '' | ||
+ | If the string is all capital, we get a normal usual symbol, in the other case we get the pipes. | ||
+ | |||
+ | The same is with Prolog, if your variable or any other symbol is not all caps, you will get a symbol in Lisp which has pipes around it: | ||
+ | |||
+ | <code lisp> | ||
+ | CL-USER> (json-prolog: | ||
+ | (((?X . 1))) | ||
+ | CL-USER> (json-prolog: | ||
+ | (((?MYVAR . 1))) | ||
+ | CL-USER> (json-prolog: | ||
+ | (((?MY_VAR . 1))) | ||
+ | CL-USER> (json-prolog: | ||
+ | (((|? | ||
+ | </ | ||
+ | |||
+ | In that case, to get the value of the variable you should also use pipes: | ||
+ | |||
+ | <code lisp> | ||
+ | CL-USER> (cut: | ||
+ | (car (json-prolog: | ||
+ | 1 | ||
+ | </ | ||
+ | |||
+ | Please note that in Prolog, all variables have to start with a capital letter and cannot contain dashes: | ||
+ | <code lisp> | ||
+ | CL-USER> (json-prolog: | ||
+ | NIL | ||
+ | CL-USER> (json-prolog: | ||
+ | NIL | ||
+ | </ | ||
==== (NIL) vs NIL ==== | ==== (NIL) vs NIL ==== | ||
| |