webstudio/docs/example.md
2024-08-15 16:12:02 +03:00

265 lines
6.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Пример: проект "Шахматы"
Имеем доску, две модели фигур - коня и пешку, робота, камеру. Задачей будет из фигур в наличии расставить шахматы на доску в начальную позицию.
### Создаём проект
* Projects
```json
{
"sid": 1,
"name": "chess",
"description": "Robossembler Example"
}
```
### Добавляем модели твёрдых тел (фигур и доски) в библиотеку проекта
Сначала добавляются пакеты:
* Packages
```json
{
"sid": 1,
"project": 1,
"type": "part_model",
"description": "Robossembler: chessboard",
"command": "python",
"package": "",
"executable": "chessboard.py",
"args": {
"blend": \${FILE:string:""},
"dae": \${FILE:string:""},rbs_arm/robot1/controller
"fbx": \${FILE:string:""},
"...": ""
}
}
```
```json
{
"sid": 2,
"project": 1,
"type": "part_model",
"description": "Robossembler: chess pieces",
"command": "python",
"package": "",
"executable": "chess_pieces.py",
"args": [ // ARRAY of pieces
{
"name": \${NAME:string:""},
"blend": \${FILE:string:""},
"dae": \${FILE:string:""},
"fbx": \${FILE:string:""},
"...": ""
}
]
}
```
Затем при запуске "get_interface.py" для каждого пакета, получаем json со структурой:
```json
{
"parts": [{"properties1": "value1", "propertiesN": "valueN"}],
"cameras": [{"properties1": "value1", "propertiesN": "valueN"}],
"robots": [{"properties1": "value1", "propertiesN": "valueN"}],
"topics": [{"properties1": "value1", "propertiesN": "valueN"}],
"datasets": [{"properties1": "value1", "propertiesN": "valueN"}],
"weights": [{"properties1": "value1", "propertiesN": "valueN"}],
"...": ""
}
```
в которой ключи - это наши сущности из БД.
В данном случае будет присутствовать только массив "parts". Web-сервис записывает парсинг результата в соответствующую таблицу.
* Parts_lib
```json
{
"sid": 1,
"package": 1,
"name": "chessboard",
"description": "Robossembler: chessboard",
"meshs": {
"blend": "chessboard.blend",
"dae": "chessboard.dae",
"fbx": "chessboard.fbx",
"...": ""
}
}
```
```json
{
"sid": 2,
"package": 2,
"name": "pawn",
"description": "Robossembler: pawn",
"meshs": {
"blend": "pawn.blend",
"dae": "pawn.dae",
"fbx": "pawn.fbx",
"...": ""
}
}
```
```json
{
"sid": 3,
"package": 2,
"name": "knight",
"description": "Robossembler: knight",
"meshs": {
"blend": "knight.blend",
"dae": "knight.dae",
"fbx": "knight.fbx",
"...": ""
}
}
```
Note. Кроме "sid" и "packages" все остальные поля заполняются из массива [{"properties1": "value1", "propertiesN": "valueN"}].
### Добавляем пакет с моделью камеры в библиотеку проекта
* Packages
```json
{
"sid": 3,
"project": 1,
"type": "digital_twin",
"entity": "CAMERA",
"description": "ROS Wrapper for Intel RealSense Cameras",
"command": "ros2 launch",
"package": "realsense2_camera",
"executable": "rs_launch.py",
"args": {
"camera_namespace": \${NAME:string:""},
"camera_name": \${NAME:string:""},
},
"interfaces": {
"cmd": "python ros2_topic_to_json.py"
}
}
```
### Добавляем экземпляр камеры в сцену (Scene Builder)
При этом запускаем "get_interface.py" и получаем json со структурой, описанной выше, но в данном случае в результате будет
```json
{
"cameras": [
{
"model_name": "Intel RealSense",
"model_type": "RGBD",
"...": "..."
}
],
"topics": [
{
"topic_name": "camera/camera1/image_raw",
"msg_type":"sensor_msgs/msg/Image"
},
{
"topic_name": "camera/camera1/camera_info",
"msg_type":"sensor_msgs/msg/CameraInfo"
}
],
}
```
В БД создаются:
* Cameras
```json
{
"sid": 1,
"package": 3,
"model_name": "Intel RealSense",
"model_type": "RGBD",
"pose": {}
}
```
* Topics
```json
{
"sid": 1,
"package": 3,
"topic_name": "camera/camera1/image_raw",
"msg_type":"sensor_msgs/msg/Image"
}
```
```json
{
"sid": 2,
"package": 3,
"topic_name": "camera/camera1/camera_info",
"msg_type":"sensor_msgs/msg/CameraInfo"
}
```
### Робот добавляется аналогично камере.
* Topics
```json
{
"sid": 3,
"package": 4,
"topic_name": "rbs_arm/robot1/controller",
"msg_type":"sensor_msgs/msg/JointState"
}
```
```json
{
"sid": 4,
"package": 4,
"topic_name": "rbs_arm/robot1/controller1",
"msg_type":"sensor_msgs/msg/JointState"
}
```
### Добавляем пакет навыка Pose Estimation DOPE в библиотеку проекта
* Packages
```json
{
"sid": 5,
"project": 1,
"type": "skill_server",
"description": "Pose Estimation Skill Dope 6D",
"command": "ros2 launch",
"package": "dope6d",
"executable": "dope.py",
"args": {
"output_topic": \${NAME:string:"bound_box"}
},
"interfaces": {
"cmd": "python ros2_topic_to_json.py"
},
"bt_param":[
{
"name": "peConfigure",
"description": "configuring lifecycle node ROS 2",
"type_action": "action"/"condition",
"type": "run",
"param": [
{
"type": "weights",
"dependency": { "object_name": "knight", "weights_file": "/home/shalenikol/0_rbs/w_knight.pth", "dimensions": [0.03, 0.026, 0.065] },
"sid": "123"
}
],
"result": ["POSE"]
},
{ "name": "peStop", "type": "stop", "param": [], "result": [] }
]
}
```
### Запускаем "get_interfaces.py"
* Topics
```json
{
"sid": 5,
"package": 5,
"topic_name": "bound_box",
"msg_type":"geometry_msgs/msg/BoundBox"
}
```
* BTrees
```json
{
"sid": 1,
"package": 5,
"command_name": "peConfigure",
"dependency": {"$FormBuilderTemplate$"}
}
```