Update channel.py
Added option to connect using IP address of the robot. For Example: python3 ./example/front_camera/camera_opencv.py enp2s0 python3 ./example/front_camera/camera_opencv.py 192.168.123.51 Both of the above will work, where "192.168.123.51" is the static IP address of the robot.
This commit is contained in:
parent
9ca77a1dc5
commit
82d2fd63ea
|
@ -13,7 +13,7 @@ from cyclonedds.util import duration
|
||||||
from cyclonedds.internal import dds_c_t, InvalidSample
|
from cyclonedds.internal import dds_c_t, InvalidSample
|
||||||
|
|
||||||
# for channel config
|
# for channel config
|
||||||
from .channel_config import ChannelConfigAutoDetermine, ChannelConfigHasInterface
|
from .channel_config import ChannelConfigAutoDetermine, ChannelConfigHasInterface, ChannelConfigHasIP
|
||||||
|
|
||||||
# for singleton
|
# for singleton
|
||||||
from ..utils.singleton import Singleton
|
from ..utils.singleton import Singleton
|
||||||
|
@ -201,7 +201,12 @@ class ChannelFactory(Singleton):
|
||||||
if networkInterface is None:
|
if networkInterface is None:
|
||||||
config = ChannelConfigAutoDetermine
|
config = ChannelConfigAutoDetermine
|
||||||
else:
|
else:
|
||||||
config = ChannelConfigHasInterface.replace('$__IF_NAME__$', networkInterface)
|
if "." in networkInterface: # connect using IP
|
||||||
|
config = ChannelConfigHasIP.replace('$__IF_IP__$', networkInterface)
|
||||||
|
print(f"connecting using IP: {networkInterface}")
|
||||||
|
else: # connect using Iface
|
||||||
|
config = ChannelConfigHasInterface.replace('$__IF_NAME__$', networkInterface)
|
||||||
|
print(f"connecting using Iface: {networkInterface}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.__domain = Domain(id, config)
|
self.__domain = Domain(id, config)
|
||||||
|
|
Loading…
Reference in New Issue