This paper considers the problem of formation control of multi-robot systems represented by a graph featuring both rigid and elastic edges, capturing specified range tolerance to the desired inter-robot distances. The objective is to navigate the robots safely through unknown environments with obstacles, utilizing onboard sensors like LiDAR while maintaining inter-robot distance constraints. To this end, a novel cooperative control algorithm is proposed, employing quadratic programming and leveraging control barrier functions to integrate multiple control objectives seamlessly. This approach ensures a unified strategy and provides a safety certificate. Experimental validation of the proposed cooperative control algorithm is conducted using a robotic testbed.