From 82d2fd63ea9738cddfb40af5ca17212a2d68f8c4 Mon Sep 17 00:00:00 2001 From: Irfan <80172338+k-m-irfan@users.noreply.github.com> Date: Wed, 22 May 2024 21:56:25 +0400 Subject: [PATCH 1/2] 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. --- unitree_sdk2py/core/channel.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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) From 64b64b75e21755e740dec077e9558dda35224392 Mon Sep 17 00:00:00 2001 From: Irfan <80172338+k-m-irfan@users.noreply.github.com> Date: Wed, 22 May 2024 21:58:03 +0400 Subject: [PATCH 2/2] Update channel_config.py Added config to connect using IP Address of the robot. --- unitree_sdk2py/core/channel_config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 = ''' + + + + + + + + + '''