Merge branch 'master' into feature/integrate_rss_3.0.0

This commit is contained in:
berndgassmann 2020-04-02 19:59:17 +02:00 committed by GitHub
commit 07fafaea67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 156 additions and 9 deletions

View File

@ -11,6 +11,8 @@
* Upgraded to AD RSS v3.0.0 supporting complex road layouts and i.e. intersections
* Added examples of sumo co-simulation for Town01, Town04 and Town05
* Added ptv vissim and carla co-simulation
* API extensions:
- Added new methods to `Map`: `get_all_landmarks`, `get_all_landmarks_from_id` and `get_all_landmarks_of_type`
## CARLA 0.9.8

View File

@ -1012,6 +1012,24 @@ Converts a given `location`, a point in the simulation, to a [carla.GeoLocation]
- **Parameters:**
- `location` (_[carla.Location](#carla.Location)_)
- **Return:** _[carla.GeoLocation](#carla.GeoLocation)_
- <a name="carla.Map.get_all_landmarks"></a>**<font color="#7fb800">get_all_landmarks</font>**(<font color="#00a6ed">**self**</font>)
Returns all the landmarks in the map. Landmarks retrieved using this method have a __null__ waypoint.
- **Return:** _list([carla.Landmark](#carla.Landmark))_
- <a name="carla.Map.get_all_landmarks_from_id"></a>**<font color="#7fb800">get_all_landmarks_from_id</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**opendrive_id**</font>)
Returns the landmarks with a certain OpenDRIVE ID. Landmarks retrieved using this method have a __null__ waypoint.
- **Parameters:**
- `opendrive_id` (_string_) The OpenDRIVE ID of the landmarks.
- **Return:** _list([carla.Landmark](#carla.Landmark))_
- <a name="carla.Map.get_all_landmarks_of_type"></a>**<font color="#7fb800">get_all_landmarks_of_type</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**type**</font>)
Returns the landmarks of a specific type. Landmarks retrieved using this method have a __null__ waypoint.
- **Parameters:**
- `type` (_string_) The type of the landmarks.
- **Return:** _list([carla.Landmark](#carla.Landmark))_
- <a name="carla.Map.get_landmark_group"></a>**<font color="#7fb800">get_landmark_group</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**landmark**</font>)
Returns the landmarks in the same group as the specified landmark (including itself). Returns an empty list if the landmark does not belong to any group.
- **Parameters:**
- `landmark` (_[carla.Landmark](#carla.Landmark)_) A landmark that belongs to the group.
- **Return:** _list([carla.Landmark](#carla.Landmark))_
- <a name="carla.Map.get_spawn_points"></a>**<font color="#7fb800">get_spawn_points</font>**(<font color="#00a6ed">**self**</font>)
Returns a list of recommendations made by the creators of the map to be used as spawning points for the vehicles. The list includes [carla.Transform](#carla.Transform) objects with certain location and orientation. Said locations are slightly on-air in order to avoid Z-collisions, so vehicles fall for a bit before starting their way.
- **Return:** _list([carla.Transform](#carla.Transform))_
@ -1027,10 +1045,10 @@ Returns a waypoint that can be located in an exact location or translated to the
- `lane_type` (_[carla.LaneType](#carla.LaneType)_) Limits the search for nearest lane to one or various lane types that can be flagged.
- **Return:** _[carla.Waypoint](#carla.Waypoint)_
- <a name="carla.Map.get_waypoint_xodr"></a>**<font color="#7fb800">get_waypoint_xodr</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**road_id**</font>, <font color="#00a6ed">**lane_id**</font>, <font color="#00a6ed">**s**</font>)
Get a waypoint if all the parameters passed are correct, otherwise return None.
Returns a waypoint if all the parameters passed are correct. Otherwise, returns __None__.
- **Parameters:**
- `road_id` (_int_) Id of the road from where getting the waypoint.
- `lane_id` (_int_) Id of the lane to get the waypoint.
- `road_id` (_int_) ID of the road to get the waypoint.
- `lane_id` (_int_) ID of the lane to get the waypoint.
- `s` (_float_) Specify the length from the road start.
- **Return:** _[carla.Waypoint](#carla.Waypoint)_
@ -1783,6 +1801,9 @@ Returns a list of waypoints from this to the start of the lane separated by a ce
- **Parameters:**
- `distance` (_float_) The approximate distance between waypoints.
- **Return:** _list([carla.Waypoint](#carla.Waypoint))_
- <a name="carla.Waypoint.get_junction"></a>**<font color="#7fb800">get_junction</font>**(<font color="#00a6ed">**self**</font>)
If the waypoint belongs to a junction this function returns the asociated junction object. Otherwise returns null.
- **Return:** _[carla.Junction](#carla.Junction)_
- <a name="carla.Waypoint.get_landmarks"></a>**<font color="#7fb800">get_landmarks</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**distance**</font>, <font color="#00a6ed">**stop_at_junction**=False</font>)
Returns a list of landmarks in the road from the current waypoint until the specified distance.
- **Parameters:**

View File

@ -31,7 +31,7 @@ namespace client {
}
road::RoadId GetRoadId() const {
return _signal->GetSignal()->GetRoadId();
return _signal->GetRoadId();
}
double GetDistance() const {
@ -117,6 +117,7 @@ namespace client {
private:
friend Waypoint;
friend Map;
Landmark(
SharedPtr<Waypoint> waypoint,

View File

@ -132,5 +132,54 @@ namespace client {
return result;
}
std::vector<SharedPtr<Landmark>> Map::GetAllLandmarks() const {
std::vector<SharedPtr<Landmark>> result;
auto signal_references = _map.GetAllSignalReferences();
for(auto* signal_reference : signal_references) {
result.emplace_back(
new Landmark(nullptr, signal_reference, 0));
}
return result;
}
std::vector<SharedPtr<Landmark>> Map::GetLandmarksFromId(std::string id) const {
std::vector<SharedPtr<Landmark>> result;
auto signal_references = _map.GetAllSignalReferences();
for(auto* signal_reference : signal_references) {
if(signal_reference->GetSignalId() == id) {
result.emplace_back(
new Landmark(nullptr, signal_reference, 0));
}
}
return result;
}
std::vector<SharedPtr<Landmark>> Map::GetAllLandmarksOfType(std::string type) const {
std::vector<SharedPtr<Landmark>> result;
auto signal_references = _map.GetAllSignalReferences();
for(auto* signal_reference : signal_references) {
if(signal_reference->GetSignal()->GetType() == type) {
result.emplace_back(
new Landmark(nullptr, signal_reference, 0));
}
}
return result;
}
std::vector<SharedPtr<Landmark>>
Map::GetLandmarkGroup(const Landmark &landmark) const {
std::vector<SharedPtr<Landmark>> result;
auto &controllers = landmark._signal->GetSignal()->GetControllers();
for (auto& controller_id : controllers) {
const auto &controller = _map.GetControllers().at(controller_id);
for(auto& signal_id : controller->GetSignals()) {
auto& signal = _map.GetSignals().at(signal_id);
auto new_landmarks = GetLandmarksFromId(signal->GetSignalId());
result.insert(result.end(), new_landmarks.begin(), new_landmarks.end());
}
}
return result;
}
} // namespace client
} // namespace carla

View File

@ -13,6 +13,7 @@
#include "carla/road/Map.h"
#include "carla/road/RoadTypes.h"
#include "carla/rpc/MapInfo.h"
#include "Landmark.h"
#include <string>
@ -81,6 +82,18 @@ namespace client {
std::vector<std::pair<SharedPtr<Waypoint>, SharedPtr<Waypoint>>> GetJunctionWaypoints(
road::JuncId id, road::Lane::LaneType type) const;
/// Returns all the larndmarks in the map
std::vector<SharedPtr<Landmark>> GetAllLandmarks() const;
/// Returns all the larndmarks in the map with a specific OpenDRIVE id
std::vector<SharedPtr<Landmark>> GetLandmarksFromId(std::string id) const;
/// Returns all the landmarks in the map of a specific type
std::vector<SharedPtr<Landmark>> GetAllLandmarksOfType(std::string type) const;
/// Returns all the landmarks in the same group including this one
std::vector<SharedPtr<Landmark>> GetLandmarkGroup(const Landmark &landmark) const;
private:
const rpc::MapInfo _description;

View File

@ -475,6 +475,19 @@ namespace road {
return result;
}
std::vector<const element::RoadInfoSignal*>
Map::GetAllSignalReferences() const {
std::vector<const element::RoadInfoSignal*> result;
for (const auto& road_pair : _data.GetRoads()) {
const auto &road = road_pair.second;
auto road_infos = road.GetInfos<element::RoadInfoSignal>();
for(const auto* road_info : road_infos) {
result.push_back(road_info);
}
}
return result;
}
std::vector<LaneMarking> Map::CalculateCrossedLanes(
const geom::Location &origin,
const geom::Location &destination) const {

View File

@ -99,6 +99,10 @@ namespace road {
std::vector<SignalSearchData> GetSignalsInDistance(
Waypoint waypoint, double distance, bool stop_at_junction = false) const;
/// Return all RoadInfoSignal in the map
std::vector<const element::RoadInfoSignal*>
GetAllSignalReferences() const;
/// ========================================================================
/// -- Waypoint generation -------------------------------------------------
/// ========================================================================

View File

@ -166,6 +166,10 @@ void export_map() {
.def("to_opendrive", CALL_RETURNING_COPY(cc::Map, GetOpenDrive))
.def("save_to_disk", &SaveOpenDriveToDisk, (arg("path")=""))
.def("get_crosswalks", CALL_RETURNING_LIST(cc::Map, GetAllCrosswalkZones))
.def("get_all_landmarks", CALL_RETURNING_LIST(cc::Map, GetAllLandmarks))
.def("get_all_landmarks_from_id", CALL_RETURNING_LIST_1(cc::Map, GetLandmarksFromId, std::string), (args("opendrive_id")))
.def("get_all_landmarks_of_type", CALL_RETURNING_LIST_1(cc::Map, GetAllLandmarksOfType, std::string), (args("type")))
.def("get_landmark_group", CALL_RETURNING_LIST_1(cc::Map, GetLandmarkGroup, cc::Landmark), args("landmark"))
.def(self_ns::str(self_ns::self))
;
@ -201,7 +205,7 @@ void export_map() {
.def("previous_until_lane_start", CALL_RETURNING_LIST_1(cc::Waypoint, GetPreviousUntilLaneStart, double), (args("distance", "stop_at_junction")))
.def("get_right_lane", &cc::Waypoint::GetRight)
.def("get_left_lane", &cc::Waypoint::GetLeft)
.def("get_junction", &cc::Waypoint::GetJunction, (args("lane_type")))
.def("get_junction", &cc::Waypoint::GetJunction)
.def("get_landmarks", CALL_RETURNING_LIST_2(cc::Waypoint, GetAllLandmakrsInDistance, double, bool), (arg("distance"), arg("stop_at_junction")=false))
.def("get_landmarks_of_type", CALL_RETURNING_LIST_3(cc::Waypoint, GetLandmakrsOfTypeInDistance, double, std::string, bool), (arg("distance"), arg("type"), arg("stop_at_junction")=false))
.def(self_ns::str(self_ns::self))

View File

@ -183,6 +183,41 @@
doc: >
Converts a given `location`, a point in the simulation, to a carla.GeoLocation, which represents world coordinates. The geographical location of the map is defined inside OpenDRIVE within the tag <b><georeference></b>.
# --------------------------------------
- def_name: get_all_landmarks
doc: >
Returns all the landmarks in the map. Landmarks retrieved using this method have a __null__ waypoint.
return: list(carla.Landmark)
# --------------------------------------
- def_name: get_all_landmarks_from_id
doc: >
Returns the landmarks with a certain OpenDRIVE ID. Landmarks retrieved using this method have a __null__ waypoint.
params:
- param_name: opendrive_id
type: string
doc: >
The OpenDRIVE ID of the landmarks.
return: list(carla.Landmark)
# --------------------------------------
- def_name: get_all_landmarks_of_type
doc: >
Returns the landmarks of a specific type. Landmarks retrieved using this method have a __null__ waypoint.
params:
- param_name: type
type: string
doc: >
The type of the landmarks.
return: list(carla.Landmark)
# --------------------------------------
- def_name: get_landmark_group
doc: >
Returns the landmarks in the same group as the specified landmark (including itself). Returns an empty list if the landmark does not belong to any group.
params:
- param_name: landmark
type: carla.Landmark
doc: >
A landmark that belongs to the group.
return: list(carla.Landmark)
# --------------------------------------
- def_name: get_spawn_points
return: list(carla.Transform)
doc: >
@ -216,20 +251,20 @@
# --------------------------------------
- def_name: get_waypoint_xodr
doc: >
Get a waypoint if all the parameters passed are correct, otherwise return None
Returns a waypoint if all the parameters passed are correct. Otherwise, returns __None__.
params:
- param_name: road_id
type: int
doc: >
Id of the road from where getting the waypoint
ID of the road to get the waypoint.
- param_name: lane_id
type: int
doc: >
Id of the lane to get the waypoint.
ID of the lane to get the waypoint.
- param_name: s
type: float
doc: >
Specify the length from the road start
Specify the length from the road start.
return: carla.Waypoint
# --------------------------------------
- def_name: __str__
@ -359,6 +394,11 @@
doc: >
Returns a list of waypoints from this to the start of the lane separated by a certain `distance`.
# --------------------------------------
- def_name: get_junction
return: carla.Junction
doc: >
If the waypoint belongs to a junction this function returns the asociated junction object. Otherwise returns null.
# --------------------------------------
- def_name: get_landmarks
params:
- param_name: distance