In order to decrease the emission of carbon dioxide, reduce the reliance on fossil fuel and contribute to a sustainable world, more and more green energy resources, such as solar panels and wind turbines, and energy storage systems, such as batteries, will be installed and integrated into power systems. There are two main problems for the integration of distributed energy resources (DERs) into the power grid. The first one is related to the optimal power planning of generation and storage units to ensure the availability of power in all times and situations (steady-state stability). This problem has been studied by many researchers and is not the subject of this proposal. The second problem, which is the subject of this proposal, is related to the safe operation of a grid in the presence of fast variation of the generations and loads (dynamic transient stability). It is well known that, in contrast to traditional large- scale power plants with large inertia and slow dynamics, DERs have low inertia and fast dynamics, which may cause large oscillations or even instability to the whole power system. Therefore, how to develop suitable controllers for these DERs to guarantee a flexible integration as well as overall stability and safety of the power grid becomes an urgent problem.