Speaking as a programmer who inherited a few frustrating projects: yes I do!
Here's a few tips: be outside for a bit. Go on a walk, or even better in my case, a long distance run. You'll hopefully be able to work with renewed focus.
Also, if you can, be sure to work in a well-ventilated room. I worked in several offices with bad air quality, which was detrimental to my productivity. Currently my office has actual windows that open and which has actual temperature control. I am less tired at the end of the day while having done a lot more.
Finally, try to get as few distractions when you need to focus. Switch off notifications on your phone or desktop and use noise cancelling headphones if you have any. Music may or may not help you focus. That is a personal thing.