4 from sensor_msgs.msg
import Image, CameraInfo
6 rospy.init_node(
"dummy_camera")
8 pub = rospy.Publisher(
"~image", Image)
9 pub_info = rospy.Publisher(
"~camera_info", CameraInfo)
10 frame_id = rospy.get_param(
'~frame_id',
'dummy_camera')
11 width = rospy.get_param(
'~width', 640)
12 height = rospy.get_param(
'~height', 480)
15 while not rospy.is_shutdown():
17 dummy_camera_info = CameraInfo()
18 dummy_camera_info.width = width
19 dummy_camera_info.height = height
20 dummy_camera_info.header.frame_id = frame_id
21 dummy_camera_info.header.stamp = now
22 dummy_camera_info.D = [0.0, 0.0, 0.0, 0.0, 0.0]
23 dummy_camera_info.K = [525.0, 0.0, 319.5, 0.0, 525.0, 239.5, 0.0, 0.0, 1.0]
24 dummy_camera_info.R = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
25 dummy_camera_info.P = [525.0, 0.0, 319.5, 0.0, 0.0, 525.0, 239.5, 0.0, 0.0, 0.0, 1.0, 0.0]
26 dummy_camera_info.distortion_model =
"plumb_bob" 27 pub_info.publish(dummy_camera_info)
30 dummy_img.width = width
31 dummy_img.height = height
32 dummy_img.header.frame_id = frame_id
33 dummy_img.header.stamp = now
34 dummy_img.step = width
35 dummy_img.encoding =
"mono8" 36 dummy_img.data = [0] * width * height
37 pub.publish(dummy_img)