[English | æĨæŽčŠ]
ðŊ Learning Path Overview
This comprehensive tutorial series will take you from beginner to expert in shared memory communication. Each tutorial builds upon the previous ones, providing practical examples and real-world applications.
ðââïļ Quick Navigation by Experience Level
Level | Focus | Recommended Tutorials | Time Required |
ðĨ Beginner | Basic concepts and simple examples | Pub/Sub basics â Service basics | 2-3 hours |
ðĨ Intermediate | Error handling and performance | Advanced features in each pattern | 4-5 hours |
ðĨ Advanced | Complex applications and optimization | Action communication + Custom patterns | 6+ hours |
ð Tutorial Series
ð Publisher/Subscriber Communication (Pub/Sub)
Best for: Real-time data streaming, sensor networks, event broadcasting
ð Complete Pub/Sub Guide
- ⥠Ultra-low latency: Microsecond-level communication
- ðĄ One-to-many broadcasting: Multiple subscribers per publisher
- ðŊ Zero-copy efficiency: Direct memory access patterns
- ðĄïļ Thread-safe operations: Concurrent publisher/subscriber handling
Key Features:
Publisher<SensorData> sensor_pub("robot_sensors");
sensor_pub.publish(sensor_reading);
Subscriber<SensorData> sensor_sub("robot_sensors");
bool success;
SensorData data = sensor_sub.subscribe(&success);
Perfect for:
- Robot sensor data streaming
- Real-time video/image processing
- High-frequency trading systems
- Live telemetry and monitoring
ðĪ Service Communication (Request-Response)
Best for: Reliable data exchange, RPC-style communication, synchronous operations
ð Complete Service Guide
- ð Guaranteed delivery: Request-response confirmation
- âąïļ Timeout management: Configurable response timeouts
- ð Retry mechanisms: Automatic failure recovery
- ðŊ Type safety: Compile-time request/response validation
Key Features:
ServiceServer<CalculationRequest, CalculationResult> calc_server("calculator");
ServiceClient<CalculationRequest, CalculationResult> calc_client("calculator");
if (calc_server.hasRequest()) {
auto request = calc_server.getRequest();
auto result = processCalculation(request);
calc_server.sendResponse(result);
}
calc_client.sendRequest(my_calculation);
if (calc_client.waitForResponse(5000000)) {
auto result = calc_client.getResponse();
}
Perfect for:
- Database query operations
- File processing services
- Configuration management
- Calculation services
⥠Action Communication (Long-Running Tasks)
Best for: Asynchronous operations, progress monitoring, cancellable tasks
ð Complete Action Guide
- ð Non-blocking execution: Asynchronous task processing
- ð Progress feedback: Real-time progress monitoring
- â Cancellation support: Graceful task termination
- ð State management: Comprehensive task lifecycle tracking
Key Features:
ActionServer<FileProcessingGoal, FileProcessingResult, FileProcessingFeedback> server("file_processor");
ActionClient<FileProcessingGoal, FileProcessingResult, FileProcessingFeedback> client("file_processor");
uint64_t goal_id = client.sendGoal(processing_goal);
while (!client.isComplete(goal_id)) {
FileProcessingFeedback feedback;
if (client.getFeedback(goal_id, feedback)) {
std::cout << "Progress: " << feedback.progress_percent << "%" << std::endl;
}
performOtherTasks();
if (shouldCancel()) {
client.cancelGoal(goal_id);
break;
}
}
Perfect for:
- Large file processing
- Machine learning training
- Complex computations
- Long-running data transformations
ðĻ Communication Pattern Comparison
When to Use Each Pattern
graph TD
A[Choose Communication Pattern] --> B{Data Size}
B -->|Small, Frequent| C{Reliability Need}
B -->|Large, Occasional| H[Action Communication]
C -->|Best Effort| D[Pub/Sub Communication]
C -->|Guaranteed| E{Processing Time}
E -->|Quick Response| F[Service Communication]
E -->|Long Running| G[Action Communication]
D --> I[ðĄ Real-time streaming<br/>ðŊ Event broadcasting<br/>⥠Ultra-low latency]
F --> J[ðĪ Database queries<br/>ð§ Configuration<br/>ð Quick calculations]
G --> K[ð File processing<br/>ð§ ML training<br/>âģ Long computations]
H --> K
Performance Characteristics
Aspect | Pub/Sub | Service | Action |
Latency | ~1Ξs | ~2-5Ξs | ~2-10Ξs |
Throughput | Very High | High | Medium |
Reliability | Best Effort | Guaranteed | Guaranteed |
Complexity | Low | Medium | High |
Use Case | Streaming | RPC | Workflows |
ð ïļ Getting Started
Prerequisites
# System requirements
g++ --version # GCC 7.0+ or equivalent
cmake --version # CMake 3.10+
Choose Your Starting Point
ð New to Inter-Process Communication?
Start here: ð Pub/Sub Tutorial
- Learn fundamental concepts
- Simple API introduction
- Immediate results
ð§ Need Reliable Communication?
Start here: ðĪ Service Tutorial
- Request-response patterns
- Error handling strategies
- Production-ready examples
⥠Building Complex Systems?
Start here: ⥠Action Tutorial
- Advanced async patterns
- State management
- Enterprise-grade features
ð Learning Progression
Phase 1: Foundation (ðĨ Beginner)
- Understanding Concepts: Read ð Introduction
- Quick Experience: Complete ð Quick Start
- Basic Pub/Sub: Master simple publisher/subscriber patterns
- Basic Service: Learn request-response communication
Phase 2: Proficiency (ðĨ Intermediate)
- Advanced Pub/Sub: Multi-threaded publishing, custom data types
- Robust Services: Error handling, timeouts, retry logic
- Performance Optimization: Benchmarking and tuning
- Integration Patterns: Combining multiple communication types
Phase 3: Mastery (ðĨ Advanced)
- Action Communication: Complex asynchronous workflows
- Custom Protocols: Building domain-specific communication
- System Architecture: Designing communication-heavy applications
- Performance Engineering: Micro-optimization and profiling
ð Cross-References
Related Topics
External Integration
- ROS Integration: Compatible with ROS message patterns
- Multi-Language: Seamless C++/Python interoperability
- Cross-Platform: Works on Linux, Windows (WSL), and macOS
ðĄ Success Tips
ðŊ Best Practices
- Start Simple: Begin with basic examples before complex scenarios
- Test Incrementally: Verify each component before integration
- Monitor Performance: Use built-in benchmarking tools
- Handle Errors: Implement proper error checking from the start
ðĻ Common Pitfalls to Avoid
- Topic Name Mismatches: Ensure exact string matching
- Data Type Inconsistencies: Use identical types across processes
- Resource Leaks: Rely on RAII for automatic cleanup
- Blocking Operations: Understand synchronous vs asynchronous patterns
ð Ready to Begin? Choose your first tutorial and start building lightning-fast inter-process communication systems! The power of microsecond-level communication awaits! âĻ