def init_perception(description):
    """create perception from description"""
    perception = PerceptionObstacle()
    perception.id = description["id"]
    perception.position.x = description["position"][0]
    perception.position.y = description["position"][1]
    perception.position.z = description["position"][2]
    perception.theta = description["theta"]
    perception.velocity.CopyFrom(
        get_velocity(description["theta"], description["speed"]))
    perception.length = description["length"]
    perception.width = description["width"]
    perception.height = description["height"]
    perception.polygon_point.extend(
        generate_polygon(perception.position, perception.theta,
                         perception.length, perception.width))
    # for point in generate_polygon(perception.position, perception.theta,
    #         perception.length, perception.width):
    #     p = perception.polygon_point.add()
    #     p.x = point[0]
    #     p.y = point[1]
    #     p.z = point[2]
    perception.tracking_time = description["tracking_time"]
    perception.type = PerceptionObstacle.Type.Value(description["type"])
    perception.timestamp = rospy.get_time()
    return perception
Example #2
0
 def get_cyber_obstacle_msg(self):
     obstacle = PerceptionObstacle()
     obstacle.id = self.get_global_id()
     transform = self.carla_actor.get_transform()
     velocity = self.carla_actor.get_velocity()
     obstacle.position.x = transform.location.x
     obstacle.position.y = -transform.location.y
     obstacle.position.z = transform.location.z
     obstacle.theta = -math.radians(transform.rotation.yaw)
     obstacle.velocity.x = velocity.x
     obstacle.velocity.y = -velocity.y
     obstacle.velocity.z = velocity.z
     obstacle.length = self.carla_actor.bounding_box.extent.x * 2.0
     obstacle.width = self.carla_actor.bounding_box.extent.y * 2.0
     obstacle.height = self.carla_actor.bounding_box.extent.z * 2.0
     return obstacle
Example #3
0
def init_perception(description):
    """
    Create perception from description
    """
    perception = PerceptionObstacle()
    perception.id = description["id"]
    perception.position.x = description["position"][0]
    perception.position.y = description["position"][1]
    perception.position.z = description["position"][2]
    perception.theta = description["theta"]
    perception.velocity.CopyFrom(get_velocity(
        description["theta"], description["speed"]))
    perception.length = description["length"]
    perception.width = description["width"]
    perception.height = description["height"]
    perception.polygon_point.extend(generate_polygon(perception.position,
                                                     perception.theta, perception.length, perception.width))
    perception.tracking_time = description["tracking_time"]
    perception.type = PerceptionObstacle.Type.Value(description["type"])
    perception.timestamp = cyber_time.Time.now().to_sec()

    return perception
def init_perception(description):
    """create perception from description"""
    perception = PerceptionObstacle()
    perception.id = description["id"]
    perception.position.x = description["position"][0]
    perception.position.y = description["position"][1]
    perception.position.z = description["position"][2]
    perception.theta = description["theta"]
    perception.velocity.CopyFrom(get_velocity(description["theta"], description["speed"]))
    perception.length = description["length"]
    perception.width = description["width"]
    perception.height = description["height"]
    perception.polygon_point.extend(generate_polygon(perception.position, perception.theta,
            perception.length, perception.width))
    # for point in generate_polygon(perception.position, perception.theta,
    #         perception.length, perception.width):
    #     p = perception.polygon_point.add()
    #     p.x = point[0]
    #     p.y = point[1]
    #     p.z = point[2]
    perception.tracking_time = description["tracking_time"]
    perception.type = PerceptionObstacle.Type.Value(description["type"])
    perception.timestamp=rospy.get_time()
    return perception