1 #ifndef TEST_SERVER_TEMPL_H_
2 #define TEST_SERVER_TEMPL_H_
4 #include <image_geometry/pinhole_camera_model.h>
8 #include <ros/console.h>
9 #include <ros/duration.h>
11 #include <ros/master.h>
12 #include <ros/names.h>
13 #include <ros/node_handle.h>
17 #include <sensor_msgs/CameraInfo.h>
18 #include <sensor_msgs/distortion_models.h>
36 ros::init(argc, argv,
"rgbd_transport_test_server");
37 ros::NodeHandle nh_private(
"~");
40 nh_private.getParam(
"rate", rate);
43 server.initialize(ros::names::resolve(
"test"));
46 cv::Mat
rgb_image(480, 640, CV_8UC3, cv::Scalar(0,0,255));
47 cv::Mat depth_image(480, 640, CV_32FC1, 5.0);
48 sensor_msgs::CameraInfo cam_info;
49 cam_info.K = {554.2559327880068, 0.0, 320.5,
50 0.0, 554.2559327880068, 240.5,
52 cam_info.P = {554.2559327880068, 0.0, 320.5, 0.0,
53 0.0, 554.2559327880068, 240.5, 0.0,
55 cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;
57 cam_info.height = 480;
58 image_geometry::PinholeCameraModel cam_model;
59 cam_model.fromCameraInfo(cam_info);
63 ros::WallTime last_master_check = ros::WallTime::now();
68 if (ros::WallTime::now() >= last_master_check + ros::WallDuration(1))
70 last_master_check = ros::WallTime::now();
71 if (!ros::master::check())
73 ROS_FATAL(
"Lost connection to master");
77 cv::line(
rgb_image, cv::Point(x, 0), cv::Point(x,
rgb_image.rows - 1), cv::Scalar(0,0,255));
78 cv::line(depth_image, cv::Point(x, 0), cv::Point(x, depth_image.rows - 1), 5.0);
80 cv::line(
rgb_image, cv::Point(x, 0), cv::Point(x,
rgb_image.rows - 1), cv::Scalar(255, 0, 0));
81 cv::line(depth_image, cv::Point(x, 0), cv::Point(x, depth_image.rows - 1), 1.0);
96 #endif // TEST_SERVER_TEMPL_H_