rl icon indicating copy to clipboard operation
rl copied to clipboard

[Feature Request] Add linear interpolation to FrameSkipTransform

Open maxweissenbacher opened this issue 1 year ago • 3 comments

Motivation

I would suggest adding an option for linear interpolation to the FrameSkipTransform (documentation here). This means, instead of repeating the same action frame_skip number of times for each step in the environment, we could instead keep track of action from the previous step and then interpolate towards the new action over frame_skip steps.

This means that at the first step, the previous action would be executed, at the final step, the new action would be executed, and in between, we interpolate linearly between the two actions.

Solution

Add a variant of the FrameSkipTransform, or otherwise add this as an option in the params of FrameSkipTransform.

Checklist

  • [x] I have checked that there is no similar issue in the repo (required)

maxweissenbacher avatar Oct 27 '23 12:10 maxweissenbacher

@vmoens , can I work on this issue?

Zekrom-7780 avatar Nov 06 '23 10:11 Zekrom-7780

Of course!

vmoens avatar Nov 06 '23 11:11 vmoens

Some pointers: we could want to make this stateless, if a buffer needs to be carried it could be put in the output tensordict under a private entry name, eg "_action_interp_buffer". We can also make it stateful within the transform. Both are viable options. A good example of the former approach is StepCounter or other stateless transforms like TargetReturn. CatFrames is a good example of stateful transform.

Another datapoint: be careful about reset, which will require some clever masking of the buffer with the reset key. Again have a look at the above mentioned transforms to get a sense of how it should work.

vmoens avatar Nov 06 '23 13:11 vmoens