It seems that the original meaning from the latin of a rake gradually transformed to a grate.

Interstingly enough, when I delved deeper I found the "herse" is also an English word but listed as obsolete. The agricultural meanings seemed to have migrated to the word harrow.

Herse...
A portcullis grated and spiked. Hist. 704 J. Harris Lex. Tech., Herse, in Fortification, is a Lattice in the form of a Harrow, and beset with many Iron Spikes. It is usually hung+that the herse may fall, and stop up the Passage+or other Entrance of a Fortress. 1841 Archæologia XXIX. 62 The+absence of the Herse is very unusual, and can only be explained, under the supposition that there was one at the porch of entrance, now fallen.

From Hearse one of the definitions:
b. A permanent framework of iron or other metal, fixed over a tomb to support rich coverings or palls, often adapted to carry lighted tapers.
1552 Berksh. Ch. Goods 10 A herse of Irone. 1846 Parker Gloss. Archit. 129 There is a brass frame+over the effigy of Richard, earl of Warwick, in the Beauchamp chapel at Warwick, which is called a herse in the contract for the tomb. 1851 Turner Dom. Archit. II. v. 242 The Sheriff of Southampton is commanded to repair the herces in the king's chapel. 1866 Peacock Eng. Ch. Furniture 128 A very graceful iron hearse of this kind+in Tanfield Church.

It seems the idea of the grate, or a grate-like apparatus is the common root.