ros2_controllers icon indicating copy to clipboard operation
ros2_controllers copied to clipboard

Refactor test "mini simulator"

Open bmagyar opened this issue 4 years ago • 3 comments

Our integration tests currently have a recurring pattern where the robot hardware read/update/write steps are repeated a couple of times in a loop until a condition is met.

An occurence of this pattern is such:

  auto start_time = rclcpp::Clock().now();
  rclcpp::Duration wait = rclcpp::Duration::from_seconds(0.5);
  auto end_time = start_time + wait;
  while (rclcpp::Clock().now() < end_time) {
    test_robot->read();
    traj_controller->update();
    test_robot->write();
  }

To improve readability and reduce duplicated code in the future, this could be factored into a test_common file with a name along the lines of run_mini_simulation(test_robot, time_to_run_for).

bmagyar avatar Jun 05 '20 08:06 bmagyar

@bmagyar , do we need this anymore? If yes, can you please elaborate what will be the current expectations?

bailaC avatar Oct 12 '21 06:10 bailaC

This is still the case. First is to find where this occurances happen.

destogl avatar Oct 19 '21 21:10 destogl

I see the code in 3 files, but they are somewhat modified.

src/ros2_controllers/joint_trajectory_controller/test/test_trajectory_actions.cpp:
  94        auto end_time = start_time + wait;
  95:       while (rclcpp::Clock().now() < end_time)
  96        {
src/ros2_controllers/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp:
  303      const auto end_time = start_time + wait_time;
  304:     while (rclcpp::Clock().now() < end_time)
  305      {
src/ros2_controllers/joint_trajectory_controller/test/test_trajectory_controller.cpp:
  404    const auto end_time = start_time + wait;
  405:   while (rclcpp::Clock().now() < end_time)
  406    {

bailaC avatar Oct 20 '21 13:10 bailaC