1 #include <ros/console.h>
2 #include <ros/duration.h>
4 #include <ros/master.h>
6 #include <ros/node_handle.h>
16 int main(
int argc,
char **argv)
19 ros::removeROSArgs(argc, argv, myargv);
20 bool publish_rgb =
false, publish_depth =
false, publish_pc =
false;
22 bool valid_arg_provided =
false;
23 for (uint i = 1; i < myargv.
size(); ++i)
26 if (opt ==
"-h" || opt ==
"--help")
29 <<
" If no valid options are provided, rgb and depth images and camera info will be published" <<
std::endl
31 <<
" -h, --help: show this message" <<
std::endl
32 <<
" -a, --all: publish rgb, depth and pointcloud" <<
std::endl
33 <<
" --rgb, --color: publish rgb image and camera info" <<
std::endl
34 <<
" --depth: publish depth image and camera info" <<
std::endl
35 <<
" --rgbd: publish rgb and depth images and camera info" <<
std::endl
36 <<
" --pc, --pointcloud: publish pointcloud" <<
std::endl;
39 else if (opt ==
"-a" || opt ==
"--all")
44 valid_arg_provided =
true;
46 else if (opt ==
"--rgb" || opt ==
"--color")
49 valid_arg_provided =
true;
51 else if (opt ==
"--depth")
54 valid_arg_provided =
true;
56 else if (opt ==
"--rgbd")
60 valid_arg_provided =
true;
62 else if (opt ==
"--pc" || opt ==
"--pointcloud")
65 valid_arg_provided =
true;
67 else if (!opt.
compare(0, 2,
"--"))
77 if (!valid_arg_provided)
84 ros::init(argc, argv,
"rgbd_to_ros");
87 ROS_DEBUG_STREAM(
"publish_rgb: " << publish_rgb);
88 ROS_DEBUG_STREAM(
"publish_depth: " << publish_depth);
89 ROS_DEBUG_STREAM(
"publish_pc: " << publish_pc);
93 client.
initialize(ros::names::resolve(
"rgbd"));
97 server.
initialize(
"", publish_rgb, publish_depth, publish_pc);
99 ros::NodeHandle nh_private(
"~");
101 nh_private.getParam(
"rate", rate);
105 ros::WallTime last_master_check = ros::WallTime::now();
110 if (ros::WallTime::now() >= last_master_check + ros::WallDuration(1))
112 last_master_check = ros::WallTime::now();
113 if (!ros::master::check())
115 ROS_FATAL(
"Lost connection to master");