AttributeError:'Tello'对象没有属性'address'(Tello Ryze Drone StreamOn错误,无法调用streamon函数:)

问题描述 投票:0回答:1
from djitellopy import tello
import cv2
# Create instances for each Tello drone
drone1 = tello.Tello(ip='192.168.10.2')  # Replace with your first Wi-Fi adapter's IP
#drone2 = tello.Tello(ip='192.168.10.3')  # Replace with your second Wi-Fi adapter's IP
# ... Add more instances for additional drones

# Connect to drones
drone1.connect()
#drone2.connect()
# ... Connect other drones

# Send commands to drones
# drone1.takeoff()
# drone2.takeoff()
# ... Send other commands

# Clean up
drone1.streamon()



# while True:
#     img = drone1.get_frame_read().frame
#     img = cv2.resize(img, (360, 240))
#     cv2.imshow("results", img)
#     if cv2.waitKey(1) & 0xFF == ord('q'):
#         break

每当我尝试调用streamon函数时,我都会收到此错误,尝试询问ChatGPT但不会给我答案

Traceback (most recent call last):
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Interface.py", line 4, in <module>
    drone1 = tello.Tello(ip='192.168.10.2')  # Replace with your first Wi-Fi adapter's IP
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Lib\site-packages\djitellopy\enforce_types.py", line 54, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: Tello.__init__() got an unexpected keyword argument 'ip'
Exception ignored in: <function Tello.__del__ at 0x000001FAE5924720>
Traceback (most recent call last):
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Lib\site-packages\djitellopy\enforce_types.py", line 54, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Lib\site-packages\djitellopy\tello.py", line 1028, in __del__
    self.end()
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Lib\site-packages\djitellopy\enforce_types.py", line 54, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\origi\PycharmProjects\DroneProject\venv\Lib\site-packages\djitellopy\tello.py", line 1023, in end
    host = self.address[0]
           ^^^^^^^^^^^^
AttributeError: 'Tello' object has no attribute 'address'

Process finished with exit code 1

我正在使用多个网络适配器连接到多个 ryze 无人机,但甚至无法让streamon fn为第一个无人机工作

对于第一架tello无人机的IP地址,我指定了我的网络适配器IP地址,因为tellos具有相同的IP

任何回应表示赞赏:)

python attributeerror tello-drone
1个回答
0
投票

代码中的主要问题不是

AttributeError
,而是构造函数中的
TypeError

TypeError: Tello.__init__() got an unexpected keyword argument 'ip'

您要么使用了过时版本的库,要么 ChatGPT 只是产生了幻觉并生成了无效代码。如果您查看

Tello
类的构造函数(here),您可以看到它接受以下参数:

    def __init__(self,
                 host=TELLO_IP,
                 retry_count=RETRY_COUNT,
                 vs_udp=VS_UDP_PORT):

因此,在创建

host
实例时,应该使用
ip
而不是
Tello

© www.soinside.com 2019 - 2024. All rights reserved.