Skip to content

Commit d3a8683

Browse files
committed
docs: rewrite create_robots_whoami.md
1 parent da4e67c commit d3a8683

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

docs/create_robots_whoami.md

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,68 @@ To configure RAI for your robot, provide contents for your robot's so called `wh
66

77
Your robot's `whoami` package serves as a configuration package for the `rai_whoami` node.
88

9-
> [!TIP]
10-
> The Human-Machine Interface (HMI), both text and voice versions, relies heavily on the whoami package. It uses the robot's identity, constitution, and documentation to provide context-aware responses and ensure the robot behaves according to its defined characteristics.
11-
129
## Configuration example - Franka Emika Panda arm
1310

1411
1. Setup the repository using 1st and 2nd step from [Setup](../README.md#setup)
1512

16-
2. Create a whoami package for Panda
17-
18-
```shell
19-
./scripts/create_rai_ws.sh --name panda --destination-directory src/examples
20-
```
13+
2. Fill in the `src/examples/panda_whoami/description` folder with data:
2114

22-
3. Fill in the `src/examples/panda_whoami/description` folder with data:
15+
2.1. Save [this image](https://robodk.com/robot/img/Franka-Emika-Panda-robot.png) into `panda/images`
2316

24-
3.1. Save [this image](https://robodk.com/robot/img/Franka-Emika-Panda-robot.png) into `src/examples/panda_whoami/description/images`
17+
2.2. Save [this document](https://github.com/user-attachments/files/16417196/Franka.Emika.Panda.robot.-.RoboDK.pdf) in `panda/documentation`
2518

26-
3.2. Save [this document](https://github.com/user-attachments/files/16417196/Franka.Emika.Panda.robot.-.RoboDK.pdf) in `src/examples/panda_whoami/description/documentation`
19+
2.3. Save [this urdf](https://github.com/frankaemika/franka_ros/blob/develop/franka_description/robots/panda/panda.urdf.xacro) in `panda/urdf`
2720

28-
3.3. Save [this urdf](https://github.com/frankaemika/franka_ros/blob/develop/franka_description/robots/panda/panda.urdf.xacro) in `src/examples/panda_whoami/description/urdf`
21+
3. Build the embodiment info using `build_whoami.py`:
2922

30-
4. Run the `parse_whoami_package`. This will process the documentation, building it into a vector database, which is used by RAI agent to reason about its identity.
23+
```shell
24+
python src/rai_whoami/rai_whoami/build_whoami.py panda/ --build-vector-db
25+
```
3126

3227
> [!IMPORTANT]
33-
> Parsing bigger documents with Cloud vendors might lead to costs. Consider using the
34-
> local `ollama` provider for this task. Embedding model can be configured in
28+
> Building the vector database with cloud vendors might lead to costs. Consider using the
29+
> local `ollama` provider for this task. The embedding model can be configured in
3530
> [config.toml](../config.toml) (`ollama` works locally, see [docs/vendors.md](./vendors.md#ollama)).
3631
37-
```shell
38-
./scripts/parse_whoami_package.sh src/examples/panda_whoami
39-
```
40-
41-
5. Optional: Examine the generated files
32+
4. Examine the generated files
4233

43-
After running the `parse_whoami_package` command, you can inspect the generated files in the `src/examples/panda_whoami/description/generated` directory. These files contain important information about your robot:
34+
After running the build command, inspect the generated files in the `panda/generated` directory. The folder should contain a info.json file containing:
4435

45-
- `robot_identity.txt`: Contains a detailed description of the robot's identity, capabilities, and characteristics.
46-
- `robot_description.urdf.txt`: Provides a summary of the robot's URDF (Unified Robot Description Format), describing its physical structure.
47-
- `robot_constitution.txt`: Outlines the ethical guidelines and operational rules for the robot.
48-
- `faiss_index`: A directory containing the vector store of the robot's documentation, used for efficient information retrieval.
36+
- `rules`: List of rules
37+
- `capabilities`: List of capabilities
38+
- `behaviors`: List of behaviors
39+
- `description`: Description of the robot
40+
- `images`: Base64 encoded images
4941

5042
## Testing
5143

52-
You can test your new `panda_whoami` package by calling `rai_whoami` services:
44+
You can test the generated package by using the RAI Whoami services:
5345

54-
1. Building the `rai_whoami` package and running the `rai_whoami_node` for your `Panda` robot:
46+
1. Using the RAI Whoami services:
5547

5648
```shell
57-
colcon build --symlink-install
58-
ros2 run rai_whoami rai_whoami_node --ros-args -p robot_description_package:="panda_whoami"
49+
# Get robot's identity
50+
ros2 service call /rai_whoami_embodiment_info_service rai_interfaces/srv/EmbodimentInfo
51+
52+
# Query the vector database
53+
ros2 service call /rai_whoami_documentation_service rai_interfaces/srv/VectorStoreRetrieval "query: 'maximum load'"
5954
```
6055

61-
2. Calling the rai_whoami services
56+
If your service calls succeed and you can access the embodiment info and vector database, your robot's whoami package has been properly initialized.
6257

63-
```shell
64-
ros2 service call /rai_whoami_identity_service std_srvs/srv/Trigger # ask for identity
65-
ros2 service call /rai_whoami_selfimages_service std_srvs/srv/Trigger # ask for images folder
66-
ros2 service call /rai_whoami_constitution_service std_srvs/srv/Trigger # ask for robot constitution
67-
ros2 service call /rai_whoami_urdf_service std_srvs/srv/Trigger # ask for urdf description
68-
ros2 service call /rai_whoami_documentation_service rai_interfaces/srv/VectorStoreRetrieval "query: 'maximum load'" # ask for Panda's maximum load
69-
```
58+
2. Alternatively, you can use the RAI Whoami tools directly in your Python code:
59+
60+
```python
61+
from rai_whoami import EmbodimentInfo
62+
from rai_whoami.tools import QueryDatabaseTool
7063

71-
If your service calls succeed, your `panda_whoami` package has been properly initialized.
64+
# Load embodiment info
65+
info = EmbodimentInfo.from_directory("panda/generated")
66+
67+
# Create a system prompt for your LLM
68+
system_prompt = info.to_langchain()
69+
70+
# Use the vector database tool
71+
query_tool = QueryDatabaseTool(root_dir="panda/generated")
72+
query_tool._run(query="maximum load")
73+
```

0 commit comments

Comments
 (0)