Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2024, KnowRob

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107 changes: 101 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# knowrob_ros

**knowrob_ros** is a ROS 1 wrapper for [KnowRob](https://github.com/knowrob/knowrob), providing ROS interfaces to integrate KnowRob's knowledge reasoning capabilities with robotic systems. This package bridges KnowRob's Prolog-based system with common ROS workflows, making it easier to perform semantic reasoning in real-world robotic tasks.
**knowrob_ros** is a ROS 1 wrapper for [KnowRob](https://github.com/knowrob/knowrob), providing ROS interfaces to integrate KnowRob's knowledge reasoning capabilities with robotic systems.

## Key Features

- **ROS Actions**
- `AskOne`, `AskAll`, **AskIncremental**, and `Tell`
- **Python API**
- `knowrob_ros_lib.py` for simple query/assertion via ros in python
- **Docker Support**
- Ready-to-use container for fast setup

## Installation (Local ROS Workspace)

Expand All @@ -21,7 +30,7 @@ cd ~/catkin_ws/src
git clone https://github.com/knowrob/knowrob.git

# Clone knowrob_ros (this repo)
git clone https://github.com/your-org/knowrob_ros.git
git clone https://github.com/knowrob/knowrob_ros.git
```

### 2. Build the workspace
Expand All @@ -32,7 +41,7 @@ catkin build
```
---

## 🐳 Installation with Docker
## Installation with Docker

If you'd like to avoid setting up everything locally, you can use the provided Dockerfile to run KnowRob and knowrob_ros in an isolated container.

Expand All @@ -59,9 +68,48 @@ source /catkin_ws/devel/setup.bash
roslaunch knowrob_ros knowrob.launch
```

## Example Usage
## Usage

### ROS Interfaces

The following ROS interfaces are available:

| Endpoint | Type | Description |
|------------------------------------------------|--------------------------------------|-------------------------------|
| `/knowrob/askone` | `AskOneAction` | Single-result query |
| `/knowrob/askall` | `AskAllAction` | Multi-result query |
| `/knowrob/askincremental` | `AskIncrementalAction` | Start incremental query |
| `/knowrob/askincremental_next_solution` | `AskIncrementalNextSolutionAction` | Fetch next solution |
| `/knowrob/askincremental_finish` (service) | `AskIncrementalFinish.srv` | Finish incremental query |
| `/knowrob/tell` | `TellAction` | Assert triples into KB |

All endpoints need to be called with a `ModalFrame` message. We document the `ModalFrame` message in detail below.

### Using the Interface from Python

Use the Python client library to integrate KnowRob queries and assertions directly into your code. Here’s a minimal example:

```python
from knowrob_ros.knowrob_ros_lib import KnowRobRosLib, get_default_modalframe

# Initialize ROS node and client
client = KnowRobRosLib()
client.init_node("my_python_client")

# Single-result query
modal = get_default_modalframe()
response = client.ask_one("lpn:jealous(lpn:vincent, X)", modal)
print("AskOne status:", response.status)
print("Binding:", response.answer)

# Shutdown when done
client.shutdown_node()
```

For detailed usage, full method reference, and advanced examples, see the [Python API Guide](src/knowrob_ros_lib/README.md).

### Query Interface

### Command Line

To run a query insterface on the terminal (for docker you can connect to the same container in which you launched knowrob), you should first list to the corresponding topic, on which the results are published:

Expand Down Expand Up @@ -93,4 +141,51 @@ goal:
confidence: 0.0"
```

You should now see an answer on the first terminal.
You should now see an answer on the first terminal.

## Modal Frames

The `ModalFrame` message controls **who** “knows” what, and **when** it’s considered true. Supply one on every call to `ask_one`, `ask_all`, `ask_incremental`, or `tell`.

| Field | Type | Default | Description |
|-----------------------|----------|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `epistemicOperator` | `uint8` | `KNOWLEDGE (0)` | **KNOWLEDGE:** “it is certain that …”<br>**BELIEF (1):** “it could be that …” |
| `aboutAgentIRI` | `string` | `""` | IRI of another agent whose knowledge/belief you’re querying. Mutually exclusive with `aboutSimulationIRI`. |
| `aboutSimulationIRI` | `string` | `""` | IRI of a mental simulation knowledge graph to query. Mutually exclusive with `aboutAgentIRI`. |
| `temporalOperator` | `uint8` | `CURRENTLY (0)` | **CURRENTLY:** “it is now the case that …”<br>**ALL_PAST (1):** “it always was the case that …”<br>**SOME_PAST (2):** “it was the case that …” |
| `minPastTimestamp` | `float` | `UNSPECIFIED_TIMESTAMP (-1.0)` | Lower time bound (seconds since epoch). When >0, only facts true *after* this timestamp are considered. |
| `maxPastTimestamp` | `float` | `UNSPECIFIED_TIMESTAMP (-1.0)` | Upper time bound (seconds since epoch). When >0, only facts true *before* this timestamp are considered. |
| `confidence` | `float` | `0.0` | Minimum confidence threshold (0.0–1.0) for returned statements. |

## Repository Layout

```
.
├── action/ ← ROS action definitions
├── include/ ← C++ interface headers
├── launch/ ← Launch files
├── msg/ ← Custom ROS messages
├── scripts/ ← Python test scripts
├── src/ ← Core Prolog, C++ and Python code
│ └── knowrob_ros_lib/ ← Python client library
├── srv/ ← ROS services
├── test/ ← rostest definitions
├── Dockerfile ← Container setup
├── build-docker.sh ← Helper for Docker builds
├── CMakeLists.txt
├── package.xml
└── README.md
```

## Contributing

1. Fork the repo and create a branch
2. Write or update tests in `scripts/` or `test/`
3. Follow ROS and Python style guidelines
4. Submit a pull request

## 🛠 Support

- **Issues & feature requests**: [GitHub Issues](https://github.com/your-org/knowrob_ros/issues)

(Inactive issues will be closed after 2 weeks of inactivity. Please open a new issue if you need further assistance.)
43 changes: 0 additions & 43 deletions include/marker/publisher.h

This file was deleted.

82 changes: 0 additions & 82 deletions include/tf/logger.h

This file was deleted.

89 changes: 0 additions & 89 deletions include/tf/memory.h

This file was deleted.

Loading