Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a62729e
Cleanup
ahmed-elbary Nov 4, 2025
ef129f3
Merge pull request #63 from jondave/ros2-devel
jondave Nov 4, 2025
a3fe180
Initial plan
Copilot Nov 10, 2025
0c8ac67
Add comprehensive concept architecture for Sentor-Nav2 integration
Copilot Nov 10, 2025
f9c36e4
Add integration summary and update README with references
Copilot Nov 10, 2025
d2baf0a
Add comprehensive integration diagrams documentation
Copilot Nov 10, 2025
ab6ff25
Enhance README with detailed integration documentation links
Copilot Nov 10, 2025
8aec75a
Add sentor_guard package design with Python/C++ guard libraries
Copilot Nov 16, 2025
5652f05
Add sentor_guard package prototype implementation
Copilot Nov 16, 2025
4981791
Merge branch 'fix_submodule' into copilot/develop-concept-architectur…
marc-hanheide Nov 16, 2025
92e9153
Merge branch 'fix_submodule' into copilot/develop-concept-architectur…
marc-hanheide Nov 16, 2025
7fa0c4c
Merge branch 'master' into copilot/develop-concept-architecture-sentor
marc-hanheide Nov 16, 2025
4d37967
Add @sentor_guarded decorator for function-level guard enforcement
Copilot Nov 16, 2025
0cb7881
Fix C++ compilation issues in sentor_guard nodes
Copilot Nov 16, 2025
3eb0b1f
Add user 'ros' with sudo privileges and update Dockerfile configuration
marc-hanheide Nov 17, 2025
ebd7516
Merge branch 'master' of https://github.com/LCAS/sentor into copilot/…
marc-hanheide Nov 17, 2025
50882cd
Refactor SentorGuard constructors for improved clarity and default op…
marc-hanheide Nov 17, 2025
621475b
Initial plan
Copilot Nov 17, 2025
2389a36
Add Nav2 behavior tree integration for sentor_guard
Copilot Nov 17, 2025
a4171a7
Update integration documentation with BT implementation details
Copilot Nov 17, 2025
99fe0a4
Add test scripts and demos for Nav2 integration
Copilot Nov 17, 2025
6d32f32
Add comprehensive Nav2 BT integration guide
Copilot Nov 17, 2025
e700930
Update Dockerfile and post-create script for improved dependency mana…
marc-hanheide Nov 17, 2025
9ba21e1
Update submodule reference and enhance package.xml for Nav2 integration
marc-hanheide Nov 17, 2025
2c3137e
Update submodule reference and disable automatic lint test dependency…
marc-hanheide Nov 17, 2025
a521ea7
Enhance test for SentorGuard by spinning multiple times to process al…
marc-hanheide Nov 17, 2025
3cf17a3
Update subproject reference in RobotStateMachine
marc-hanheide Nov 17, 2025
86d2782
Add colcon_defaults.yaml for test and build configuration
marc-hanheide Nov 17, 2025
e6de320
Simplify guard architecture to monitor only RobotStateMachine topics
Copilot Nov 24, 2025
280cefe
Fix BT condition node to use simplified guard API
Copilot Nov 24, 2025
d57fa80
Add blocking reason publisher with call stack tracking to guards
Copilot Nov 24, 2025
8c7c43f
Fix CMake duplicate target error by removing redundant ament_python_i…
Copilot Nov 24, 2025
4e28243
Restore GuardStatus message with proper message generation setup
Copilot Nov 25, 2025
c3ef551
Refactor guard implementation to use sentor_msgs and add GuardStatus …
marc-hanheide Nov 25, 2025
9a9406a
Add error handling for missing ROS2 node in CheckAutonomyAllowedFactory
marc-hanheide Nov 25, 2025
4e15702
re-added python
marc-hanheide Nov 25, 2025
928f018
fixed Python tests confirmed working
marc-hanheide Nov 25, 2025
4be8594
Revert "Fix submodule configuration for RobotStateMachine"
jondave Dec 1, 2025
ba8d696
Merge pull request #70 from LCAS/revert-66-fix_submodule
jondave Dec 1, 2025
a705eb6
Merge pull request #69 from LCAS/ros2-devel
jondave Dec 1, 2025
7c35aab
Initial plan
Copilot Nov 10, 2025
f90aaec
Add comprehensive concept architecture for Sentor-Nav2 integration
Copilot Nov 10, 2025
434f6a7
Add integration summary and update README with references
Copilot Nov 10, 2025
ad2a57b
Add comprehensive integration diagrams documentation
Copilot Nov 10, 2025
aee12e4
Enhance README with detailed integration documentation links
Copilot Nov 10, 2025
72dd5bb
Add sentor_guard package design with Python/C++ guard libraries
Copilot Nov 16, 2025
05e6d30
Add sentor_guard package prototype implementation
Copilot Nov 16, 2025
e58b8b7
Add @sentor_guarded decorator for function-level guard enforcement
Copilot Nov 16, 2025
74054d4
Fix C++ compilation issues in sentor_guard nodes
Copilot Nov 16, 2025
5e584c8
Refactor SentorGuard constructors for improved clarity and default op…
marc-hanheide Nov 17, 2025
404576e
Initial plan
Copilot Nov 17, 2025
6c59cde
Add Nav2 behavior tree integration for sentor_guard
Copilot Nov 17, 2025
dac2957
Update integration documentation with BT implementation details
Copilot Nov 17, 2025
95b0aa6
Add test scripts and demos for Nav2 integration
Copilot Nov 17, 2025
05fabe5
Add comprehensive Nav2 BT integration guide
Copilot Nov 17, 2025
cd0082e
Update Dockerfile and post-create script for improved dependency mana…
marc-hanheide Nov 17, 2025
b72369c
Update submodule reference and enhance package.xml for Nav2 integration
marc-hanheide Nov 17, 2025
df43523
Update submodule reference and disable automatic lint test dependency…
marc-hanheide Nov 17, 2025
5498457
Enhance test for SentorGuard by spinning multiple times to process al…
marc-hanheide Nov 17, 2025
5f023e1
Add colcon_defaults.yaml for test and build configuration
marc-hanheide Nov 17, 2025
81c38bf
Simplify guard architecture to monitor only RobotStateMachine topics
Copilot Nov 24, 2025
13b32ad
Fix BT condition node to use simplified guard API
Copilot Nov 24, 2025
a75d236
Add blocking reason publisher with call stack tracking to guards
Copilot Nov 24, 2025
8111c10
Fix CMake duplicate target error by removing redundant ament_python_i…
Copilot Nov 24, 2025
f855239
Restore GuardStatus message with proper message generation setup
Copilot Nov 25, 2025
cded4bc
Refactor guard implementation to use sentor_msgs and add GuardStatus …
marc-hanheide Nov 25, 2025
8071f07
Add error handling for missing ROS2 node in CheckAutonomyAllowedFactory
marc-hanheide Nov 25, 2025
2a0a8e5
re-added python
marc-hanheide Nov 25, 2025
8379b34
fixed Python tests confirmed working
marc-hanheide Nov 25, 2025
bab064d
Merge branch 'copilot/develop-concept-architecture-sentor' of https:/…
jondave Dec 1, 2025
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN find /tmp/src -type f \! -name "package.xml" -print | xargs rm -rf
FROM base AS depbuilder
# copy the reduced source tree (only package.xml) from previous stage
COPY --from=sourcefilter /tmp/src /tmp/src
RUN rosdep update --rosdistro ${ROS_DISTRO} && apt-get update
RUN rosdep update --rosdistro ${ROS_DISTRO} && apt-get update && apt-get upgrade --no-install-recommends -y
RUN cd /tmp/src && rosdep install --from-paths . --ignore-src -r -y && cd && rm -rf /tmp/src

