-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import data resampling #36
base: main
Are you sure you want to change the base?
Conversation
and other PRAGMA options for better paralle read/write performance
as we don't always have values for all joints and then want to default to 0.0
d585d15
to
5c3ce5b
Compare
with different converters by data type and different resampling strategies: - game_states are converted with original rate - images are converted with a max sample rate, meaning they can have a lesser rate, but not more while not having consitent time deltas - joint_state and joint_command are resampled in sync with an interpolation using the last available value at any sample point The initial db data point at `t_0`, having a relative timestamp of `0.0` is set only when all synced data becomes available (joint_state, joint_command, later also imu). The last available game_state will also be saved at this time point `t_0`. Before this no data will be saved to the database.
5c3ce5b
to
02db4ad
Compare
converter = self.synced_data_converter | ||
case "/DynamixelController/command": | ||
last_messages_by_topic.joint_command = ros_msg | ||
converter = self.synced_data_converter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no default case
from ddlitlab2024.dataset.imports.model_importer import InputData, Sample | ||
|
||
|
||
class OriginalRateResampler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an interface for Resamplers
if num_samples > 0: | ||
return samples | ||
else: | ||
self.last_received_data = data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you set last_reveived_data only here?
self.last_sampled_data = self.last_received_data | ||
self.last_sample_step_timestamp = self.last_sample_step_timestamp + self.sampling_step_in_seconds | ||
samples.append(Sample(data=self.last_sampled_data, timestamp=self.last_sample_step_timestamp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using class variables in Sample might be problematic if used by copy
else: | ||
self.last_received_data = data | ||
return [ | ||
Sample(data=self.last_sampled_data, timestamp=self.last_sample_step_timestamp, was_sampled_already=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return empty list
|
||
@abstractmethod | ||
def convert_to_model(self, data: InputData, relative_timestamp: float, recording: Recording) -> ModelData: | ||
"""_summary_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace summary
models = ModelData() | ||
|
||
for sample in self.resampler.resample(data, relative_timestamp): | ||
if not sample.was_sampled_already: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this?
|
||
if img_scaling_changed: | ||
logger.error( | ||
"The image sizes changed, during one recording! All images of a recording must have the same size." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The image sizes changed, during one recording! All images of a recording must have the same size." | |
"The image sizes changed during one recording! All images of a recording must have the same size." |
Summary
Proposed changes
This PR adds resampling with different converters by data type and different resampling strategies:
The initial db data point at
t_0
, having a relative timestamp of0.0
is set only when all synced data becomes available (joint_state, joint_command, later also imu).The last available game_state will also be saved at this time point
t_0
.Before this, no data will be saved to the database.
The
Converter
s currently still contain a mixture of bitbots/rosbag specific data access and conversion logic, which can be easily adjusted however by changing the fields ofInputData
to generic types to which we convert all of our different input data.I think doing this abstraction makes most sense once we see the actual difference in data.