roadmark binding in PythonAPI and adapted no rendering mode
This commit is contained in:
parent
a5f7261f27
commit
a953834f5e
|
@ -76,11 +76,11 @@ namespace client {
|
|||
static_cast<typename std::underlying_type<EnumT>::type>(rhs));
|
||||
}
|
||||
|
||||
const road::element::WaypointInfoRoadMark Waypoint::GetRightRoadMark() const {
|
||||
road::element::WaypointInfoRoadMark Waypoint::GetRightRoadMark() const {
|
||||
return road::element::WaypointInfoRoadMark(*_mark_record.first);
|
||||
}
|
||||
|
||||
const road::element::WaypointInfoRoadMark Waypoint::GetLeftRoadMark() const {
|
||||
road::element::WaypointInfoRoadMark Waypoint::GetLeftRoadMark() const {
|
||||
return road::element::WaypointInfoRoadMark(*_mark_record.second);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ namespace client {
|
|||
|
||||
SharedPtr<Waypoint> Left() const;
|
||||
|
||||
const road::element::WaypointInfoRoadMark GetRightRoadMark() const;
|
||||
road::element::WaypointInfoRoadMark GetRightRoadMark() const;
|
||||
|
||||
const road::element::WaypointInfoRoadMark GetLeftRoadMark() const;
|
||||
road::element::WaypointInfoRoadMark GetLeftRoadMark() const;
|
||||
|
||||
Waypoint::LaneChange GetLaneChange() const;
|
||||
|
||||
|
|
|
@ -492,12 +492,17 @@ class MapImage(object):
|
|||
transform.rotation.yaw += 90
|
||||
return transform.location + shift * transform.get_forward_vector()
|
||||
|
||||
def does_cross_solid_line(waypoint, shift):
|
||||
w = carla_map.get_waypoint(lateral_shift(waypoint.transform, shift), project_to_road=False)
|
||||
if w is None or w.road_id != waypoint.road_id or w.lane_type != carla.LaneType.Driving:
|
||||
return True
|
||||
else:
|
||||
return (w.lane_id * waypoint.lane_id < 0) or w.lane_id == waypoint.lane_id
|
||||
def does_cross_solid_line_left(waypoint):
|
||||
return (waypoint.get_left_road_mark().type == carla.LaneMarking.Solid)
|
||||
|
||||
def does_cross_solid_line_right(waypoint):
|
||||
return (waypoint.get_right_road_mark().type == carla.LaneMarking.Solid)
|
||||
|
||||
def has_line_left(waypoint):
|
||||
return (waypoint.get_left_road_mark().type != carla.LaneMarking.NONE)
|
||||
|
||||
def has_line_right(waypoint):
|
||||
return (waypoint.get_right_road_mark().type != carla.LaneMarking.NONE)
|
||||
|
||||
def draw_topology (carla_topology, index):
|
||||
topology = [x[index] for x in carla_topology]
|
||||
|
@ -531,11 +536,11 @@ class MapImage(object):
|
|||
draw_lane_marking(
|
||||
map_surface,
|
||||
[world_to_pixel(x) for x in left_marking],
|
||||
does_cross_solid_line(sample, -sample.lane_width * 1.2))
|
||||
does_cross_solid_line_left(sample) and has_line_left(sample))
|
||||
draw_lane_marking(
|
||||
map_surface,
|
||||
[world_to_pixel(x) for x in right_marking],
|
||||
does_cross_solid_line(sample, sample.lane_width * 1.2))
|
||||
does_cross_solid_line_right(sample) and has_line_right(sample))
|
||||
for n, wp in enumerate(waypoints):
|
||||
if (n % 400) == 0:
|
||||
draw_arrow(map_surface, wp.transform)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <carla/PythonUtil.h>
|
||||
#include <carla/client/Map.h>
|
||||
#include <carla/client/Waypoint.h>
|
||||
|
||||
#include "carla/road/element/WaypointInformationTypes.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace carla {
|
||||
|
@ -58,6 +58,7 @@ void export_map() {
|
|||
namespace cc = carla::client;
|
||||
namespace cr = carla::road;
|
||||
namespace cg = carla::geom;
|
||||
namespace cre = carla::road::element;
|
||||
|
||||
enum_<cr::Lane::LaneType>("LaneType")
|
||||
.value("NONE", cr::Lane::LaneType::None) // None is reserved in Python3
|
||||
|
@ -97,11 +98,42 @@ void export_map() {
|
|||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
enum_<cc::Waypoint::LaneChange>("LaneChange")
|
||||
.value("NONE", cc::Waypoint::LaneChange::None) // None is reserved in Python3
|
||||
.value("Right", cc::Waypoint::LaneChange::Right)
|
||||
.value("Left", cc::Waypoint::LaneChange::Left)
|
||||
.value("Both", cc::Waypoint::LaneChange::Both)
|
||||
enum_<cre::LaneMarking>("LaneMarking")
|
||||
.value("Other", cre::LaneMarking::Other)
|
||||
.value("Broken", cre::LaneMarking::Broken)
|
||||
.value("Solid", cre::LaneMarking::Solid)
|
||||
.value("SolidSolid", cre::LaneMarking::SolidSolid)
|
||||
.value("SolidBroken", cre::LaneMarking::SolidBroken)
|
||||
.value("BrokenSolid", cre::LaneMarking::BrokenSolid)
|
||||
.value("BrokenBroken", cre::LaneMarking::BrokenBroken)
|
||||
.value("BottsDots", cre::LaneMarking::BottsDots)
|
||||
.value("Grass", cre::LaneMarking::Grass)
|
||||
.value("Curb", cre::LaneMarking::Curb)
|
||||
.value("NONE", cre::LaneMarking::None) // None is reserved in Python3
|
||||
;
|
||||
|
||||
enum_<cre::WaypointInfoRoadMark::LaneChange>("RoadMarkLaneChange")
|
||||
.value("Increase", cre::WaypointInfoRoadMark::LaneChange::Increase)
|
||||
.value("Decrease", cre::WaypointInfoRoadMark::LaneChange::Decrease)
|
||||
.value("Both", cre::WaypointInfoRoadMark::LaneChange::Both)
|
||||
.value("NONE", cre::WaypointInfoRoadMark::LaneChange::None) // None is reserved in Python3
|
||||
;
|
||||
|
||||
enum_<cre::WaypointInfoRoadMark::Color>("RoadMarkColor")
|
||||
.value("Standard", cre::WaypointInfoRoadMark::Color::Standard)
|
||||
.value("Blue", cre::WaypointInfoRoadMark::Color::Blue)
|
||||
.value("Green", cre::WaypointInfoRoadMark::Color::Green)
|
||||
.value("Red", cre::WaypointInfoRoadMark::Color::Red)
|
||||
.value("White", cre::WaypointInfoRoadMark::Color::White)
|
||||
.value("Yellow", cre::WaypointInfoRoadMark::Color::Yellow)
|
||||
.value("Other", cre::WaypointInfoRoadMark::Color::Other)
|
||||
;
|
||||
|
||||
class_<cre::WaypointInfoRoadMark>("WaypointInfoRoadMark", no_init)
|
||||
.add_property("width", &cre::WaypointInfoRoadMark::width)
|
||||
.add_property("color", &cre::WaypointInfoRoadMark::color)
|
||||
.add_property("lane_change", &cre::WaypointInfoRoadMark::lane_change)
|
||||
.add_property("type", &cre::WaypointInfoRoadMark::type)
|
||||
;
|
||||
|
||||
class_<cc::Waypoint, boost::noncopyable, boost::shared_ptr<cc::Waypoint>>("Waypoint", no_init)
|
||||
|
@ -115,6 +147,8 @@ void export_map() {
|
|||
.add_property("s", &cc::Waypoint::GetDistance)
|
||||
.add_property("lane_change", &cc::Waypoint::GetLaneChange)
|
||||
.add_property("lane_type", &cc::Waypoint::GetType)
|
||||
.def("get_right_road_mark", &cc::Waypoint::GetRightRoadMark)
|
||||
.def("get_left_road_mark", &cc::Waypoint::GetLeftRoadMark)
|
||||
.def("next", CALL_RETURNING_LIST_1(cc::Waypoint, Next, double), (args("distance")))
|
||||
.def("get_right_lane", &cc::Waypoint::Right)
|
||||
.def("get_left_lane", &cc::Waypoint::Left)
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace data {
|
|||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const LaneInvasionEvent &meas) {
|
||||
out << "LaneInvasionEvent(frame=" << meas.GetFrameNumber()
|
||||
out << "LaneInvasionEvent(frame=" << meas.GetFrameNumber()
|
||||
<< ", timestamp=" << meas.GetTimestamp()
|
||||
<< ')';
|
||||
return out;
|
||||
|
@ -159,7 +159,6 @@ void export_sensor_data() {
|
|||
namespace cr = carla::rpc;
|
||||
namespace cs = carla::sensor;
|
||||
namespace csd = carla::sensor::data;
|
||||
namespace cre = carla::road::element;
|
||||
|
||||
class_<cs::SensorData, boost::noncopyable, boost::shared_ptr<cs::SensorData>>("SensorData", no_init)
|
||||
.add_property("frame_number", &cs::SensorData::GetFrameNumber)
|
||||
|
@ -223,12 +222,6 @@ void export_sensor_data() {
|
|||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
enum_<cre::LaneMarking>("LaneMarking")
|
||||
.value("Other", cre::LaneMarking::Other)
|
||||
.value("Broken", cre::LaneMarking::Broken)
|
||||
.value("Solid", cre::LaneMarking::Solid)
|
||||
;
|
||||
|
||||
class_<csd::LaneInvasionEvent, bases<cs::SensorData>, boost::noncopyable, boost::shared_ptr<csd::LaneInvasionEvent>>("LaneInvasionEvent", no_init)
|
||||
.add_property("actor", &csd::LaneInvasionEvent::GetActor)
|
||||
.add_property("crossed_lane_markings", CALL_RETURNING_LIST(csd::LaneInvasionEvent, GetCrossedLaneMarkings))
|
||||
|
|
Loading…
Reference in New Issue