Go to the documentation of this file. 1 #include <ros/console.h>
2 #include <ros/duration.h>
4 #include <ros/master.h>
6 #include <ros/node_handle.h>
17 int main(
int argc,
char **argv) {
18 ros::init(argc, argv,
"ros_to_rgbd");
20 ros::NodeHandle nh_private(
"~");
23 nh_private.getParam(
"rate", rate);
30 nh_private.getParam(
"rgb_storage", rgb_type_str);
31 if (rgb_type_str ==
"none")
33 else if (rgb_type_str ==
"lossless")
35 else if (rgb_type_str ==
"jpg")
39 ROS_ERROR(
"Unknown 'rgb_storage' type: should be 'none', 'lossless', or 'jpg'.");
48 nh_private.getParam(
"depth_storage", depth_type_str);
49 if (depth_type_str ==
"none")
51 else if (depth_type_str ==
"lossless")
53 else if (depth_type_str ==
"png")
57 ROS_ERROR(
"Unknown 'depth_storage' type: should be 'none', 'lossless', or 'png'.");
66 client.
initialize(
"rgb_image",
"depth_image",
"cam_info");
67 server.
initialize(ros::names::resolve(
"rgbd"), rgb_type, depth_type);
71 ros::WallTime last_master_check = ros::WallTime::now();
76 if (ros::WallTime::now() >= last_master_check + ros::WallDuration(1))
78 last_master_check = ros::WallTime::now();
79 if (!ros::master::check())
81 ROS_FATAL(
"Lost connection to master");
87 server.
send(*image_ptr);
Server which provides interfaces of ServerRGBD and ServerSHM.
void send(const Image &image, bool threaded=false)
send Write a new image to all interfaces
bool nextImage(Image &image)
Get a new Image. If no new image has been received since the last call, no image will be written and ...
void initialize(const std::string &name, RGBStorageType rgb_type=RGB_STORAGE_LOSSLESS, DepthStorageType depth_type=DEPTH_STORAGE_LOSSLESS, const float service_freq=10)
initialize initialize server
int main(int argc, char **argv)
Client which subscribes to regular ROS image topics.
bool initialize(const std::string &rgb_image_topic, const std::string &depth_image_topic, const std::string &cam_info_topic)
Initialize the subscriber.