19 from sensor_msgs.srv
import SetCameraInfo, SetCameraInfoRequest
21 rospy.init_node(
'set_camera_info')
22 rospy.wait_for_service(
'camera/set_camera_info')
23 set_camera_info = rospy.ServiceProxy(
'camera/set_camera_info', SetCameraInfo)
24 req = SetCameraInfoRequest()
25 req.camera_info.header.stamp = rospy.Time.now()
26 req.camera_info.header.frame_id = rospy.get_param(
'~frame_id')
27 req.camera_info.height = rospy.get_param(
'~image_height')
28 req.camera_info.width = rospy.get_param(
'~image_width')
29 req.camera_info.distortion_model =
"plumb_bob" 30 req.camera_info.D = rospy.get_param(
'~distortion_coefficients/data')
31 req.camera_info.K = rospy.get_param(
'~camera_matrix/data')
32 req.camera_info.R = rospy.get_param(
'~rectification_matrix/data')
33 req.camera_info.P = rospy.get_param(
'~projection_matrix/data')
34 print(req.camera_info)
37 except rospy.ServiceException
as e:
38 print(
"Service did not process request: {}".format(e))