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

fix(mock): hard-coded update rate #1379

Merged
merged 1 commit into from
Sep 13, 2024
Merged

Conversation

satoshi-ota
Copy link
Contributor

Description

Now that #1368 was merged, we can change update rate for traffic_simulator::API but I found there was another hard-coded variable in cpp_scenario_node.cpp.

Abstract

Use global_frame_rate paramter for timer in cpp_scenario_node.cpp.

diff --git a/mock/cpp_mock_scenarios/src/cpp_scenario_node.cpp b/mock/cpp_mock_scenarios/src/cpp_scenario_node.cpp
index b9f0d72a0..4fb9bd392 100644
--- a/mock/cpp_mock_scenarios/src/cpp_scenario_node.cpp
+++ b/mock/cpp_mock_scenarios/src/cpp_scenario_node.cpp
@@ -64,8 +64,9 @@ void CppScenarioNode::start()
 {
   onInitialize();
   api_.startNpcLogic();
-  using namespace std::chrono_literals;
-  update_timer_ = this->create_wall_timer(50ms, std::bind(&CppScenarioNode::update, this));
+  const auto rate =
+    std::chrono::duration<double>(1.0 / get_parameter("global_frame_rate").as_double());
+  update_timer_ = this->create_wall_timer(rate, std::bind(&CppScenarioNode::update, this));
 }

Background

N/A

Details

References

N/A

Destructive Changes

N/A

Known Limitations

N/A

Copy link

github-actions bot commented Sep 13, 2024

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

@hakuturu583 hakuturu583 added the bump patch If this pull request merged, bump patch version of the scenario_simulator_v2 label Sep 13, 2024
@hakuturu583 hakuturu583 merged commit 2da5c9e into master Sep 13, 2024
14 checks passed
@github-actions github-actions bot deleted the fix/hard-coded-update-rate branch September 13, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch If this pull request merged, bump patch version of the scenario_simulator_v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants