29#include <EGL/eglext.h>
30#include <GLFW/glfw3.h>
31#include <mujoco/mujoco.h>
33#include <hardware_interface/hardware_info.hpp>
34#include <rclcpp/node.hpp>
35#include <rclcpp/publisher.hpp>
36#include <rclcpp/rclcpp.hpp>
37#include <sensor_msgs/msg/camera_info.hpp>
38#include <sensor_msgs/msg/image.hpp>
49 std::string frame_name;
50 std::string info_topic;
51 std::string image_topic;
52 std::string depth_topic;
57 std::vector<uint8_t> image_buffer;
58 std::vector<float> depth_buffer;
59 std::vector<float> depth_buffer_flipped;
61 sensor_msgs::msg::Image image;
62 sensor_msgs::msg::Image depth_image;
63 sensor_msgs::msg::CameraInfo camera_info;
65 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr image_pub;
66 rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr depth_image_pub;
67 rclcpp::Publisher<sensor_msgs::msg::CameraInfo>::SharedPtr camera_info_pub;
88 explicit MujocoCameras(rclcpp::Node::SharedPtr node, std::recursive_mutex* sim_mutex, mjData* mujoco_data,
89 mjModel* mujoco_model,
double camera_publish_rate);
124 rclcpp::Node::SharedPtr node_;
127 std::recursive_mutex* sim_mutex_{
nullptr };
131 mjData* mj_camera_data_;
134 double camera_publish_rate_;
142 std::vector<CameraData> cameras_;
145 std::thread rendering_thread_;
146 std::atomic_bool publish_images_;
149 EGLDisplay egl_display_{ EGL_NO_DISPLAY };
150 EGLContext egl_context_{ EGL_NO_CONTEXT };
151 EGLSurface egl_surface_{ EGL_NO_SURFACE };
152 bool use_egl_{
false };
158 bool init_egl_context();
163 void cleanup_egl_context();
Wraps MuJoCo cameras for publishing ROS 2 RGB-D streams.
Definition mujoco_cameras.hpp:74
void register_cameras(const hardware_interface::HardwareInfo &hardware_info)
Parses camera information from the mujoco model.
Definition mujoco_cameras.cpp:42
void close()
Stops the camera processing thread and closes the relevant objects, call before shutdown.
Definition mujoco_cameras.cpp:155
void init(GlfwInitFn glfw_init_fn=glfwInit)
Starts the image processing thread in the background.
Definition mujoco_cameras.cpp:133
std::function< int()> GlfwInitFn
Definition mujoco_cameras.hpp:77
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:363
Definition mujoco_cameras.hpp:44