ZJU-FAST-Lab / ego-planner-swarm

An efficient single/multi-agent trajectory planner for multicopters.
GNU General Public License v3.0
1.13k stars 222 forks source link

Gazebo and PX4 sitl simulation #19

Closed giorgiovaccarino closed 2 years ago

giorgiovaccarino commented 2 years ago

Hi, I am very interested in this trajectory planner and would like to integrate it into a Gazebo+PX4-sitl simulation and then onto a real drone. The tf transformation from base_link to world frame is published by px4. I give as input only the point-cloud from a simulated velodyne VLP-16, no images, no depth. At runtime the point cloud of the velodyne is correctly oriented but the grid_map is correct until the drone does not make a rotation, in this case the map rotates with respect to the world and the generated trajectories collide with the obstacles. I am missing something in the configuration, I think. Attached is the view_frames and the ros_graph. Has anyone successfully integrated ego-planner-swarm into px4 sitl? Can you give me a hand?

rosgraph frames.pdf

Video: https://youtu.be/hhEcDnhjNcQ

bigsuperZZZX commented 2 years ago

That happens because the mapping module considers the pointcloud to be in the world frame, but obviously not. The code is in this line: https://github.com/ZJU-FAST-Lab/ego-planner-swarm/blob/d8c7604e30d028800be327069545296fbf193845/src/planner/plan_env/src/grid_map.cpp#L797 where the points from the pointcloud is adopted without any translation or rotation. Therefore, you should add this transformation by yourself using the received odometry message. Just left multiply "p3d" with a transformation matrix from the latest odometry message will fix this problem, just like what we have done in this line: https://github.com/ZJU-FAST-Lab/ego-planner-swarm/blob/d8c7604e30d028800be327069545296fbf193845/src/planner/plan_env/src/grid_map.cpp#L245.