## 1 Introduction
The consensus of the system requires a suitable control protocol to be designed so that all agents can converge to a common value under the premise that they can only exchange information with their neighbors [7]. The consensus performance is obviously affected by the dynamics of the agents and network topology. Numerous results have been studied considering these two factors [8; 9; 10; 11; 12; 13]. However, in physical and engineering systems, the consensus problem is expected to ensure that all agents can converge in a certain trajectory to achieve the desired goal. Rapid convergence can be achieved by designing a consensus algorithm to determine the optimal weight matrix [14]. An appropriate function was constructed by maximizing the second smallest eigenvalue of the Laplacian operator, thereby optimizing the consensus algorithm [15]. Furthermore, the average consensus problem was realized by developing an optimal interaction graph [16]. In another study, the consensus problem was expressed as an optimization problem using the linear matrix inequality method [17]. An optimal linear consensus algorithm based on the linear quadratic adjuster has also been proposed [18]. The cooperative mission was studied by [19], analyzing the approach to solve the averaging problem through the application of assumptions that were based on linear iterative form. In [20], each group member interacted with its neighboring states by a linear stochastic matrix until all of them reached the same limit. In [21], a distributed algorithm was generalized for the consensus in fixed topology. In [22], an arranged motion of particulars in a group was controlled by a specific model in order to update the information from the closest neighbor. An optimistic optimization approach with simple black box was devised in a form of a non-linear structure for controlling the agents' behavior in [23]. This research focuses on the analysis of consensus models, the design of consensus protocols, convergence, equilibrium, and application prospects. Many scholars have applied different model methods and carried out in-depth research and expansion of consensus theory from different directions. The consensus has developed rapidly and yielded fruitful results and has been widely applied to a variety of scientific and engineering problems,including synchronization of coupled oscillators, formation control, swarm control, optimal cooperative control, clustering, sensor networks, etc. [24; 25]. In [26] the problem of consensus in multi-AUV recovery systems with time varying delays was explored. A new consensus control protocol for formations was proposed. In [27] the problem of multi-AUV formation control under constraints such as bounded communication delays and nonconvex control inputs was studied. In [28] an improved event-triggering mechanism to coordinate the communication in heterogeneous AUVs was explored. In [29], some effective criteria for consensus of a class of non-smooth opinion dynamics over a directed graph were presented. In [30] the integral sliding mode control protocol was proposed to address the formation control of multi-robot systems. In [31] the output consensus issue for linear multi-agent systems was addressed. It is clear that the convergence time of the system depends on the initial conditions. Coordination among multiple agents is critical, but the obstacle avoidance strategies that were designed previously neither considered the optimality nor the interaction topology (consensus) issues. The contributions of this paper are described as follows. (1) A new consensus algorithm was studied for the single-integrator systems in an obstacle environment. (2) A novel control approach was developed to achieve multi-AUV consensus and have the minimal obstacle avoidance cost. (3) A novel nonquadratic obstacle avoidance cost function was constructed by an inverse optimal control approach. (4) The theory in this paper was verified by practical experiments.