Bridging with Native ROS¶
The Python ROS engine provides capabilities to discover and interact with native ROS nodes.
Bridge Architecture¶
The bridge enables communication between Python ROS Engine and native ROS systems:
graph LR A[Python ROS Engine] -- Message Translation --> B[(ROS Bridge)] B -- XMLRPC/Socket --> C[ROS Master] B -- TCP/UDP --> D[Native ROS Nodes] A -- TCP/UDP --> E[Native ROS Nodes]
Here's a sequence diagram showing the discovery process:
sequenceDiagram participant PyROSNode participant Bridge participant ROSMaster PyROSNode->>Bridge: connect() Bridge->>ROSMaster: XMLRPC discovery request ROSMaster->>Bridge: discovery response Bridge->>PyROSNode: return discovery data
ROS Communication Patterns¶
When bridging with native ROS, various communication patterns are supported:
graph TD A[Communication Patterns] --> B[Topics - Publisher/Subscriber] A --> C[Services - Request/Response] A --> D[Parameters - Key/Value Storage] B --> B1[Asynchronous Messaging] C --> C1[Synchronous Communication] D --> D1[Configuration Management]
Bridge Connection¶
The bridge connects to the ROS master using XMLRPC protocol:
from pyros2 import Bridge
# Default connection (localhost:11311)
bridge = Bridge()
# Custom connection
bridge = Bridge("192.168.1.100", 11312)
Discovering ROS Nodes¶
from pyros2 import Bridge
bridge = Bridge()
try:
bridge.connect()
nodes = bridge.discover_ros_nodes()
print("Discovered ROS nodes:")
for node in nodes:
print(f" - {node}")
except BridgeConnectionError as e:
print(f"Failed to connect: {e}")
Discovering ROS Topics¶
from pyros2 import Bridge
bridge = Bridge()
try:
bridge.connect()
topics = bridge.discover_ros_topics()
print("Discovered ROS topics:")
for topic in topics:
print(f" - {topic['name']} (type: {topic['type']})")
except BridgeConnectionError as e:
print(f"Failed to connect: {e}")
Discovering ROS Services¶
from pyros2 import Bridge
bridge = Bridge()
try:
bridge.connect()
services = bridge.discover_ros_services()
print("Discovered ROS services:")
for service in services:
print(f" - {service['name']} (providers: {service['providers']})")
except BridgeConnectionError as e:
print(f"Failed to connect: {e}")
Requirements for Bridging¶
To use the bridging capabilities, you need:
- A running ROS master (ROS1)
- Network connectivity to the ROS master
- Proper permissions to access the ROS master
Setting up ROS Master¶
If you don't have ROS installed, you can run a simple ROS master using roscore:
This will start the ROS master on localhost:11311 by default.
Limitations¶
The current bridging implementation:
- Only supports ROS1 master discovery
- Does not support message translation between Python ROS engine and native ROS
- Does not support parameter synchronization
- Does not support service request/response translation
Future versions will expand these capabilities to provide full interoperability with native ROS systems.