Python SDK Conncetion error
840 2 2023-12-15
Uploading and Loding Picture ...(0/1)
o(^-^)o
djiuser_ucSf6ZolszTZ
lvl.1
Hungary
Offline

Hi,

I have a Robomaster EP core robot that works in all modes with the educational app (Wi-Fi direct connection or Networking connection), but when I try to program it with the Python SDK, the Wi-Fi direct connection works, but when I try to control through a router the robot is connected via wifi and the computer is connected via wire or wifi in both cases I have the same problem. I've tried on WSL and Ubuntu, but the result was the same.

from robomaster import conn
if __name__ == '__main__':
    robot_ip_list = conn.scan_robot_ip_list()
    print(robot_ip_list)
        
I get this:

[Running] python -u "c:\...\Robomaster\Projects\EP\test_000_ip.py"
find robot sn:3JKCK6U0030ALG, ip:192.168.140.6
['192.168.140.6']

The program can find the robot, but when the following or any other code when the robot should do something:

from robomaster import robot

if __name__ == '__main__':
    ep_robot = robot.Robot()
    ep_robot.initialize(conn_type="sta")

    ep_version = ep_robot.get_version()
    print("Robot Version: {0}".format(ep_version))

    ep_robot.close()

I get this:

[Running] python -u "c:\...\Robomaster\Projects\EP\test_001_version.py"
2023-12-15 11:39:37,008 ERROR conn.py:107 scan_robot_ip: exception timed out
2023-12-15 11:39:37,011 ERROR robot.py:1354 Robot: Connection Failed, Please Check Hareware Connections!!! conn_type sta, host None, target None.
2023-12-15 11:39:37,011 ERROR client.py:70 Client: __init__, create Connection, exception: module 'robomaster.config' has no attribute 'DEFAULT_CONN_PROTO'
2023-12-15 11:39:37,190 ERROR client.py:153 Client: send_sync_msg, client recv_task is not running.
Robot: Can not connect to robot, check connection please.
2023-12-15 11:39:37,190 ERROR client.py:153 Client: send_sync_msg, client recv_task is not running.
2023-12-15 11:39:37,190 ERROR client.py:153 Client: send_sync_msg, client recv_task is not running.
2023-12-15 11:39:37,191 ERROR client.py:153 Client: send_sync_msg, client recv_task is not running.
2023-12-15 11:39:37,191 ERROR client.py:153 Client: send_sync_msg, client recv_task is not running.
Traceback (most recent call last):
  File "C:\Users\admin\anaconda3\envs\robomaster\lib\site-packages\robomaster\client.py", line 93, in remote_addr
    return self._conn.target_addr
AttributeError: 'NoneType' object has no attribute 'target_addr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\...\Robomaster\Projects\EP\test_001_version.py", line 6, in <module>
    ep_robot.initialize(conn_type="sta")
  File "C:\Users\admin\anaconda3\envs\robomaster\lib\site-packages\robomaster\robot.py", line 1327, in initialize
    self._ftp.connect(self.ip)
  File "C:\Users\admin\anaconda3\envs\robomaster\lib\site-packages\robomaster\robot.py", line 1157, in ip
    return self.client.remote_addr[0]
  File "C:\Users\admin\anaconda3\envs\robomaster\lib\site-packages\robomaster\client.py", line 95, in remote_addr
    raise print('Robot: Can not connect to robot, check connection please.')
TypeError: exceptions must derive from BaseException

2023-12-15
Use props
BGA
Second Officer
United States
Offline

If I understand you correctly, this is very weird. It looks like when you call scan_robot_ip() directly it can find the robot but if it is scanned through the connect method it can not. This makes no sense (the timeout just means it could not find a robot).
2023-12-16
Use props
tsvi lev
lvl.1

Israel
Offline

BGA Posted at 12-16 06:17
If I understand you correctly, this is very weird. It looks like when you call scan_robot_ip() directly it can find the robot but if it is scanned through the connect method it can not. This makes no sense (the timeout just means it could not find a robot).


I cannot even 'find' the robot with latest SDK, despite clear connection from command line!
I installed the latest Python and Robomaster packages.
I am connected in DIrect WiFi, robomaster on 192.168.2.1 port 40923 accepts tcp/ip plaintext commands but just empty response (I assume due to deprecation).
In python, robot_ip_list=conn.scan_robot_ip_list(timeout=5)  returns empty list depsite all that.
Hence of course no programming or control possible.
Any ideas/suggestions?
thanks in advance!
2023-12-17
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules