Skip to content
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

Bugfix for incorrect playback rate changes when pressing buttons #1513

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions rosbag2_transport/src/rosbag2_transport/player.cpp
Expand Up @@ -1061,12 +1061,12 @@ void PlayerImpl::add_keyboard_callbacks()
);
add_key_callback(
play_options_.increase_rate_key,
[this]() {owner_->set_rate(get_rate() * 1.1);},
[this]() {owner_->set_rate(get_rate() + 0.1);},
"Increase Rate 10%"
);
add_key_callback(
play_options_.decrease_rate_key,
[this]() {owner_->set_rate(get_rate() * 0.9);},
[this]() {owner_->set_rate(get_rate() - 0.1);},
"Decrease Rate 10%"
);
}
Expand Down
Expand Up @@ -157,8 +157,14 @@ TEST_F(RosBag2PlayTestFixture, test_keyboard_controls)
keyboard_handler->simulate_key_press(play_options_.pause_resume_toggle_key);
EXPECT_THAT(player->is_paused(), true);

keyboard_handler->simulate_key_press(play_options_.increase_rate_key);
EXPECT_DOUBLE_EQ(player->get_rate(), 1.0);
keyboard_handler->simulate_key_press(play_options_.decrease_rate_key);
// Each increase/decrease shall change playback rate value by 10%
EXPECT_DOUBLE_EQ(player->get_rate(), 0.9);
keyboard_handler->simulate_key_press(play_options_.increase_rate_key);
EXPECT_DOUBLE_EQ(player->get_rate(), 1.0);
keyboard_handler->simulate_key_press(play_options_.increase_rate_key);
EXPECT_DOUBLE_EQ(player->get_rate(), 1.1);

// start playback asynchronously in a separate thread
player->play();
Expand All @@ -175,7 +181,7 @@ TEST_F(RosBag2PlayTestFixture, test_keyboard_controls)
EXPECT_THAT(player->num_paused, 1);
EXPECT_THAT(player->num_resumed, 1);
EXPECT_THAT(player->num_played_next, 1);
EXPECT_THAT(player->num_set_rate, 2);
EXPECT_THAT(player->num_set_rate, 3);
}

TEST_F(RecordIntegrationTestFixture, test_keyboard_controls)
Expand Down