Skip to content

Commit d3a81ab

Browse files
authored
Add API Reference documentation page (#36)
1 parent 94cd48c commit d3a81ab

4 files changed

Lines changed: 91 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Every coroutine returns `Task<T>` and is launched with `ctx.create_task(...)`. T
7474
7575
- [Getting Started](https://otamachan.github.io/rclcpp_async/getting-started/) -- prerequisites, installation, walkthrough
7676
- [Guide](https://otamachan.github.io/rclcpp_async/guide/) -- topics, services, actions, concurrency, cancellation, TF
77+
- [API Reference](https://otamachan.github.io/rclcpp_async/api-reference/) -- full list of public types and methods
7778
7879
## Benchmarks
7980

docs/api-reference.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# API Reference
2+
3+
## CoContext
4+
5+
| Method | Returns | Description |
6+
|---|---|---|
7+
| `create_task(task)` | `Task<T>` | Start a coroutine |
8+
| `subscribe<MsgT>(topic, qos)` | `shared_ptr<TopicStream<MsgT>>` | Subscribe to a topic |
9+
| `create_timer(period)` | `shared_ptr<TimerStream>` | Create a periodic timer stream |
10+
| `create_service<SrvT>(name, cb)` | `shared_ptr<Service<SrvT>>` | Create a coroutine service server |
11+
| `create_action_server<ActT>(name, cb)` | `shared_ptr<Server<ActT>>` | Create a coroutine action server |
12+
| `wait_for_service(client, timeout)` | *awaitable* `Result<void>` | Wait for a service |
13+
| `send_request<SrvT>(client, req)` | *awaitable* `Response` | Call a service |
14+
| `wait_for_action(client, timeout)` | *awaitable* `Result<void>` | Wait for an action server |
15+
| `send_goal<ActT>(client, goal)` | *awaitable* `Result<shared_ptr<GoalStream>>` | Send an action goal |
16+
| `sleep(duration)` | *awaitable* `void` | Async sleep |
17+
| `poll_until(pred, interval, timeout)` | `Task<Result<void>>` | Poll until predicate is true or timeout |
18+
| `wait_for(awaitable, timeout)` | `Task<Result<T>>` | Race an awaitable against a timeout |
19+
| `post(fn)` | `void` | Post a callback to the executor thread (thread-safe) |
20+
| `node()` | `Node&` | Access the underlying node |
21+
22+
## Free Functions
23+
24+
| Function | Returns | Description |
25+
|---|---|---|
26+
| `create_single_goal_action_server<ActT>(ctx, name, cb)` | `shared_ptr<Server<ActT>>` | Single-goal action server with preemption |
27+
| `when_all(awaitables...)` | *awaitable* `tuple<Ts...>` | Await all tasks/awaitables concurrently |
28+
| `when_any(awaitables...)` | *awaitable* `variant<Ts...>` | Race tasks/awaitables, return first result |
29+
| `shield(task)` | *awaitable* `T` | Protect a task from parent cancellation |
30+
31+
## Task
32+
33+
| Method | Returns | Description |
34+
|---|---|---|
35+
| `operator bool()` | `bool` | `true` if the task holds a valid coroutine (not moved-from) |
36+
| `done()` | `bool` | `true` if the coroutine has completed (`false` for null tasks) |
37+
| `result()` | `T&` | Get the result of a completed `Task<T>` (rethrows if exception) |
38+
| `cancel()` | `void` | Request cancellation via `CancelledException` |
39+
40+
## Result
41+
42+
| Method | Returns | Description |
43+
|---|---|---|
44+
| `ok()` | `bool` | `true` if the operation succeeded |
45+
| `timeout()` | `bool` | `true` if the operation timed out |
46+
| `value` | `std::optional<T>` | The result value (present when `ok()` is `true`) |
47+
48+
## GoalContext
49+
50+
| Method | Returns | Description |
51+
|---|---|---|
52+
| `goal()` | `const Goal&` | Access the goal request |
53+
| `is_canceling()` | `bool` | Check if cancellation was requested |
54+
| `publish_feedback(fb)` | `void` | Send feedback to the client |
55+
| `abort()` | `void` | Abort the goal |
56+
57+
## Event
58+
59+
| Method | Returns | Description |
60+
|---|---|---|
61+
| `set()` | `void` | Signal the event, resuming all waiters |
62+
| `clear()` | `void` | Reset the event so future `wait()` calls will suspend |
63+
| `wait()` | *awaitable* `void` | Suspends until the event is set |
64+
| `is_set()` | `bool` | Check the current state |
65+
66+
## Mutex
67+
68+
| Method | Returns | Description |
69+
|---|---|---|
70+
| `lock()` | *awaitable* `void` | Suspends until the lock is acquired |
71+
| `unlock()` | `void` | Release the lock, resuming the next waiter |
72+
| `is_locked()` | `bool` | Check the current state |
73+
74+
## Channel
75+
76+
| Method | Returns | Description |
77+
|---|---|---|
78+
| `send(value)` | `void` | Send a value (thread-safe) |
79+
| `close()` | `void` | Signal end of stream |
80+
| `next()` | *awaitable* `optional<T>` | Receive the next value (`nullopt` when closed) |
81+
82+
## TfBuffer
83+
84+
| Method | Returns | Description |
85+
|---|---|---|
86+
| `TfBuffer(ctx)` | -- | Construct with a `CoContext`; starts a listener thread |
87+
| `lookup_transform(target, source)` | `optional<TransformStamped>` | Sync lookup of latest transform |
88+
| `lookup_transform(target, source, time)` | *awaitable* `TransformStamped` | Async lookup; suspends until available |

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ The standard `rclcpp::spin()` drives execution -- no special executor needed.
5353
5454
- **[Getting Started](getting-started.md)** -- prerequisites, installation, and a walkthrough of the Quick Start example
5555
- **[Guide](guide.md)** -- topics, services, actions, concurrency primitives, cancellation, and TF lookups
56+
- **[API Reference](api-reference.md)** -- full list of public types and methods

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ nav:
66
- Home: index.md
77
- Getting Started: getting-started.md
88
- Guide: guide.md
9+
- API Reference: api-reference.md
910

1011
theme:
1112
name: material

0 commit comments

Comments
 (0)