AttributeError:'NoneType'对象没有属性'decision_threaded'

时间:2017-07-18 12:01:23

标签: python tensorflow

    python3.4 scripts/diff_drive.py --remote=http://10.100.33.241:8887 --config=diff_vehicle
Detected running on rasberrypi. Only importing select modules.
Using TensorFlow backend.
PiVideoStream loaded.. .warming camera
/usr/lib/python3/dist-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 160x120 to 160x128
  width, height, fwidth, fheight)))
Traceback (most recent call last):
  File "scripts/diff_drive.py", line 58, in <module>
    car.start()
  File "/home/pi/donkey/donkey/vehicles.py", line 41, in start
    angle, throttle, drive_mode = self.remote.decide_threaded(img_arr,
AttributeError: 'NoneType' object has no attribute 'decide_threaded'
Exception ignored in: <bound method Session.__del__ of <tensorflow.python.client.session.Session object at 0x6cea7ab0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/client/session.py", line 581, in __del__
TypeError: 'NoneType' object is not callable

在Raspberry Pi 3上使用Adafruit DC Motor HAT制作驴车时遇到此错误。将根据需要发布必要的文件。 Pi和已建立的遥控器仅在短时间内连接螺母。

以下是vehicles.py

的代码片段
 def start(self):
        start_time = time.time()
        angle = 0.
        throttle = 0.

        #drive loop
        while True:
            now = time.time()
            start = now

            milliseconds = int( (now - start_time) * 1000)

            #get image array image from camera (threaded)
            img_arr = self.camera.capture_arr()

            angle, throttle, drive_mode = self.remote.decide_threaded(img_arr,
                                                 angle,
                                                 throttle,


                               milliseconds)

这是带有decision_threaded定义的片段:

def decide_threaded(self, img_arr, angle, throttle, milliseconds):
    ''' 
    Return the last state given from the remote server.
    '''
    #update the state's image
    self.state['img_arr'] = img_arr

    #return last returned last remote response.
    return self.state['angle'], self.state['throttle'], self.state['drive_mode']

编辑:

这是self.remote发生的实例:

'''
vehicles.py
Class to pull together all parts that operate the vehicle including,
sensors, actuators, pilots and remotes.
'''

import time

class BaseVehicle:
    def __init__(self,
                 drive_loop_delay = .5,
                 camera=None,
                 actuator_mixer=None,
                 pilot=None,
                 remote=None):

        self.drive_loop_delay = drive_loop_delay #how long to wait between loops

        #these need tobe updated when vehicle is defined
        self.camera = camera
        self.actuator_mixer = actuator_mixer
        self.pilot = pilot
        self.remote = remote

谢谢!非常感谢。

0 个答案:

没有答案