Added waypoint's junction_id (#1509)

* Added waypoint's junction_id and is_junction
* Updated changelog
* Removed unnecessary const
This commit is contained in:
Marc Garcia Puig 2019-04-29 15:34:45 +02:00 committed by Néstor Subirón
parent be61f80caf
commit 424c32d2d4
13 changed files with 45 additions and 26 deletions

View File

@ -5,6 +5,8 @@
- Camera following in playback was not working if a new map was needed to load.
- API function 'show_recorder_file_info' was showing the wrong parent id.
- Script 'start_recording.py' now properly saves destruction of actors at stop.
* API extension: waypoint's `junction_id` that returns de OpenDrive identifier of the current junction
* API change: deprecated waypoint's `is_intersection`, now is `is_junction`
* New recorder features:
- Added optional parameter to show more details about a recorder file (related to `show_recorder_file_info.py`)
- Added playback speed (slow/fast motion) for the replayer

View File

@ -22,7 +22,7 @@
- `show_recorder_actors_blocked(string filename, float min_time, float min_distance)`
- `set_replayer_speed(float time_factor)`
- `apply_batch(commands, do_tick=False)`
- `apply_batch_sync(commands, do_tick=False) -> list(carla.command.Response)`
- `apply_batch_sync(commands, do_tick=False)` -> list(carla.command.Response)
## `carla.World`
@ -328,28 +328,30 @@
## `carla.LaneMarking`
- `type -> carla.LaneMarking`
- `color -> carla.RoadMarkColor`
- `lane_change -> carla.LaneChange`
- `type` -> carla.LaneMarking
- `color` -> carla.RoadMarkColor
- `lane_change` -> carla.LaneChange
- `width`
## `carla.Waypoint`
- `id`
- `transform`
- `is_intersection`
- `is_intersection` _deprecated, use `is_junction` instead_
- `is_junction`
- `lane_width`
- `road_id`
- `section_id`
- `lane_id`
- `junction_id`
- `s`
- `lane_change -> carla.LaneChange`
- `lane_type -> carla.LaneType`
- `right_lane_marking -> carla.LaneMarking`
- `left_lane_marking -> carla.LaneMarking`
- `next(distance) -> list(carla.Waypoint)`
- `get_right_lane() -> carla.Waypoint`
- `get_left_lane() -> carla.Waypoint`
- `lane_change` -> carla.LaneChange
- `lane_type` -> carla.LaneType
- `right_lane_marking` -> carla.LaneMarking
- `left_lane_marking` -> carla.LaneMarking
- `next(distance)` -> list(carla.Waypoint)
- `get_right_lane()` -> carla.Waypoint
- `get_left_lane()` -> carla.Waypoint
## `carla.WeatherParameters`

View File

