Exemplo n.º 1
0
    def publish_traffic(self, data):
        x, y, z = data['light_pos_x'], data['light_pos_y'], data['light_pos_z'],
        yaw = [math.atan2(dy, dx) for dx, dy in zip(data['light_pos_dx'], data['light_pos_dy'])]
        status = data['light_state']

        lights = TrafficLightArray()
        header = Header()
        header.stamp = rospy.Time.now()
        header.frame_id = '/world'
        lights.lights = [self.create_light(*e) for e in zip(x, y, z, yaw, status)]
        self.publishers['trafficlights'].publish(lights)
    def __init__(self):
        rospy.init_node('tl_publisher')

        self.traffic_light_pubs = rospy.Publisher('/vehicle/traffic_lights', TrafficLightArray, queue_size=1)

        light = self.create_light(20.991, 22.837, 1.524, 0.08, 3)
        lights = TrafficLightArray()
        lights.header = light.header
        lights.lights = [light]
        self.lights = lights
        self.loop()
Exemplo n.º 3
0
    def publish_traffic(self, data):
        x, y, z = data['light_pos_x'], data['light_pos_y'], data[
            'light_pos_z'],
        yaw = [
            math.atan2(dy, dx)
            for dx, dy in zip(data['light_pos_dx'], data['light_pos_dy'])
        ]
        status = data['light_state']

        lights = TrafficLightArray()
        header = Header()
        header.stamp = rospy.Time.now()
        header.frame_id = '/world'
        lights.lights = [
            self.create_light(*e) for e in zip(x, y, z, yaw, status)
        ]
        self.publishers['trafficlights'].publish(lights)
Exemplo n.º 4
0
    def publish_traffic(self, data):
        x, y, z = (data["light_pos_x"], data["light_pos_y"],
                   data["light_pos_z"])
        yaw = [
            math.atan2(dy, dx)
            for dx, dy in zip(data["light_pos_dx"], data["light_pos_dy"])
        ]
        status = data["light_state"]

        lights = TrafficLightArray()
        header = Header()
        header.stamp = rospy.Time.now()
        header.frame_id = "/world"
        lights.lights = [
            self.create_light(*e) for e in zip(x, y, z, yaw, status)
        ]
        self.publishers["trafficlights"].publish(lights)
Exemplo n.º 5
0
    def __init__(self):
        rospy.init_node('tl_publisher')

        self.traffic_light_pubs = rospy.Publisher('/vehicle/traffic_lights',
                                                  TrafficLightArray,
                                                  queue_size=1)

        light = self.create_light(20.991, 22.837, 1.524, 0.08, 3)

        lights = TrafficLightArray()
        lights.header = light.header
        lights.lights = [light]
        self.lights = lights

        rate = rospy.Rate(50)
        while not rospy.is_shutdown():
            self.traffic_light_pubs.publish(self.lights)
            rate.sleep()
Exemplo n.º 6
0
    def publish_traffic(self, data):
        # Don't bother publishing if traffic light status is the same 
        # as last time (the light positions never change, but the
        # light state changes as the lights turn green/yellow/red)
        if data == self.prev_traffic_data:
            return
        self.prev_traffic_data = data
        x, y, z = data['light_pos_x'], data['light_pos_y'], data['light_pos_z'],
        yaw = [math.atan2(dy, dx) for dx, dy in zip(data['light_pos_dx'], data['light_pos_dy'])]
        status = data['light_state']
        # print("traffic change", status)

        lights = TrafficLightArray()
        header = Header()
        header.stamp = rospy.Time.now()
        header.frame_id = '/world'
        lights.lights = [self.create_light(*e) for e in zip(x, y, z, yaw, status)]
        self.publishers['trafficlights'].publish(lights)