diff --git a/pendulum_control/src/pendulum_demo.cpp b/pendulum_control/src/pendulum_demo.cpp index 55cba4610..aef8d6d60 100644 --- a/pendulum_control/src/pendulum_demo.cpp +++ b/pendulum_control/src/pendulum_demo.cpp @@ -197,8 +197,12 @@ int main(int argc, char * argv[]) pendulum_controller->on_pendulum_setpoint(msg); }; + // Receive the most recently published message from the teleop node publisher. + auto qos_profile_setpoint_sub(qos_profile); + qos_profile_setpoint_sub.durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL; + auto setpoint_sub = controller_node->create_subscription( - "pendulum_setpoint", controller_command_callback, qos_profile, nullptr, false, + "pendulum_setpoint", controller_command_callback, qos_profile_setpoint_sub, nullptr, false, setpoint_msg_strategy); // Initialize the logger publisher. diff --git a/pendulum_control/src/pendulum_teleop.cpp b/pendulum_control/src/pendulum_teleop.cpp index e57902771..7a29e9f9f 100644 --- a/pendulum_control/src/pendulum_teleop.cpp +++ b/pendulum_control/src/pendulum_teleop.cpp @@ -54,7 +54,9 @@ int main(int argc, char * argv[]) rclcpp::sleep_for(500ms); pub->publish(msg); rclcpp::spin_some(teleop_node); - std::cout << "Teleop node exited." << std::endl; + printf("Teleop message published.\n"); + rclcpp::sleep_for(1s); + printf("Teleop node exited.\n"); rclcpp::shutdown(); } diff --git a/pendulum_control/test/test_pendulum_demo.py.in b/pendulum_control/test/test_pendulum_demo.py.in index 171200d60..1b0d31252 100644 --- a/pendulum_control/test/test_pendulum_demo.py.in +++ b/pendulum_control/test/test_pendulum_demo.py.in @@ -16,6 +16,9 @@ def setup(): os.environ['OSPL_VERBOSITY'] = '8' # 8 = OS_NONE # bare minimum formatting for console output matching os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '{message}' + # force flush of the stdout buffer. + # this ensures a correct sync of prints from processes executed within the launch file. + os.environ['RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED'] = '1' def test_executable(): @@ -53,6 +56,7 @@ def test_executable(): pendulum_demo_handler = create_handler( pendulum_demo_name, launch_descriptor, pendulum_demo_output_file, + exit_on_match=False, # the process will exit automatically after a set number of iterations filtered_prefixes=filtered_prefixes, filtered_rmw_implementation=rmw_implementation) assert pendulum_demo_handler, \ diff --git a/pendulum_control/test/test_pendulum_teleop.py.in b/pendulum_control/test/test_pendulum_teleop.py.in index de46e6329..45e586e5d 100644 --- a/pendulum_control/test/test_pendulum_teleop.py.in +++ b/pendulum_control/test/test_pendulum_teleop.py.in @@ -17,6 +17,9 @@ def setup(): os.environ['OSPL_VERBOSITY'] = '8' # 8 = OS_NONE # bare minimum formatting for console output matching os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '{message}' + # force flush of the stdout buffer. + # this ensures a correct sync of prints from processes executed within the launch file. + os.environ['RCUTILS_CONSOLE_STDOUT_LINE_BUFFERED'] = '1' def test_executable():