Skip to content

Commit 1d1e7c5

Browse files
shahram95nevalsar
andauthored
Add Robotics Vision, SLAM, and ML Optimization Guides to Wiki (#196)
Adds a large set of new robotics technical guides and integrates them into section discoverability and navigation. - add new guides across sections: - wiki/machine-learning/ (pose estimation, quantization/TensorRT, ARM deployment, augmentation, Kornia, distillation, pruning, MTL, optical flow, 3D DL, Kalman tracking, LLM+Franka integration) - wiki/sensing/ (ZED setup, neural depth sensing, CUDA PCL acceleration) - wiki/state-estimation/ (ORB-SLAM3 install and troubleshooting) - wiki/interfacing/ (Streamlit + ROS2 + web visualization integration) - normalize filename hygiene for new wiki docs to kebab-case: - 6d-pose-tracking-yolo-zed.md - accelerating-point-cloud-processing-with-cuda-pcl.md - update _data/navigation.yml entries for all added pages and resolved path consistency - update section index pages to include discoverability links: - wiki/machine-learning/index.md - wiki/sensing/index.md - wiki/state-estimation/index.md - wiki/interfacing/index.md --------- Co-authored-by: Nevin Valsaraj <nevin.valsaraj32@gmail.com>
1 parent 84d8135 commit 1d1e7c5

22 files changed

Lines changed: 3891 additions & 3 deletions

_data/navigation.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ wiki:
156156
url: /wiki/sensing/thermal-cameras/
157157
- title: Tracking vehicles using a static traffic camera
158158
url: /wiki/sensing/trajectory-extraction-static-camera/
159+
- title: Setting Up the ZED Camera with ROS and troubleshooting steps
160+
url: /wiki/sensing/setting-up-the-zed-camera-with-ros.md
161+
- title: Neural Depth Sensing in ZED Stereo Cameras
162+
url: /wiki/sensing/neural-depth-sensing-in-zed.md
163+
- title: Accelerating Point Cloud Processing with CUDA PCL (cuPCL)
164+
url: /wiki/sensing/accelerating-point-cloud-processing-with-cuda-pcl.md
159165
- title: Actuation
160166
url: /wiki/actuation/
161167
children:
@@ -204,6 +210,30 @@ wiki:
204210
url: /wiki/machine-learning/mediapipe-live-ml-anywhere.md/
205211
- title: NLP for robotics
206212
url: /wiki/machine-learning/nlp_for_robotics.md/
213+
- title: 6D Pose Estimation with YOLO and ZED
214+
url: /wiki/machine-learning/6d-pose-tracking-yolo-zed.md
215+
- title: Practical Guide to Model Quantization and TensorRT Optimization
216+
url: /wiki/machine-learning/practical-guide-to-model-quantization-and-tensorrt-optimization.md
217+
- title: Installing YOLO on ARM Architecture Devices
218+
url: /wiki/machine-learning/installing-yolo-on-arm-architecture-devices.md
219+
- title: Comprehensive guide to albumentations
220+
url: /wiki/machine-learning/comprehensive-guide-to-albumentations.md
221+
- title: Kornia technical guide
222+
url: /wiki/machine-learning/kornia-technical-guide.md
223+
- title: Integrating OLLAMA LLMs with Franka Arm
224+
url: /wiki/machine-learning/integrating-ollama-llms-with-franka-arm.md
225+
- title: Multi-task learning A starter guide
226+
url: /wiki/machine-learning/multitask-learning-starter.md
227+
- title: Understanding Kalman Filters and Visual Tracking
228+
url: /wiki/machine-learning/understanding-kalman-filters-and-visual-tracking.md
229+
- title: Knowledge Distillation practical implementation guide
230+
url: /wiki/machine-learning/knowledge-distillation-practical-implementation-guide.md
231+
- title: Neural Network optimization using model pruning
232+
url: /wiki/machine-learning/neural-network-optimization-using-model-pruning.md
233+
- title: Deep learning techniques for 3D datasets
234+
url: /wiki/machine-learning/deep-learning-techniques-for-3d-datasets.md
235+
- title: Optical Flow - Classical to Deep Learning Implementation
236+
url: /wiki/machine-learning/optical-flow-classical-to-deep-learning-implementation.md
207237
- title: State Estimation
208238
url: /wiki/state-estimation/
209239
children:
@@ -225,6 +255,8 @@ wiki:
225255
url: /wiki/state-estimation/lio-sam-velocity-undistortion-and-dynamic-filtering/
226256
- title: Running SLAM in Production - A Practitioner's Guide
227257
url: /wiki/state-estimation/running-slam-in-production/
258+
- title: Complete Guide to Installing ORB SLAM3
259+
url: /wiki/state-estimation/orb-slam3-setup-and-troubleshoot-guide.md
228260
- title: Programming
229261
url: /wiki/programming/
230262
children:
@@ -291,6 +323,8 @@ wiki:
291323
url: /wiki/interfacing/microros-for-ros2-on-microcontrollers/
292324
- title: ROS 1 - ROS 2 Bridge
293325
url: /wiki/interfacing/ros1-ros2-bridge/
326+
- title: Interfacing Streamlit, ROS2, and HTML/CSS/JS for visualization
327+
url: /wiki/interfacing/interfacing-streamlit-ros2-and-html-css-js-for-visualization/
294328
- title: Computing
295329
url: /wiki/computing/
296330
children:

wiki/interfacing/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ This section delves into **interfacing techniques and tools** for robotics appli
2727
- **[ROS 1 - ROS 2 Bridge](/wiki/interfacing/ros1-ros2-bridge/)**
2828
A detailed walkthrough of setting up the ROS 1 bridge to enable communication between ROS 1 and ROS 2 environments. Discusses dynamic and static bridges, installation tips, and best practices for sourcing. Also includes guidance for Docker-based deployment and examples of bridging specific topics and services.
2929

30+
- **[Interfacing Streamlit, ROS2, and HTML/CSS/JS for Visualizations](/wiki/interfacing/interfacing-streamlit-ros2-and-html-css-js-for-visualization/)**
31+
A practical architecture and implementation guide for combining Streamlit, ROS2, and web components to build real-time robotics visualization dashboards.
32+
3033
## Resources
3134

3235
### General Tools and Frameworks
@@ -42,4 +45,4 @@ This section delves into **interfacing techniques and tools** for robotics appli
4245
### Advanced Topics
4346
- [Building and Bridging Custom ROS Message Types](https://docs.ros.org/en/galactic/Tutorials/Creating-Custom-Msgs.html)
4447
- [Sensor Integration with ROS](https://wiki.ros.org/Sensors)
45-
- [Managing Transient Connectivity in micro-ROS](https://micro.ros.org/docs/tutorials/advanced/transient_connectivity/)
48+
- [Managing Transient Connectivity in micro-ROS](https://micro.ros.org/docs/tutorials/advanced/transient_connectivity/)
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
---
2+
date: 2024-12-22
3+
title: Interfacing Streamlit, ROS2, and HTML/CSS/JS for Visualizations
4+
---
5+
6+
# Interfacing Streamlit, ROS2, and HTML/CSS/JS for Visualizations
7+
8+
## Introduction
9+
10+
Modern robotics applications demand sophisticated visualization and control interfaces that can handle real-time data while providing rich interactive features. This guide explores the integration of Streamlit, ROS2, and web technologies to create a powerful, real-time robotics visualization dashboard. By combining these technologies, we can create interfaces that are both functional and user-friendly, while maintaining the robust communication capabilities required for robotics applications.
11+
12+
## System Architecture Overview
13+
14+
The integration of Streamlit with ROS2 and web visualizations creates a multi-layered architecture that balances performance with functionality. At its core, the system uses ROS2 for reliable robotics communication, Streamlit for rapid interface development, and custom web components for rich visualizations. This architecture enables real-time data flow while maintaining system responsiveness and user interaction capabilities.
15+
16+
The key components interact through a carefully designed communication layer that consists of:
17+
18+
The ROS2 Backend manages robot communication and data flow, serving as the foundation for all robotics operations. The Streamlit Frontend provides the user interface framework, enabling rapid development of interactive features. Custom Web Components enable rich interactive visualizations, while the State Management system coordinates data flow between all components.
19+
20+
### Technology Stack Deep Dive
21+
22+
The system relies on several key technologies, each serving a specific purpose in the architecture. ROS2 provides the foundation for robotic system communication, offering reliable publish-subscribe patterns and service-based interactions. Streamlit serves as the primary web framework, chosen for its Python-native approach and rapid development capabilities. The WebSocket protocol enables real-time communication between the web interface and ROS2 system, while custom JavaScript components provide rich visualization capabilities.
23+
24+
## Implementation Guide
25+
26+
### 1. Foundation Setup
27+
28+
The project structure needs to support both development workflow and runtime requirements. Here's the recommended organization:
29+
30+
```plaintext
31+
project_root/
32+
├── src/
33+
│ ├── frontend/
34+
│ │ ├── components/
35+
│ │ ├── pages/
36+
│ ├── ros/
37+
│ │ ├── nodes/
38+
│ └── shared/
39+
├── static/
40+
└── config/
41+
```
42+
43+
This structure provides clear separation of concerns while maintaining easy access to shared resources. Each directory serves a specific purpose in the application's architecture, allowing for modular development and easy maintenance.
44+
45+
### 2. ROS2 Integration Layer
46+
47+
The ROS2 integration represents a critical aspect of the system. Here's a comprehensive implementation:
48+
49+
```python
50+
class ROSInterface:
51+
def __init__(self):
52+
# Initialize ROS2 node
53+
rclpy.init()
54+
self.node = Node('visualization_interface')
55+
56+
# Thread-safe state management
57+
self.state_lock = threading.Lock()
58+
self.shared_state = {}
59+
60+
# Set up message filters and synchronization
61+
self.sync_filters = {}
62+
self.subscribers = {}
63+
64+
# Initialize communication interfaces
65+
self._setup_communications()
66+
67+
def _setup_communications(self):
68+
"""Configure ROS2 publishers/subscribers with thread safety"""
69+
# Set up main data subscribers
70+
self.subscribers['telemetry'] = self.node.create_subscription(
71+
TelemetryMsg,
72+
'/robot/telemetry',
73+
self._telemetry_callback,
74+
qos_profile=qos.QoSProfile(
75+
reliability=qos.ReliabilityPolicy.BEST_EFFORT,
76+
durability=qos.DurabilityPolicy.VOLATILE,
77+
history=qos.HistoryPolicy.KEEP_LAST,
78+
depth=10
79+
)
80+
)
81+
```
82+
83+
### 3. WebSocket Bridge Implementation
84+
85+
The WebSocket bridge enables real-time communication between ROS2 and the web interface:
86+
87+
```python
88+
class WebSocketBridge:
89+
def __init__(self, host='localhost', port=9090):
90+
self.host = host
91+
self.port = port
92+
self.connections = set()
93+
self.message_handlers = {}
94+
95+
# Set up asyncio event loop
96+
self.loop = asyncio.get_event_loop()
97+
self.server = None
98+
99+
async def start_server(self):
100+
"""Initialize WebSocket server with error handling"""
101+
try:
102+
self.server = await websockets.serve(
103+
self._handle_connection,
104+
self.host,
105+
self.port,
106+
ping_interval=20,
107+
ping_timeout=30
108+
)
109+
print(f"WebSocket server running on ws://{self.host}:{self.port}")
110+
except Exception as e:
111+
print(f"Failed to start WebSocket server: {e}")
112+
raise
113+
```
114+
115+
### 4. Interactive Visualization Component
116+
117+
The visualization component handles rendering and user interaction:
118+
119+
```javascript
120+
class RobotVisualizer {
121+
constructor(config) {
122+
// Initialize canvas layers
123+
this.mainCanvas = document.createElement('canvas');
124+
this.overlayCanvas = document.createElement('canvas');
125+
this.setupCanvasLayers();
126+
127+
// Initialize WebGL context
128+
this.gl = this.mainCanvas.getContext('webgl2');
129+
if (!this.gl) {
130+
throw new Error('WebGL2 not supported');
131+
}
132+
133+
// Set up rendering pipeline
134+
this.setupShaders();
135+
this.setupBuffers();
136+
this.setupInteraction();
137+
}
138+
139+
setupCanvasLayers() {
140+
// Configure canvas properties
141+
this.mainCanvas.style.position = 'absolute';
142+
this.overlayCanvas.style.position = 'absolute';
143+
144+
// Set up high-DPI support
145+
this.setupHighDPI();
146+
147+
// Configure canvas container
148+
this.container = document.createElement('div');
149+
this.container.style.position = 'relative';
150+
this.container.appendChild(this.mainCanvas);
151+
this.container.appendChild(this.overlayCanvas);
152+
}
153+
}
154+
```
155+
156+
### 5. State Management System
157+
158+
A robust state management implementation:
159+
160+
```python
161+
class SharedState:
162+
def __init__(self):
163+
self._state = {}
164+
self._callbacks = {}
165+
self._lock = threading.Lock()
166+
self._history = {}
167+
self._max_history = 1000
168+
169+
def subscribe(self, key, callback):
170+
"""Register callback for state changes"""
171+
with self._lock:
172+
if key not in self._callbacks:
173+
self._callbacks[key] = set()
174+
self._callbacks[key].add(callback)
175+
176+
def update(self, key, value, store_history=False):
177+
"""Thread-safe state update with history tracking"""
178+
with self._lock:
179+
self._state[key] = value
180+
181+
if store_history:
182+
if key not in self._history:
183+
self._history[key] = []
184+
self._history[key].append({
185+
'timestamp': time.time(),
186+
'value': value
187+
})
188+
189+
# Maintain history size
190+
if len(self._history[key]) > self._max_history:
191+
self._history[key].pop(0)
192+
193+
# Notify subscribers
194+
self._notify_subscribers(key, value)
195+
```
196+
197+
## Best Practices
198+
199+
### Error Handling
200+
201+
Implement comprehensive error handling throughout the system:
202+
203+
- Create error boundaries at component boundaries
204+
- Provide clear, actionable error messages
205+
- Handle network failures gracefully
206+
- Implement appropriate fallback behaviors
207+
- Log errors appropriately for debugging
208+
209+
### Resource Management
210+
211+
Proper resource management prevents memory leaks and ensures system stability:
212+
213+
- Clean up WebSocket connections when they're no longer needed
214+
- Manage canvas and WebGL resources efficiently
215+
- Implement proper memory management strategies
216+
- Handle component lifecycle events appropriately
217+
- Monitor system resource usage
218+
219+
## Conclusion
220+
221+
The integration of Streamlit, ROS2, and web visualizations provides a powerful foundation for building sophisticated robotics interfaces. Success with this architecture requires careful attention to threading and state management, implementation of appropriate optimization strategies, adherence to best practices for resource management, and regular monitoring and performance optimization.
222+
223+
Remember to adapt these patterns to your specific use case while maintaining the core principles of performance, reliability, and maintainability. Regular testing and monitoring of the system will help ensure it continues to meet the demands of modern robotics visualization requirements.

0 commit comments

Comments
 (0)