def publish(self): """ publish the current status """ status_msg = CarlaStatus() status_msg.frame = self.frame status_msg.synchronous_mode = self.synchronous_mode status_msg.synchronous_mode_running = self.synchronous_mode_running self.carla_status_publisher.publish(status_msg)
def __init__(self, role_name, width, height, node): self.role_name = role_name self.dim = (width, height) self.node = node font = pygame.font.Font(pygame.font.get_default_font(), 20) fonts = [x for x in pygame.font.get_fonts() if 'mono' in x] default_font = 'ubuntumono' mono = default_font if default_font in fonts else fonts[0] mono = pygame.font.match_font(mono) self._font_mono = pygame.font.Font(mono, 14) self._notifications = FadingText(font, (width, 40), (0, height - 40)) self.help = HelpText(pygame.font.Font(mono, 24), width, height) self._show_info = True self._info_text = [] self.vehicle_status = CarlaEgoVehicleStatus() self.vehicle_status_subscriber = node.new_subscription( CarlaEgoVehicleStatus, "/carla/{}/vehicle_status".format(self.role_name), self.vehicle_status_updated, qos_profile=10) self.vehicle_info = CarlaEgoVehicleInfo() self.vehicle_info_subscriber = node.new_subscription( CarlaEgoVehicleInfo, "/carla/{}/vehicle_info".format(self.role_name), self.vehicle_info_updated, qos_profile=QoSProfile( depth=10, durability=DurabilityPolicy.TRANSIENT_LOCAL)) self.x, self.y, self.z = 0, 0, 0 self.yaw = 0 self.latitude = 0 self.longitude = 0 self.manual_control = False self.gnss_subscriber = node.new_subscription(NavSatFix, "/carla/{}/gnss".format( self.role_name), self.gnss_updated, qos_profile=10) self.odometry_subscriber = node.new_subscription( Odometry, "/carla/{}/odometry".format(self.role_name), self.odometry_updated, qos_profile=10) self.manual_control_subscriber = node.new_subscription( Bool, "/carla/{}/vehicle_control_manual_override".format(self.role_name), self.manual_control_override_updated, qos_profile=10) self.carla_status = CarlaStatus() self.status_subscriber = node.new_subscription( CarlaStatus, "/carla/status", self.carla_status_updated, qos_profile=10)
def __init__(self, role_name, width, height): self.role_name = role_name self.dim = (width, height) font = pygame.font.Font(pygame.font.get_default_font(), 20) fonts = [x for x in pygame.font.get_fonts() if 'mono' in x] default_font = 'ubuntumono' mono = default_font if default_font in fonts else fonts[0] mono = pygame.font.match_font(mono) self._font_mono = pygame.font.Font(mono, 14) self._notifications = FadingText(font, (width, 40), (0, height - 40)) self.help = HelpText(pygame.font.Font(mono, 24), width, height) self._show_info = True self._info_text = [] self.vehicle_status = CarlaEgoVehicleStatus() self.tf_listener = tf.TransformListener() self.vehicle_status_subscriber = rospy.Subscriber( "/carla/{}/vehicle_status".format(self.role_name), CarlaEgoVehicleStatus, self.vehicle_status_updated) self.vehicle_info = CarlaEgoVehicleInfo() self.vehicle_info_subscriber = rospy.Subscriber( "/carla/{}/vehicle_info".format(self.role_name), CarlaEgoVehicleInfo, self.vehicle_info_updated) self.latitude = 0 self.longitude = 0 self.manual_control = False self.gnss_subscriber = rospy.Subscriber( "/carla/{}/gnss/gnss1/fix".format(self.role_name), NavSatFix, self.gnss_updated) self.manual_control_subscriber = rospy.Subscriber( "/carla/{}/vehicle_control_manual_override".format(self.role_name), Bool, self.manual_control_override_updated) self.carla_status = CarlaStatus() self.status_subscriber = rospy.Subscriber("/carla/status", CarlaStatus, self.carla_status_updated)
def __init__(self, role_name, width, height, node): self.role_name = role_name self.dim = (width, height) self.node = node font = pygame.font.Font(pygame.font.get_default_font(), 20) fonts = [x for x in pygame.font.get_fonts() if 'mono' in x] default_font = 'ubuntumono' mono = default_font if default_font in fonts else fonts[0] mono = pygame.font.match_font(mono) self._font_mono = pygame.font.Font(mono, 14) self._notifications = FadingText(font, (width, 40), (0, height - 40)) self.help = HelpText(pygame.font.Font(mono, 24), width, height) self._show_info = True self._info_text = [] self.vehicle_status = CarlaEgoVehicleStatus() if ROS_VERSION == 1: self.tf_listener = tf.TransformListener() self.callback_group = None elif ROS_VERSION == 2: self.tf_buffer = tf2_ros.Buffer() self.tf_listener = tf2_ros.TransformListener(self.tf_buffer, node=self.node) self.callback_group = ReentrantCallbackGroup() self.vehicle_status_subscriber = node.create_subscriber( CarlaEgoVehicleStatus, "/carla/{}/vehicle_status".format(self.role_name), self.vehicle_status_updated, callback_group=self.callback_group) self.vehicle_info = CarlaEgoVehicleInfo() self.vehicle_info_subscriber = node.create_subscriber( CarlaEgoVehicleInfo, "/carla/{}/vehicle_info".format(self.role_name), self.vehicle_info_updated, callback_group=self.callback_group, qos_profile=QoSProfile(depth=10, durability=latch_on)) self.latitude = 0 self.longitude = 0 self.manual_control = False self.gnss_subscriber = node.create_subscriber( NavSatFix, "/carla/{}/gnss".format(self.role_name), self.gnss_updated, callback_group=self.callback_group) self.manual_control_subscriber = node.create_subscriber( Bool, "/carla/{}/vehicle_control_manual_override".format(self.role_name), self.manual_control_override_updated, callback_group=self.callback_group) self.carla_status = CarlaStatus() self.status_subscriber = node.create_subscriber(CarlaStatus, "/carla/status", self.carla_status_updated, callback_group=self.callback_group)