@ -19,7 +19,11 @@ namespace client {
Waypoint::~Waypoint() = default;
bool Waypoint::IsIntersection() const {
road::JuncId Waypoint::GetJunctionId() const {
return _parent->GetMap().GetJunctionId(_waypoint.road_id);
}
bool Waypoint::IsJunction() const {
return _parent->GetMap().IsJunction(_waypoint.road_id);
}

View File

@ -9,10 +9,11 @@
#include "carla/Memory.h"
#include "carla/NonCopyable.h"
#include "carla/geom/Transform.h"
#include "carla/road/Lane.h"
#include "carla/road/element/LaneMarking.h"
#include "carla/road/element/RoadInfoMarkRecord.h"
#include "carla/road/element/Waypoint.h"
#include "carla/road/Lane.h"
#include "carla/road/RoadTypes.h"
#include <boost/optional.hpp>
@ -56,7 +57,9 @@ namespace client {
return _transform;
}
bool IsIntersection() const;
road::JuncId GetJunctionId() const;
bool IsJunction() const;
double GetLaneWidth() const;

View File

@ -331,7 +331,11 @@ namespace road {
return lane_width_info->GetPolynomial().Evaluate(s);
}
bool Map::IsJunction(const RoadId road_id) const {
JuncId Map::GetJunctionId(RoadId road_id) const {
return _data.GetRoad(road_id).GetJunctionId();
}
bool Map::IsJunction(RoadId road_id) const {
return _data.GetRoad(road_id).IsJunction();
}

View File

@ -64,6 +64,8 @@ namespace road {
double GetLaneWidth(Waypoint waypoint) const;
JuncId GetJunctionId(RoadId road_id) const;
bool IsJunction(RoadId road_id) const;
std::pair<const element::RoadInfoMarkRecord *, const element::RoadInfoMarkRecord *>

View File

@ -43,7 +43,7 @@ namespace road {
return _is_junction;
}
JuncId Road::GetJunction() const {
JuncId Road::GetJunctionId() const {
return _junction_id;
}

View File

@ -45,7 +45,7 @@ namespace road {
bool IsJunction() const;
JuncId GetJunction() const;
JuncId GetJunctionId() const;
Lane &GetLaneByDistance(double s, LaneId lane_id);

View File

@ -118,12 +118,12 @@ class Agent(object):
ego_vehicle_location = self._vehicle.get_location()
ego_vehicle_waypoint = self._map.get_waypoint(ego_vehicle_location)
if ego_vehicle_waypoint.is_intersection:
if ego_vehicle_waypoint.is_junction:
# It is too late. Do not block the intersection! Keep going!
return (False, None)
if self._local_planner.target_waypoint is not None:
if self._local_planner.target_waypoint.is_intersection:
if self._local_planner.target_waypoint.is_junction:
min_angle = 180.0
sel_magnitude = 0.0
sel_traffic_light = None

View File

@ -69,7 +69,7 @@ class GlobalRoutePlanner(object):
entry_xyz, exit_xyz = segment['entryxyz'], segment['exitxyz']
path = segment['path']
entry_wp, exit_wp = segment['entry'], segment['exit']
intersection = entry_wp.is_intersection
intersection = entry_wp.is_junction
road_id, section_id, lane_id = entry_wp.road_id, entry_wp.section_id, entry_wp.lane_id
for vertex in entry_xyz, exit_xyz:
@ -176,7 +176,7 @@ class GlobalRoutePlanner(object):
left_found, right_found = False, False
for waypoint in segment['path']:
if not segment['entry'].is_intersection:
if not segment['entry'].is_junction:
next_waypoint, next_road_option, next_segment = None, None, None
if bool(waypoint.lane_change & carla.LaneChange.Right) and not right_found:

View File

@ -152,12 +152,14 @@ void export_map() {
class_<cc::Waypoint, boost::noncopyable, boost::shared_ptr<cc::Waypoint>>("Waypoint", no_init)
.add_property("id", &cc::Waypoint::GetId)
.add_property("transform", CALL_RETURNING_COPY(cc::Waypoint, GetTransform))
.add_property("is_intersection", &cc::Waypoint::IsIntersection)
.add_property("is_intersection", &cc::Waypoint::IsJunction) // deprecated
.add_property("is_junction", &cc::Waypoint::IsJunction)
.add_property("lane_width", &cc::Waypoint::GetLaneWidth)
.add_property("road_id", &cc::Waypoint::GetRoadId)
.add_property("section_id", &cc::Waypoint::GetSectionId)
.add_property("lane_id", &cc::Waypoint::GetLaneId)
.add_property("s", &cc::Waypoint::GetDistance)
.add_property("junction_id", &cc::Waypoint::GetJunctionId)
.add_property("lane_change", &cc::Waypoint::GetLaneChange)
.add_property("lane_type", &cc::Waypoint::GetType)
.add_property("right_lane_marking", CALL_RETURNING_OPTIONAL(cc::Waypoint, GetRightLaneMarking))

View File

@ -700,7 +700,7 @@ class MapImage(object):
True)
# Draw Lane Markings and Arrows
if not waypoint.is_intersection:
if not waypoint.is_junction:
draw_lane_marking(
map_surface,
waypoints,
@ -725,7 +725,7 @@ class MapImage(object):
dist = 1.5
to_pixel = lambda wp: world_to_pixel(wp.transform.location)
for wp in carla_map.generate_waypoints(dist):
col = (0, 255, 255) if wp.is_intersection else (0, 255, 0)
col = (0, 255, 255) if wp.is_junction else (0, 255, 0)
for nxt in wp.next(dist):
pygame.draw.line(map_surface, col, to_pixel(wp), to_pixel(nxt), 2)
if wp.lane_change & carla.LaneChange.Right:

View File

@ -143,7 +143,7 @@ def main():
# Render some nice information, notice that you can't see the strings if you are using an editor camera
draw_waypoint_info(debug, current_w, trail_life_time)
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_intersection else green, trail_life_time)
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, trail_life_time)
draw_transform(debug, current_w.transform, white, trail_life_time)
# print the remaining waypoints