microsoft / AirSim

Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
https://microsoft.github.io/AirSim/
Other
16.47k stars 4.59k forks source link

How can I get collision information with AirSim ROS Wrapper? #4424

Open shuaikangma opened 2 years ago

shuaikangma commented 2 years ago

Question

What's your question?

How can I get collision information with AirSim ROS Wrapper?

Include context on what you are trying to achieve

I want to use AirSim in a drl-based navigation system. I just want to get a collision trigger and the give my agent a negative reward , then reset the env.

Context details

AIrSim version: #4410 Unreal version: v1.7.0-linux OS version: ubuntu18.04 with ros-melodic Use default settiongs :AirSim/ros/settings/front_stereo_and_center_mono.json in #4410

Include details of what you already did to find answers

By the way, I test reset service manually use rqt in ros, it can't take off after reset service being called. I see a commit and merge in the early version, but it may dose't work?

shuaikangma commented 2 years ago

I attempt to use airsim_client_->simGetCollisionInfo(vehicle_ros->vehicle_name) and drone->curr_drone_state.collision.has_collided in ros::Time AirsimROSWrapper::update_state() at _~/AirSim/ros/src/airsim_ros_pkgs/src/airsim_roswrapper.cpp to get the collision information, but both of them return 0(I print the CollisionInfo.time_stamp, but it turns to be 0).

shuaikangma commented 2 years ago

My fault! I didn't print CollisionInfo.hascollision when test **airsim_client_->simGetCollisionInfo(vehicle_ros->vehicle_name)**, it really worked! But `drone->curr_drone_state.collision.has_collided_` still didn't work. I fix it in #4426