File: update_frame_id.py

package info (click to toggle)
ros-image-pipeline 1.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,320 kB
  • sloc: cpp: 6,220; python: 2,143; xml: 445; sh: 21; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 1,102 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python 

import rospy
from sensor_msgs.msg import Image 
from sensor_msgs.msg import CameraInfo

rospy.init_node("update_frame_id")

#Updating frame id for the error depth_front frame id does not match rgb_front frame id
class update_frame_id:
    def __init__(self):
        self.image = Image()
        #subscribe to your specific sensors
        self.sub_raw = rospy.Subscriber("/carla/ego_vehicle/rgb_front/image", Image, self.callback_raw)
        self.sub_info = rospy.Subscriber("/carla/ego_vehicle/rgb_front/camera_info", CameraInfo, self.callback_info)
        self.pub_raw = rospy.Publisher("/rgb/image_rect_color", Image, queue_size = 1)
        self.pub_info = rospy.Publisher("/rgb/camera_info", CameraInfo, queue_size = 1)
    def callback_raw(self, message):
        message.header.frame_id = "ego_vehicle/depth_front"
        self.pub_raw.publish(message)
    def callback_info(self, message):
        message.header.frame_id = "ego_vehicle/depth_front"
        self.pub_info.publish(message)

update_frame_id = update_frame_id()
rospy.spin()

print("\nNode shutdown\n")