Airsim: AttributeError: 'CarState' object has no attribute 'collision'

Created on 20 Dec 2017  Â·  10Comments  Â·  Source: microsoft/AirSim

Code from 'hello_car.py':

    # get state of the car
    car_state = client.getCarState()
    print("Speed %d, Gear %d" % (car_state.speed, car_state.gear))

Result:

Traceback (most recent call last):
  File "c:\SDC\AirSim\PythonClient\hello_car.py", line 11, in <module>
    car_state = client.getCarState()
  File "c:\SDC\AirSim\PythonClient\AirSimClient.py", line 556, in getCarState
    return CarState.from_msgpack(state_raw)
  File "c:\SDC\AirSim\PythonClient\AirSimClient.py", line 26, in from_msgpack
    obj.__dict__ = { k : (v if not isinstance(v, dict) else getattr(getattr(obj, k).__class__, "from_msgpack")(v)) for k, v in encoded.items()}
  File "c:\SDC\AirSim\PythonClient\AirSimClient.py", line 26, in <dictcomp>
    obj.__dict__ = { k : (v if not isinstance(v, dict) else getattr(getattr(obj, k).__class__, "from_msgpack")(v)) for k, v in encoded.items()}
AttributeError: 'CarState' object has no attribute 'collision'

Most helpful comment

@sytelus I used the new version of DQNcar.py. However, I still got AttributeError: 'CarState' object has no attribute 'velocity'. I guess that it still be caused by the recent change of CarState structure which now has full kinematics.

All 10 comments

I think this is because you are using new version of AirSim but old version of Python client. Just update Python client from your new version and should be fine.

@sytelus Hi, sytelus. I am facing the same issue. How can I update Python client?

@sytelus , I have the same question. After I follow the tutorial Build It on Linux to install and configure the package, I run the demo hello_drone.py and there are some errors:
2017-12-27 18 11 42
What's more, in most cases, it shows like this:
2017-12-27 18 14 26

What's the matter with it?

I use the new version of AirSim and the latest version of Python client from repo.
Problem has been resolved by adding two lines into AirSimClient.py/LandedState/CarState

collision = CollisionInfo()
kinematics_true = KinematicsState()

Thanks to https://github.com/Microsoft/AirSim/pull/696

@kvasnyj thank you! The problem was solved!

I found the issue and it's now fixed in this commit. Please get latest. If you had done local changes to workaround this issue and then you might want to revert them first.

Also, please note that there is slight change in APIs. Specifically, CarState structure now has full kinematics. This now allows you to get much more ground truth information about car's state in kinematics_true than just position and velocity.

Duplicate issues:

@sytelus When I run the DQNcar.py, I got the ERROR " 'CarState' object has no attribute 'position' ". I guess it was caused by this commit.

DQNcar.py is also now fixed.

@sytelus I used the new version of DQNcar.py. However, I still got AttributeError: 'CarState' object has no attribute 'velocity'. I guess that it still be caused by the recent change of CarState structure which now has full kinematics.

@sytelus @DQQ-077-SZ I also encounter the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kim-BongSu picture Kim-BongSu  Â·  3Comments

p3jawors picture p3jawors  Â·  3Comments

machenxiang picture machenxiang  Â·  3Comments

vinbo picture vinbo  Â·  4Comments

jingleFun picture jingleFun  Â·  3Comments