diff --git a/unitree_sdk2py/core/channel.py b/unitree_sdk2py/core/channel.py index 6dfa2e1..f8bc5ea 100644 --- a/unitree_sdk2py/core/channel.py +++ b/unitree_sdk2py/core/channel.py @@ -13,7 +13,7 @@ from cyclonedds.internal import dds_c_t, InvalidSample # for channel config -from .channel_config import ChannelConfigAutoDetermine, ChannelConfigHasInterface +from .channel_config import ChannelConfigAutoDetermine, ChannelConfigHasInterface, ChannelConfigHasIP # for singleton from ..utils.singleton import Singleton @@ -201,7 +201,12 @@ def Init(self, id: int, networkInterface: str = None, qos: Qos = None): if networkInterface is None: config = ChannelConfigAutoDetermine 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: self.__domain = Domain(id, config) diff --git a/unitree_sdk2py/core/channel_config.py b/unitree_sdk2py/core/channel_config.py index 19a67a4..40de925 100644 --- a/unitree_sdk2py/core/channel_config.py +++ b/unitree_sdk2py/core/channel_config.py @@ -23,3 +23,14 @@ ''' + +ChannelConfigHasIP = ''' + + + + + + + + + '''