Skip to content

Commit

Permalink
support for cumulative time
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenWizard2015 committed Oct 11, 2024
1 parent e615453 commit 1a3c4cd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Core/CDataSampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import Core.CDataSampler_utils as DSUtils

class CDataSampler:
def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0):
def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0, cumulative_time=True):
'''
If cumulative_time is True, then time is a cumulative time from the start of the trajectory i.e. [0, 0.1, 0.2, 0.3, ...]
If cumulative_time is False, then time is a time delta between frames i.e. [0, 0.1, 0.1, 0.1, ...]
'''
self._storage = storage
self._defaults = defaults
self._batchSize = batch_size
self._maxT = maxT
self._minFrames = minFrames
self._samples = []
self._currentSample = None
self._cumulative_time = cumulative_time
return

def reset(self):
Expand Down Expand Up @@ -118,6 +123,9 @@ def _prepareT(self, res):
pass
T = np.insert(T, 0, 0.0)
assert len(res) == len(T)
# T is an array of time deltas like [0, 0.1, 0.1, 0.1, ...], convert it to cumulative time
if self._cumulative_time:
T = np.cumsum(T)
return T

def _framesFor(self, mainInd, samples, steps, stepsSampling):
Expand Down

0 comments on commit 1a3c4cd

Please sign in to comment.