ros2_control - kilted
Loading...
Searching...
No Matches
render_loop_exit.hpp
1
17#ifndef MUJOCO_ROS2_CONTROL__RENDER_LOOP_EXIT_HPP_
18#define MUJOCO_ROS2_CONTROL__RENDER_LOOP_EXIT_HPP_
19
20#include <atomic>
21#include <memory>
22
23#include <rclcpp/context.hpp>
24
26{
27
28inline bool handle_render_loop_exit(std::atomic<int>& exit_request,
29 const std::atomic<bool>& explicit_shutdown_requested,
30 const std::shared_ptr<rclcpp::Context>& context)
31{
32 // MuJoCo sets exitrequest when the window closes, so it cannot distinguish a user close from
33 // MujocoSimulation::shutdown(). The owner marks the latter before waking RenderLoop().
34 exit_request.store(1);
35 if (explicit_shutdown_requested.load())
36 {
37 return false;
38 }
39
40 return context && context->shutdown("MuJoCo rendering window closed");
41}
42
43} // namespace mujoco_ros2_control::detail
44
45#endif // MUJOCO_ROS2_CONTROL__RENDER_LOOP_EXIT_HPP_
Definition render_loop_exit.hpp:26