dummy_camera.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from sensor_msgs.msg import Image, CameraInfo
5 
6 rospy.init_node("dummy_camera")
7 
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)
13 
14 r = rospy.Rate(10)
15 while not rospy.is_shutdown():
16  now = rospy.Time(0)
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)
28 
29  dummy_img = Image()
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)
38  r.sleep()


jsk_interactive_marker
Author(s): furuta
autogenerated on Sat Mar 20 2021 03:03:33