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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ The differentiation-based filter is `DiffFilter` in `drone_estimators.estimator_
### ROS 2 node

```bash
python -m drone_estimators.ros_nodes.ros2_node --drone_name cf1 --estimator_type ukf
python -m drone_estimators.ros_nodes.ros2_node --drone_name cf1 --estimator_type diff
python -m drone_estimators.ros_nodes.ros2_node --settings path/to/estimators.toml
python -m drone_estimators.ros.node --drone_name cf1 --estimator_type ukf
python -m drone_estimators.ros.node --drone_name cf1 --estimator_type diff
python -m drone_estimators.ros.node --settings path/to/estimators.toml
```

The settings are read from [`estimators.toml`](drone_estimators/ros_nodes/estimators.toml). To estimate several drones, add one `[estimatorX]` section per drone and pass your file with `--settings`. Drones with identical settings are batched into one estimator.
The settings are read from [`estimators.toml`](drone_estimators/ros/estimators.toml). To estimate several drones, add one `[estimatorX]` section per drone and pass your file with `--settings`. Drones with identical settings are batched into one estimator.

The node subscribes to `/tf` (e.g., from [motion_capture_tracking](https://github.com/learnsyslab/motion_capture_tracking)) and to `/drones/<name>/command` (roll, pitch, yaw in deg and thrust in PWM, needed by the UKF). It publishes the estimates to `/drones/<name>/estimate/{pose,twist,wrench,rotor_vel}`. The node only communicates with nodes on the same machine (`ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST`).

Expand All @@ -113,7 +113,7 @@ To read the estimates in Python without blocking, use the `ROSConnector`:
```python
import rclpy

from drone_estimators.ros_nodes.ros2_connector import ROSConnector
from drone_estimators.ros import ROSConnector

rclpy.init()
conn = ROSConnector(estimator_names=["cf1"], timeout=10.0)
Expand Down
10 changes: 5 additions & 5 deletions docs/get-started/ros2.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ The type and IP address of the motion capture system are set in the [configurati
Start the estimator for a single drone with

```bash
python -m drone_estimators.ros_nodes.ros2_node --drone_name cf1
python -m drone_estimators.ros.node --drone_name cf1
```

The node waits until it has received a first pose of every drone, initializes the estimators with it, and then runs at a fixed frequency. Add `--estimator_type diff` to use the differentiation-based filter instead of the UKF, `--estimator_type ekf` to use the EKF, or `--estimator_type ukf` to force the UKF.

The settings of the estimators are read from a TOML file. By default, the node uses the [estimators.toml](https://github.com/learnsyslab/drone-estimators/blob/main/drone_estimators/ros_nodes/estimators.toml) that ships with the package:
The settings of the estimators are read from a TOML file. By default, the node uses the [estimators.toml](https://github.com/learnsyslab/drone-estimators/blob/main/drone_estimators/ros/estimators.toml) that ships with the package:

```toml
--8<-- "drone_estimators/ros_nodes/estimators.toml"
--8<-- "drone_estimators/ros/estimators.toml"
```

To estimate several drones, add one `[estimatorN]` section per drone to your own copy of the file and pass it to the node. `--drone_name` and `--estimator_type` overwrite the settings of `estimator1`.

```bash
python -m drone_estimators.ros_nodes.ros2_node --settings path/to/estimators.toml
python -m drone_estimators.ros.node --settings path/to/estimators.toml
```

Estimators with identical settings (except for the drone name) run as one batched estimator.
Expand Down Expand Up @@ -75,7 +75,7 @@ The `ROSConnector` gives non-blocking access to the latest estimates from your o
```python
import rclpy

from drone_estimators.ros_nodes.ros2_connector import ROSConnector
from drone_estimators.ros import ROSConnector

if __name__ == "__main__": # The connector spawns processes, so guard the entry point
rclpy.init()
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ This section is generated from the docstrings of the source code with [mkdocstri
| `drone_estimators.filterpy` | Functional EKF and UKF predict and correct steps, adapted from [FilterPy](https://github.com/rlabbe/filterpy) |
| `drone_estimators.structs` | `EstimatorData` and the EKF and UKF settings |
| `drone_estimators.utils` | Batching, dynamics, and integration helpers |
| `drone_estimators.ros_nodes` | The ROS 2 estimator node, the `ROSConnector`, and message utilities |
| `drone_estimators.ros` | The ROS 2 estimator node, the `ROSConnector`, and message utilities |

Navigate the full reference using the sidebar.
5 changes: 5 additions & 0 deletions drone_estimators/ros/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""ROS 2 node and connector for the estimators."""

from drone_estimators.ros.connector import ROSConnector

__all__ = ["ROSConnector"]
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

from drone_estimators.estimator_diff import DiffFilter
from drone_estimators.estimator_kalman import KalmanFilter
from drone_estimators.ros_nodes.ros2_utils import (
from drone_estimators.ros.utils import (
append_measurement,
append_state,
create_array,
Expand Down Expand Up @@ -696,7 +696,7 @@ def launch_node(settings: Munch, stop_event: Event):
args = parser.parse_args()

if args.settings is None:
path = Path(__file__).parents[1] / "ros_nodes/estimators.toml"
path = Path(__file__).parent / "estimators.toml"
else:
path = args.settings
with open(path, "r") as f:
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion drone_estimators/ros_nodes/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
find = {}

[tool.setuptools.package-data]
drone_estimators = ["ros_nodes/*.toml"]
drone_estimators = ["ros/*.toml"]

[tool.pytest.ini_options]
markers = ["unit", "integration", "render"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import pytest

# Keep the test traffic on this machine, see ros2_node.py
# Keep the test traffic on this machine, see node.py
os.environ["ROS_AUTOMATIC_DISCOVERY_RANGE"] = "LOCALHOST"

import rclpy
Expand All @@ -21,7 +21,7 @@
from std_msgs.msg import Float64MultiArray
from tf2_msgs.msg import TFMessage

from drone_estimators.ros_nodes.ros2_connector import ROSConnector
from drone_estimators.ros import ROSConnector

if TYPE_CHECKING:
from collections.abc import Callable, Iterator
Expand All @@ -48,7 +48,7 @@ def fake() -> Iterator[SimpleNamespace]:
fake = SimpleNamespace(gate=f"gate_{uuid4().hex[:8]}", drone=f"cf_{uuid4().hex[:8]}")
fake.drone_tracked = True
rclpy.init()
node = rclpy.create_node("test_ros2_connector_" + uuid4().hex)
node = rclpy.create_node("test_connector_" + uuid4().hex)
tf_pub = node.create_publisher(TFMessage, "/tf", 10)
topic = f"/drones/{fake.drone}/estimate"
pose_pub = node.create_publisher(PoseStamped, f"{topic}/pose", 10)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_save_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from drone_estimators.estimator_diff import DiffFilter
from drone_estimators.estimator_kalman import KalmanFilter
from drone_estimators.ros_nodes.ros2_utils import append_state
from drone_estimators.ros.utils import append_state

DIFF_PARAMS = (0.0001, 0.007, 0.09, 0.005, 0.07) # As in the ROS node

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[
"drone_estimators.estimator_kalman",
"drone_estimators.estimator_diff",
"drone_estimators.ros_nodes.ros2_node",
"drone_estimators.ros.node",
],
)
def test_import_first(module: str):
Expand Down
Loading