scenic.simulators.carla.misc

Module with auxiliary functions.

Summary of Module Members

Functions

compute_distance

Euclidean distance between 3D points

compute_magnitude_angle

Compute relative angle and distance between a target_location and a current_location

distance_vehicle

Returns the 2D distance from a waypoint to a vehicle

draw_waypoints

Draw a list of waypoints at a certain height given in z.

get_speed

Compute speed of a vehicle in Km/h.

is_within_distance

Check if a target object is within a certain distance from a reference object.

is_within_distance_ahead

Check if a target object is within a certain distance in front of a reference object.

positive

Return the given number if positive, else 0

vector

Returns the unit vector from location_1 to location_2

Member Details

draw_waypoints(world, waypoints, z=0.5)[source]

Draw a list of waypoints at a certain height given in z.

param world:

carla.world object

param waypoints:

list or iterable container with the waypoints to draw

param z:

height in meters

get_speed(vehicle)[source]

Compute speed of a vehicle in Km/h.

param vehicle:

the vehicle for which speed is calculated

return:

speed as a float in Km/h

is_within_distance_ahead(target_transform, current_transform, max_distance)[source]

Check if a target object is within a certain distance in front of a reference object.

Parameters:
  • target_transform – location of the target object

  • current_transform – location of the reference object

  • orientation – orientation of the reference object

  • max_distance – maximum allowed distance

Returns:

True if target object is within max_distance ahead of the reference object

is_within_distance(target_location, current_location, orientation, max_distance, d_angle_th_up, d_angle_th_low=0)[source]

Check if a target object is within a certain distance from a reference object. A vehicle in front would be something around 0 deg, while one behind around 180 deg.

param target_location:

location of the target object

param current_location:

location of the reference object

param orientation:

orientation of the reference object

param max_distance:

maximum allowed distance

param d_angle_th_up:

upper thereshold for angle

param d_angle_th_low:

low thereshold for angle (optional, default is 0)

return:

True if target object is within max_distance ahead of the reference object

compute_magnitude_angle(target_location, current_location, orientation)[source]

Compute relative angle and distance between a target_location and a current_location

param target_location:

location of the target object

param current_location:

location of the reference object

param orientation:

orientation of the reference object

return:

a tuple composed by the distance to the object and the angle between both objects

distance_vehicle(waypoint, vehicle_transform)[source]

Returns the 2D distance from a waypoint to a vehicle

param waypoint:

actual waypoint

param vehicle_transform:

transform of the target vehicle

vector(location_1, location_2)[source]

Returns the unit vector from location_1 to location_2

param location_1, location_2:

carla.Location objects

compute_distance(location_1, location_2)[source]

Euclidean distance between 3D points

param location_1, location_2:

3D points

positive(num)[source]

Return the given number if positive, else 0

param num:

value to check