FROM depbuilder AS final
Expand Down
5 changes: 5 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function add_git_config_if_not_exist {

add_config_if_not_exist "source /opt/ros/$ROS_DISTRO/setup.bash"

rosdep update --rosdistro $ROS_DISTRO

sudo apt-get update && sudo apt-get upgrade --no-install-recommends -y
rosdep install --from-paths src/ --ignore-src -r -y

source /opt/ros/$ROS_DISTRO/setup.bash

colcon build --symlink-install --continue-on-error || true
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/ros-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ jobs:
container:
image: ${{ matrix.docker_image }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1
token: ${{ secrets.ORGA_GH_TOKEN }}

- uses: actions/checkout@v3
- name: setup ROS environment
uses: LCAS/setup-ros@master
with:
Expand All @@ -69,6 +65,6 @@ jobs:
if: ${{ matrix.ros_version == 2 }}
uses: ros-tooling/action-ros-ci@v0.3
with:
import-token: ${{ secrets.ORGA_GH_TOKEN }}
import-token: ${{ github.token }}
target-ros2-distro: ${{ matrix.ros_distribution }}
skip-tests: true
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1,251 changes: 1,251 additions & 0 deletions ARCHITECTURE_INTEGRATION.md

Large diffs are not rendered by default.

340 changes: 340 additions & 0 deletions INTEGRATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
# Integration Summary: Sentor + RobotStateMachine + Nav2

## Quick Reference Guide

This document provides a high-level overview of the proposed integration architecture. For complete details, see [ARCHITECTURE_INTEGRATION.md](ARCHITECTURE_INTEGRATION.md).

---

## Core Safety Requirement

Autonomous navigation is permitted **ONLY** when:

```python
robot_state == "active" AND autonomous_mode == True
```

Additionally recommended:
```python
safety_heartbeat == True AND warning_heartbeat == True
```

Any violation must immediately stop the robot and cancel navigation.

---

## System Components

| Component | Role | Key Output |
|-----------|------|------------|
| **RobotStateMachine** | Manages robot operational state and mode | `/robot_state`, `/autonomous_mode` |
| **Sentor** | Monitors system health | `/safety/heartbeat`, `/warning/heartbeat` |
| **Safety Controller** (NEW) | Coordinates safety conditions with Nav2 | Lifecycle management, goal cancellation |
| **sentor_guard** (NEW) | Reusable safety libraries and nodes | Python/C++ guards, topic filters, lifecycle mgmt |
| **Nav2** | Autonomous navigation | Navigation goals, motion commands |

---

## Architecture Overview

```
RobotStateMachine ──┐
├──> Safety Controller ──> Nav2 ──> Robot Base
Sentor ─────────────┘
```

**Safety Controller** is the new component that:
1. Subscribes to all safety condition topics
2. Controls Nav2 activation/deactivation based on conditions
3. Cancels navigation goals when conditions become invalid
4. Optionally filters velocity commands as last-resort safety

---

## Integration Approach: Multi-Layer Safety

### Layer 1: Lifecycle Management (Primary)
- Safety Controller activates/deactivates Nav2 based on safety conditions
- Uses **sentor_guard** libraries for condition checking
- Clean, well-defined ROS2 pattern
- ~100-500ms response time

### Layer 2: Behavior Tree Integration (✅ Implemented)
- `CheckAutonomyAllowed` BT condition node checks safety in Nav2
- Uses **sentor_guard** C++ library for condition evaluation
- Faster response (~50-100ms) with continuous monitoring
- Enables graceful pause/resume of navigation
- Integrates via standard BehaviorTree.CPP plugin mechanism
- Example BTs and launch files provided in `sentor_guard/examples/nav2_examples/`

### Layer 3: cmd_vel Filter (Emergency Backup)
- **sentor_guard** Topic Guard node filters cmd_vel
- Zeros velocity commands when unsafe
- <50ms response time
- Last line of defense

### Additional: Application-Level Guards
- **sentor_guard** Python/C++ libraries in user code
- Context managers and RAII patterns
- Blocks execution until safe
- Defense in depth throughout the system

---

## State Transition Examples

### Normal Operation
```
1. autonomous_mode ← true
2. robot_state ← "active"
3. All monitors healthy (heartbeats ← true)
4. Safety Controller activates Nav2
5. Navigation goals accepted and executed
```

### Emergency Stop
```
1. Emergency button pressed → robot_state ← "emergency_stop"
2. Safety Controller detects change (< 100ms)
3. Cancels active Nav2 goals (< 200ms)
4. Optionally zeros cmd_vel (< 50ms)
5. Robot stops (< 500ms total)
```

### Sensor Failure
```
1. Critical sensor stops publishing
2. Sentor detects failure → warning_heartbeat ← false
3. Safety Controller cancels navigation
4. Robot stops
5. After recovery + timeout → System ready again
```

---

## Key Timing Requirements

| Event | Target Latency | Critical |
|-------|----------------|----------|
| State change detection | < 100ms | YES |
| Goal cancellation | < 200ms | YES |
| Total stop time | < 500ms | YES |
| Recovery after fault | < 15s | NO |

---

## Implementation Phases

### Phase 1: sentor_guard Package (HIGH PRIORITY)
- Create **`sentor_guard`** package with reusable libraries
- Implement Python guard library (context manager pattern)
- Implement C++ guard library (RAII pattern)
- Add topic guard node and lifecycle guard node
- Include configuration examples and launch files

### Phase 2: Sentor Configuration (HIGH PRIORITY)
- Create Nav2-specific monitoring configuration
- Define which topics/nodes are safety-critical vs autonomy-critical
- Set appropriate timeouts

### Phase 3: Safety Controller (HIGH PRIORITY)
- Create `sentor_safety_controller` package
- Use **sentor_guard** libraries for condition evaluation
- Add Nav2 lifecycle management
- Add goal cancellation capability

### Phase 4: Nav2 BT Plugin (✅ COMPLETED)
- ✅ Created `CheckAutonomyAllowed` BT condition node
- ✅ Integrated with **sentor_guard** C++ library
- ✅ Added optional BehaviorTree.CPP dependency
- ✅ Created example behavior tree XML files
- ✅ Comprehensive integration documentation
- See: `src/sentor_guard/examples/nav2_examples/`

### Phase 5: Testing & Validation (HIGH PRIORITY)
- Simulation testing
- Hardware validation
- Performance benchmarking

---

## Sentor Configuration Example

```yaml
monitors:
# Autonomy-critical: Required for navigation
- name: "/scan"
message_type: "sensor_msgs/msg/LaserScan"
rate: 10.0
signal_when:
condition: "published"
timeout: 1.0
autonomy_critical: true

# Safety-critical: Required for safety
- name: "/emergency_stop"
message_type: "std_msgs/msg/Bool"
rate: 5.0
signal_lambdas:
- expression: "lambda x: x.data == False"
timeout: 0.5
safety_critical: true

node_monitors:
- name: "/controller_server"
timeout: 2.0
autonomy_critical: true

- name: "/safety_controller"
timeout: 2.0
safety_critical: true
```

---

## Failure Modes to Address

1. **Safety Controller crashes** → Nav2 continues without oversight
- *Mitigation*: Monitor Safety Controller with Sentor, implement watchdog

2. **Topic communication failure** → Stale safety data
- *Mitigation*: Implement message age checks, use reliable QoS

3. **Nav2 lifecycle service fails** → Nav2 stays active
- *Mitigation*: Fallback to cmd_vel filter, implement retry logic

4. **Race conditions** → Inconsistent state
- *Mitigation*: Proper state machine, debouncing, thread-safe access

5. **Network congestion** → Delayed reactions
- *Mitigation*: QoS policies, DDS priorities, dedicated network

---

## Key Design Principles

1. **Defense in Depth**: Multiple independent safety layers
2. **Fail Safe**: System defaults to stopped/inactive on any failure
3. **Fast Response**: Sub-500ms reaction to safety violations
4. **Standard Patterns**: Uses ROS2 lifecycle, actions, and topics
5. **No Nav2 Modification**: Primary approach doesn't require Nav2 changes
6. **Comprehensive Logging**: All state changes logged for analysis

---

## Quick Start: Using the Nav2 BT Integration

The `CheckAutonomyAllowed` behavior tree condition node is now available for direct integration with Nav2. Here's how to use it:

### 1. Build with BT support
```bash
# Install BehaviorTree.CPP if needed
sudo apt install ros-$ROS_DISTRO-behaviortree-cpp

# Build sentor_guard
cd ~/ros2_ws
colcon build --packages-select sentor_guard
source install/setup.bash
```

### 2. Configure Nav2 to load the plugin

Add to your `bt_navigator` parameters:
```yaml
bt_navigator:
ros__parameters:
plugin_lib_names:
# ... other Nav2 plugins ...
- sentor_guard_bt_nodes # Add this line
default_nav_to_pose_bt_xml: /path/to/your/behavior_tree.xml
```

### 3. Use in your behavior tree

Simple pre-navigation check:
```xml
<Sequence>
<CheckAutonomyAllowed required_state="active"/>
<ComputePathToPose goal="{goal}" path="{path}"/>
<FollowPath path="{path}"/>
</Sequence>
```

Continuous monitoring with pause/resume:
```xml
<PipelineSequence>
<RateController hz="2.0">
<CheckAutonomyAllowed required_state="active"/>
</RateController>
<ComputePathToPose goal="{goal}" path="{path}"/>
<FollowPath path="{path}"/>
</PipelineSequence>
```

### 4. See complete examples

Full working examples with launch files and documentation:
- `src/sentor_guard/examples/nav2_examples/navigate_with_guard.xml` - Complete BT with recovery
- `src/sentor_guard/examples/nav2_examples/simple_nav_with_guard.xml` - Minimal example
- `src/sentor_guard/examples/nav2_examples/README.md` - Detailed integration guide

---

## Next Steps

1. **Review and approve** this architecture concept
2. **Create Safety Controller package** with basic functionality
3. **Test in simulation** with mock RobotStateMachine
4. **Develop Sentor configuration** for your specific robot/Nav2 setup
5. **Validate timing** on target hardware
6. **Deploy incrementally** with thorough testing at each phase

---

## Questions to Address

Before implementation, clarify:

1. **State Values**: What are the exact state strings used by RobotStateMachine?
- e.g., "active", "paused", "emergency_stop", "idle"?

2. **Topic Names**: Confirm final topic names for:
- `/robot_state`
- `/autonomous_mode`
- Nav2 namespaces

3. **QoS Requirements**: What reliability/durability needed for safety topics?

4. **Hardware Platform**: What is the target compute platform?
- Affects timing validation

5. **Nav2 Configuration**: Are there specific Nav2 customizations already in place?

6. **Recovery Policy**: Should navigation automatically resume after recovery or wait for new goals?
- **Recommendation**: Wait for explicit new goals (safer)

---

## References

- **Full Architecture Document**: [ARCHITECTURE_INTEGRATION.md](ARCHITECTURE_INTEGRATION.md)
- **sentor_guard Package Design**: [docs/SENTOR_GUARD_DESIGN.md](docs/SENTOR_GUARD_DESIGN.md)
- **Integration Diagrams**: [docs/INTEGRATION_DIAGRAMS.md](docs/INTEGRATION_DIAGRAMS.md)
- **Sentor Documentation**: [README.md](README.md)
- **RobotStateMachine**: https://github.com/LCAS/RobotStateMachine
- **Nav2 Documentation**: https://docs.nav2.org/
- **ROS2 Lifecycle**: https://design.ros2.org/articles/node_lifecycle.html

---

## Contact and Feedback

For questions or suggestions about this architecture:
- Open an issue in the sentor repository
- Reference issue LCAS/sentor#[issue_number]

---

*Document Version: 1.0*
*Date: 2025-11-10*
*Status: Concept Proposal*
Loading