PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

[gz-sim] x500_lidar for testing CollisionPrevention

Open dakejahl opened this issue 2 years ago • 16 comments

Added another x500 model with a lidar attached. https://app.gazebosim.org/OpenRobotics/fuel/models/Lidar%202d%20v2

Subscribes to gz::msgs::LaserScan and publishes to ObstacleDistance.

requires https://github.com/PX4/PX4-gazebo-models/pull/41

image image

dakejahl avatar Nov 21 '23 00:11 dakejahl

Nice, I definitely want to use this to fix CollisionPrevention. Thanks for looking into the simulation part :pray:

MaEtUgR avatar Nov 21 '23 16:11 MaEtUgR

gz_collision_prevention_test.tar.gz

Run this command: PX4_GZ_WORLD=hall make px4_sitl gz_x500_lidar

dirksavage88 avatar Nov 21 '23 18:11 dirksavage88

Something doesn't look right with the obstacle distance array. Is it supposed to report the max distance if close up to an obstacle? I thought the array bins started at 0 and wrapped around the vehicle CW with bins w/o sensor coverage filled with UINT16_MAX.

Maybe something is wrong with my gz sim collisions...I saw this on depth cam too where it would report the max distance of '1911' (cm) even though it was facing an obstacle that should have taken up the entire 70 degree FOV. Kazam_screenshot_00014

dirksavage88 avatar Nov 23 '23 03:11 dirksavage88

@dirksavage88

A value of 0 means that the obstacle is right in front of the sensor. A value of max_distance +1 means no obstacle is present. A value of UINT16_MAX for unknown/not used.

Index 0 in the array corresponds to the first distance measurement which starts at the angle_offset which is 135* in this case, so those up close measurements appear in the middle of the array, they are the small values ~40cm

edit: check obstacle_distance_fused if you want the CollisionPrevention remapped representation. Also check out the QGC overlay to validate the results. You will see that it's correct! That 90* issue with the depth cam model is because it's not converting FLU to FRD -- the array gets reversed

dakejahl avatar Nov 23 '23 04:11 dakejahl

If it is mapped correctly the something else is wrong but with the gz sim collision model itself? Collision prevention did not stop me from hitting the box that was shown in the screenshot and params are matching with what I had for the depth cam model. The depth cam model did work to stop from collision but the array showed some strange range bin values. I’ll check the fused array.

dirksavage88 avatar Nov 23 '23 04:11 dirksavage88

The depth cam model did work to stop from collision

Since we know now that the depth cam model is publishing the distances array in reverse order and CP still works it's probably an issue with the CP code itself.

dakejahl avatar Nov 23 '23 04:11 dakejahl

The depth cam model did work to stop from collision

Since we know now that the depth cam model is publishing the distances array in reverse order and CP still works it's probably an issue with the CP code itself.

I’m copying your files into my local branch. I tried building the PR branch on a cloned local of your fork and had issues, so I can’t rule out build issues on my end. I did notice depth cam obstacle map was flipped but thought it was QGC visual only, that makes sense that the array itself was flipped and why I’m seeing large bin values where it should be shorter distances….

CP would still reliably reduce velocity in the forward direction even if the array is flipped.

dirksavage88 avatar Nov 23 '23 04:11 dirksavage88

@dirksavage88 I just tested it and it works for me but it's just really shitty. The velocity contraints will kick in too slowly and you'll hit the obstacle if you're moving towards it too fast. Try increasing CP_DIST and reduce the max horizontal speed and tilt angle. The tilt angle and tilt rates needs to be reduced or the lidar will be looking at the ground

dakejahl avatar Nov 23 '23 04:11 dakejahl

@dirksavage88 I just tested it and it works for me but it's just really shitty. The velocity contraints will kick in too slowly and you'll hit the obstacle if you're moving towards it too fast. Try increasing CP_DIST and reduce the max horizontal speed and tilt angle. The tilt angle and tilt rates needs to be reduced or the lidar will be looking at the ground

I did play with the settings and it's a bit better. My concern is that if I turn the CP go_no_go parameter on I'm not able to roll to the right, which means something may be off with the obstacle distance map message. I pulled the lidar specs and it looks like there's a 90 degree gap, so that may explain why I'm seeing a gap in coverage but it should be directly aft of the vehicle and not the sectors to the right. Kazam_screenshot_00015 Kazam_screenshot_00017

dirksavage88 avatar Nov 24 '23 12:11 dirksavage88

Hello everyone, I have one simple question... How did you manage to visualize 2d lidar data in QGroundControl? @dakejahl Thank you in advance!

OgnjenX avatar Jan 18 '24 13:01 OgnjenX

@OgnjenX With a vehicle connected go to the Safety page and check the "show obstacle distance overlay" box image

dakejahl avatar Jan 18 '24 18:01 dakejahl

@OgnjenX With a vehicle connected go to the Safety page and check the "show obstacle distance overlay" box image

For some reason, it does not show data on the map with this configuration:

image

image

But when I run 'listener obstacle_distance' in MAVLink Console, I get:

image

OgnjenX avatar Jan 18 '24 20:01 OgnjenX

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/using-obstacle-distance-uorb-msgs-for-collision-prevention/37524/8

DronecodeBot avatar Apr 12 '24 12:04 DronecodeBot

I just rebased and retested, added a PR to the new gz submodule. https://github.com/PX4/PX4-gazebo-models/pull/41 Let's get this in.

dakejahl avatar May 13 '24 23:05 dakejahl

Hey @Jaeyoung-Lim can you help us review/merge?

mrpollo avatar May 22 '24 15:05 mrpollo

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/px4-sync-q-a-may-22-2024/38872/1

DronecodeBot avatar May 22 '24 15:05 DronecodeBot

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/using-collision-prevention/40013/4

DronecodeBot avatar Aug 07 '24 06:08 DronecodeBot