Id Counter Server
id_counter_server.py
Unique ID Generation Service – thread-safe counter persisted via ROS Parameter Server
This node provides a simple ROS service that hands out globally unique integer IDs to clients on demand. It stores the current counter in the ROS Parameter Server under id_client_counter, so the count survives node restarts, and uses a threading lock to serialize concurrent requests safely.
Interfaces (strongly-typed, stateful)
Interface |
Type |
Semantics |
---|---|---|
Service: |
|
Stateful RPC – returns the next integer in a persisted counter; the service maintains and updates its internal state (the counter) on each call. |
ROS Service
Service Name |
Type |
Description |
---|---|---|
|
|
Returns the next unique integer ID in the sequence. |
- class id_counter_server.IdCounterServer[source]
Bases:
object
Provides the /get_next_id service and manages the counter state.
Variables
- id_counterint
Current value of the ID counter (loaded from Parameter Server).
- _id_lockthreading.Lock
Ensures only one thread can increment id_counter at a time.
- id_servicerospy.Service
Service handle for /get_next_id.