An electric defense grid was a self-defense device installed on some combat droids to make up for their weaknesses in melee combat. It was either installed as part of the droid's armor, or overlaid on the outer shell.
If a combatant made contact with the droid when the grid was active, they received an electrical shock. This only happened if the combatant made direct contact or used a conductive weapon. Lightsabers and other non-conductive weapons were immune to this effect.