apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Errors in data_collector.py

Open Leonardo092 opened this issue 8 years ago • 7 comments

Hello there, I run into some unexpected behaviour (a bug, maybe. Not sure) when dealing with the update of vehicle calibration (please refer to this guide ). To be concise:

  1. In file the variable self.in_session appears to be not initialized. The error displays:

File "modules/tools/calibration/data_collector.py", line 132, in callback_canbus if self.in_session: AttributeError: 'DataCollector' object has no attribute 'in_session'

2)Still in the same file, the variable I had the following error:

File "modules/tools/calibration/data_collector.py", line 147, in publish_control if self.case == 'a': AttributeError: 'DataCollector' object has no attribute 'case'

I solved by adding the following piece of code at line 147:

        if self.vehicle_speed >= self.cmd[1]:
           self.case = 'd'
        else:
           self.case = 'a' 

Did I miss something before running the script or are my considerations worthy?

Leonardo092 avatar Aug 22 '18 10:08 Leonardo092

Hi, Could you please add try...(related exception) in this case as well, then submit a patch to fix that?

freeHackOfJeff avatar Aug 27 '18 08:08 freeHackOfJeff

Hi @Leonardo092 ! I have same issue. I fix it by adding self.case = 'a' self.in_session = False into data_collector.py in method: class DataCollector(object): def __init__(self):

gladijos avatar Aug 28 '18 07:08 gladijos

Also there is one issue in sending deceleration command. I fix it with: if self.case == 'a': if self.cmd[0] > 0: self.controlcmd.throttle = self.cmd[0] self.controlcmd.brake = 0 else: self.controlcmd.throttle = 0 self.controlcmd.brake = -self.cmd[0] if self.vehicle_speed >= self.cmd[1]: self.case = 'd' if self.case == 'd': if self.cmd[2] > 0: self.controlcmd.throttle = self.cmd[2] self.controlcmd.brake = 0 else: self.controlcmd.throttle = 0 self.controlcmd.brake = -self.cmd[2] if self.vehicle_speed == 0: self.in_session = False into data_collector.py in method: class DataCollector(object): def publish_control(self):

gladijos avatar Aug 28 '18 07:08 gladijos

I gone through the file, looks your solution is good. Also, this file could be refactored by isoldate usage into a method, a few code is written without following the pythonic style.

freeHackOfJeff avatar Aug 28 '18 07:08 freeHackOfJeff

Thanks @gladijos! My solution works as well but I will try yours in addition(especially that regarding deceleration).

Leonardo092 avatar Aug 28 '18 07:08 Leonardo092

Checking your solution, @gladijos, I noticed that variable self.case is nowhere set to default value but in def __init__(self):. Maybe I am missing something obvious, but I am wondering how the variable could ever be set again to default, as data_collector.run(cmd) is called loopwise.

Leonardo092 avatar Aug 28 '18 08:08 Leonardo092

you shall use try..catch to check is there any exception raised in DataCollector construct.if DataCollector init successfully shall not get these error print. ——Reply reference comes from the Apollo developer community issue master contest https://apollo.auto/developer/questiondata_cn.html?target=631

apollodevcommunity avatar Feb 07 '21 08:02 apollodevcommunity