AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

How to get the collision information while using command 'moveToPositionAsync'

Open Hoshea7 opened this issue 7 years ago • 1 comments

Hi everybody,

I am currently using reinforcement learning for path planning, and I would to reset the initial point which is generated randomly at each episode. To achieve this, I will generate the random coordinates in the beginning of each new episode and using the command 'moveToPositionAsync' to control the UAV moving into the generated initial point. But my environment contains some obstacles which might impede the movement when the quadrotor tries to reach it , and then the quadrotor would be stucked into this kind of situations forever.

So I wonder if any solutions that I can get the collision information or any interrupt actions that can break it while the quadrotoe is reaching the target point by ' 'moveToPositionAsync'' but meet the obstacles?

Hoshea7 avatar Aug 04 '19 14:08 Hoshea7

I would recommend using moveByVelocityAsync() with a simple P control input. This way you can work collision detection into the control loop:

while !client.simGetCollisionInfo().has_collided
    velocity_input = your_waypoint - client.simGetVehiclePose().position
    client.moveByVelocity(velocity_input.x_val, velocity_input.y_val, velocity_input.z_val, duration)

msb336 avatar Aug 07 '19 22:08 msb336