Errors in data_collector.py
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:
- In file the variable
self.in_sessionappears 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?
Hi, Could you please add try...(related exception) in this case as well, then submit a patch to fix that?
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):
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):
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.
Thanks @gladijos! My solution works as well but I will try yours in addition(especially that regarding deceleration).
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.
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