For computational expensive algorithms, it is recommanded to attach a mini computer to the drone. This computer is called the companion computer. More information on this topic can be found here.
To create custom MAVLink messages in PX4 and publish the corresponding message content in ROS, follow the instructions here.
To simulate the drone in Gazebo, follow the instructions here.
Tuning instructions for the PX4 attitude (P) and rate (PID) controllers in simulation and on the real drone are described here.
For more information about PX4, click here.
For more information about building QGroundControl from source and supporting custom MAVLink messages, click here.