10 #ifndef _RGBD_CAMERA_PLUGIN_HH_ 11 #define _RGBD_CAMERA_PLUGIN_HH_ 14 #include "gazebo/common/Plugin.hh" 15 #include <gazebo/msgs/msgs.hh> 16 #include <gazebo/physics/physics.hh> 17 #include <gazebo/rendering/DepthCamera.hh> 18 #include <gazebo/sensors/sensors.hh> 19 #include <gazebo/transport/transport.hh> 20 #include <gazebo/common/Events.hh> 22 #include "gazebo/rendering/ogre_gazebo.h" 24 #include "camera_request.pb.h" 25 #include "camera_response.pb.h" 38 #define PARAM_CAMERA "cameraName" 39 #define PARAM_QUEUE_SIZE "renderQueueSize" 41 #define PARAM_OUTPUT_DIR "outputDir" 43 #define PARAM_EXTENSION "imageFormat" 45 #define PARAM_REQ_TOPIC "requestTopic" 47 #define PARAM_RES_TOPIC "responseTopic" 53 #define DEFAULT_OUTPUT_DIR "/tmp/RGBDCameraPlugin" 54 #define DEFAULT_EXTENSION "png" 56 #define DEFAULT_REQ_TOPIC "~/grasp/rgbd" 58 #define DEFAULT_RES_TOPIC "~/grasp/rgbd/response" 64 #define CAPTURE_REQUEST grasp::msgs::CameraRequest::CAPTURE 65 #define MOVE_REQUEST grasp::msgs::CameraRequest::MOVE 67 #define PREFIX_REQUEST grasp::msgs::CameraRequest::PREFIX 69 #define CAPTURE_RESPONSE grasp::msgs::CameraResponse::CAPTURE 71 #define MOVE_RESPONSE grasp::msgs::CameraResponse::MOVE 73 #define PREFIX_RESPONSE grasp::msgs::CameraResponse::PREFIX 80 typedef const boost::shared_ptr<const grasp::msgs::CameraRequest>
83 typedef const boost::shared_ptr<const grasp::msgs::CameraResponse>
95 private: std::unique_ptr<RGBDCameraPluginPrivate>
data_ptr;
98 private: physics::ModelPtr
model;
103 private: rendering::DepthCameraPtr
camera;
116 private:
bool stop_thread {
false};
125 private: std::string output_prefix {
""};
130 private:
bool capture {
false};
132 private:
bool update_pose {
false};
137 private:
bool rgb_captured {
false};
139 private:
bool depth_captured {
false};
152 public:
virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
160 public:
void onNewRGBFrame(
161 const unsigned char *_image,
163 unsigned int _height,
165 const std::string &_format);
173 public:
void onNewDepthFrame(
176 unsigned int _height,
178 const std::string &_format);
183 private:
void onUpdate();
190 private:
void saveRenderRGB();
193 private:
void saveRenderDepth();
196 private:
void saveDepthFrame(
199 unsigned int _height,
201 const std::string &_format,
202 const std::string &_filename);
205 private:
void clearQueues();
211 private:
static int OgrePixelFormat(
const std::string &_format);
std::string output_ext
Rendered output format.
Definition: RGBDCameraPlugin.hh:127
event::ConnectionPtr newRGBFrameConn
Pointer to RGB camera callback connection.
Definition: RGBDCameraPlugin.hh:107
Queue data structure for concurrent access.
Definition: ContactSensorPlugin.cc:12
std::string output_dir
Render output directory.
Definition: RGBDCameraPlugin.hh:123
ConcurrentQueue< unsigned char * > * rgb_queue
Multithread safe queue for RGB data.
Definition: RGBDCameraPlugin.hh:118
Definition: RGBDCameraPlugin.hh:33
std::thread thread_rgb
Auxiliar thread for saving RGB frames to disk.
Definition: RGBDCameraPlugin.hh:112
rendering::DepthCameraPtr camera
Pointer to depth camera renderer.
Definition: RGBDCameraPlugin.hh:103
physics::ModelPtr model
Camera model.
Definition: RGBDCameraPlugin.hh:98
std::thread thread_depth
Auxiliar thread for saving depth frames to disk.
Definition: RGBDCameraPlugin.hh:114
Class for private Target plugin data.
Definition: RGBDCameraPlugin.cc:17
const boost::shared_ptr< const grasp::msgs::CameraResponse > CameraResponsePtr
Shared pointer declaration for response message type.
Definition: RGBDCameraPlugin.hh:84
ignition::math::Pose3d new_pose
New desired pose.
Definition: RGBDCameraPlugin.hh:134
physics::WorldPtr world
World.
Definition: RGBDCameraPlugin.hh:100
ConcurrentQueue< float * > * depth_queue
Multithread safe queue for depth data.
Definition: RGBDCameraPlugin.hh:120
const boost::shared_ptr< const grasp::msgs::CameraRequest > CameraRequestPtr
Shared pointer declaration for request message type.
Definition: RGBDCameraPlugin.hh:81
event::ConnectionPtr newDepthFrameConn
Pointer to depth camera callback connection.
Definition: RGBDCameraPlugin.hh:109
std::unique_ptr< RGBDCameraPluginPrivate > data_ptr
Class with private attributes.
Definition: RGBDCameraPlugin.hh:95
event::ConnectionPtr updateConn
Pointer to world update callback connection.
Definition: RGBDCameraPlugin.hh:105