Distributed PID control for consensus of homogeneous and heterogeneous networks