# Как создать библиотеку в ROS2

1. Создать пакет

```bash
ros2 pkg create --build-type ament_python lib_package
```

2. В директории `your_ws/src/lib_package/lib_package` написать свою python-модули.
3. Если хотите изменить, дополнить поведение при импорте - правьте `__init__.py`
4. В `setup.py` нужно внести изменения

* Изменить импорты:

```python
# Было:
from setuptools import setup
# Стало:
from setuptools import find_packages, setup
```

* Изменить аргумент функции `setup()`:

```python
# Было:
packages=package_name,
# Стало:
packages=find_packages(exclude=["test"]),
```

5. `colocn build`
6. `source install/local_setup.bash`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alice-and-alex-docs.gitbook.io/alice_and_alex_docs/ros2-development/kak-sozdat-biblioteku-v-ros2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
