I' m try to implement the HER algorithm from scratch in order to use it in the PandaReach-v3 environment. I already developed the same algorithm for the bitflip environment and it works as expected. So, what's now the problem? The problem is the calculation of the new reward $r'$ given an additional goal as stated in the red box in the following picture:
The problem is, that while in the bitflip environment I just created a trivial function, that basically calculates the difference between the state $s_{t}$ and the goal $g'$, in the case of a more complex problem like the PandaReach I don't kwon how to proceed, since I cannot figure out, how the function for the calculation of the new reward given a new goal should look like.
Basically I came up with the following two ideas:
I could implement a function, which calculates the 3D distance between the state and the goal. The function could output a one, if the calculated distance is below a small $\epsilon$ or zero otherwise;
I could use the already implemented step method (from the environment), which delivers in one step the new calculated reward. So no effort from my side. But here the problem is that I need to pass an action to the step method in order to generate a new state and calculate the new reward. And, for a new action, I need a policy. Since HER is a off policy algorithm I have a behavioural policy $\pi_{b}$ and nothing else. So my concern is whether I can/should/may use the same behavioural policy to sample an action to feed into the step method and get the new reward.
In other words: how do you calculate the new reward $r'$ in the HER algorithm?
Many thanks