Question: How to get car state in C++?
I'm working on a C++ ROS node to interface a ROS package with a car in Airsim. To properly control the car, I would need to be able to read the car's speed and angular velocity, then compare them to the commanded values coming through the ROS messages. The example code mentions a client.getCarState() command for Python, but nothing in the documentation mentions anything equivalent for C++. How do I get the car's state through C++? Thank you.
For C++ you use CarRpcLibClient. Method is
CarApiBase::CarState getCarState(const std::string& vehicle_name = "")
APIs: https://github.com/Microsoft/AirSim/blob/77f84fff2c60d9b3d361bc2d2121cf10436d0996/AirLib/include/vehicles/car/api/CarRpcLibClient.hpp#L19
Example: https://github.com/Microsoft/AirSim/blob/77f84fff2c60d9b3d361bc2d2121cf10436d0996/HelloCar/main.cpp#L19
No method by the name getCarState appears in either of those files.
@dehavenm - were you able to use the API (it is defined).. tho there doesn't seem to be a sample for it quite as yet. Perhaps you can post it, if you managed to work it out.
@dehavenm did you find how to use getCarState() in C++?
No, I never was able to find that information.
Hi @dehavenm! Yo can see that method in the file commented by stylus but three lines below. I tried adding this line CarApiBase::CarState state = client.getCarState(); to HelloCar/main.cpp successfully. Let me know if you need more help. Regards