use super::{Junction, LandmarkList, WaypointList};
use crate::{
error::ffi::with_ffi_error,
geom::Transform,
road::{
JuncId, LaneId, LaneType, RoadId, SectionId,
element::{LaneMarking, LaneMarking_LaneChange},
},
};
use carla_sys::carla_rust::client::FfiWaypoint;
use cxx::SharedPtr;
use derivative::Derivative;
use static_assertions::assert_impl_all;
#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[repr(transparent)]
pub struct Waypoint {
#[derivative(Debug = "ignore")]
pub(crate) inner: SharedPtr<FfiWaypoint>,
}
impl Waypoint {
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.id](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.id)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.id](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.id)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.id](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.id)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn id(&self) -> u64 {
self.inner.GetId()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.road_id](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.road_id)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.road_id](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.road_id)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.road_id](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.road_id)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn road_id(&self) -> RoadId {
self.inner.GetRoadId().into()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.section_id](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.section_id)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.section_id](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.section_id)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.section_id](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.section_id)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn section_id(&self) -> SectionId {
self.inner.GetSectionId().into()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.lane_id](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.lane_id)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.lane_id](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.lane_id)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.lane_id](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.lane_id)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn lane_id(&self) -> LaneId {
self.inner.GetLaneId().into()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.s](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.s)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.s](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.s)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.s](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.s)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn distance(&self) -> f64 {
self.inner.GetDistance()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.transform](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.transform)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.transform](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.transform)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.transform](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.transform)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn transform(&self) -> Transform {
Transform::from_ffi(self.inner.GetTransform())
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.junction_id](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.junction_id)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.junction_id](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.junction_id)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.junction_id](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.junction_id)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn junction_id(&self) -> JuncId {
self.inner.GetJunctionId().into()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.is_junction](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.is_junction)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.is_junction](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.is_junction)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.is_junction](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.is_junction)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn is_junction(&self) -> bool {
self.inner.IsJunction()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.get_junction](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.get_junction)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.get_junction](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.get_junction)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.get_junction](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.get_junction)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn junction(&self) -> crate::Result<Option<Junction>> {
let ptr = with_ffi_error("junction", |e| self.inner.GetJunction(e))?;
Ok(Junction::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.lane_width](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.lane_width)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.lane_width](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.lane_width)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.lane_width](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.lane_width)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn lane_width(&self) -> f64 {
self.inner.GetLaneWidth()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.lane_type](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.lane_type)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.lane_type](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.lane_type)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.lane_type](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.lane_type)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn type_(&self) -> LaneType {
self.inner.GetType()
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.next](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.next)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.next](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.next)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.next](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.next)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn next(&self, distance: f64) -> crate::Result<WaypointList> {
let ptr = with_ffi_error("next", |e| self.inner.GetNext(distance, e))?;
Ok(unsafe { WaypointList::from_cxx(ptr).unwrap_unchecked() })
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.previous](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.previous)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.previous](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.previous)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.previous](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.previous)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn previous(&self, distance: f64) -> crate::Result<WaypointList> {
let ptr = with_ffi_error("previous", |e| self.inner.GetPrevious(distance, e))?;
Ok(unsafe { WaypointList::from_cxx(ptr).unwrap_unchecked() })
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.next_until_lane_end](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.next_until_lane_end)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.next_until_lane_end](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.next_until_lane_end)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.next_until_lane_end](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.next_until_lane_end)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn next_until_lane_end(&self, distance: f64) -> crate::Result<WaypointList> {
let ptr = with_ffi_error("next_until_lane_end", |e| {
self.inner.GetNextUntilLaneEnd(distance, e)
})?;
Ok(unsafe { WaypointList::from_cxx(ptr).unwrap_unchecked() })
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.previous_until_lane_start](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.previous_until_lane_start)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.previous_until_lane_start](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.previous_until_lane_start)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.previous_until_lane_start](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.previous_until_lane_start)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn previous_until_lane_start(&self, distance: f64) -> crate::Result<WaypointList> {
let ptr = with_ffi_error("previous_until_lane_start", |e| {
self.inner.GetPreviousUntilLaneStart(distance, e)
})?;
Ok(unsafe { WaypointList::from_cxx(ptr).unwrap_unchecked() })
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.get_left_lane](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.get_left_lane)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.get_left_lane](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.get_left_lane)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.get_left_lane](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.get_left_lane)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn left(&self) -> crate::Result<Option<Waypoint>> {
let ptr = with_ffi_error("left", |e| self.inner.GetLeft(e))?;
Ok(Self::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.get_right_lane](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.get_right_lane)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.get_right_lane](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.get_right_lane)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.get_right_lane](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.get_right_lane)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn right(&self) -> crate::Result<Option<Waypoint>> {
let ptr = with_ffi_error("right", |e| self.inner.GetRight(e))?;
Ok(Self::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.right_lane_marking](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.right_lane_marking)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.right_lane_marking](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.right_lane_marking)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.right_lane_marking](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.right_lane_marking)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn right_lane_marking(&self) -> crate::Result<Option<LaneMarking>> {
let ptr = with_ffi_error("right_lane_marking", |e| self.inner.GetRightLaneMarking(e))?;
Ok(LaneMarking::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.left_lane_marking](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.left_lane_marking)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.left_lane_marking](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.left_lane_marking)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.left_lane_marking](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.left_lane_marking)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn left_lane_marking(&self) -> crate::Result<Option<LaneMarking>> {
let ptr = with_ffi_error("left_lane_marking", |e| self.inner.GetLeftLaneMarking(e))?;
Ok(LaneMarking::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.lane_change](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.lane_change)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.lane_change](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.lane_change)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.lane_change](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.lane_change)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn lane_change(&self) -> LaneMarking_LaneChange {
self.inner.GetLaneChange()
}
pub fn all_landmarks_in_distance(
&self,
distance: f64,
stop_at_junction: bool,
) -> crate::Result<LandmarkList> {
let ptr = with_ffi_error("all_landmarks_in_distance", |e| {
self.inner
.GetAllLandmarksInDistance(distance, stop_at_junction, e)
})?;
Ok(unsafe { LandmarkList::from_cxx(ptr).unwrap_unchecked() })
}
pub fn landmarks_of_type_in_distance(
&self,
distance: f64,
filter_type: &str,
stop_at_junction: bool,
) -> crate::Result<LandmarkList> {
let ptr = with_ffi_error("landmarks_of_type_in_distance", |e| {
self.inner
.GetLandmarksOfTypeInDistance(distance, filter_type, stop_at_junction, e)
})?;
Ok(unsafe { LandmarkList::from_cxx(ptr).unwrap_unchecked() })
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.get_landmarks](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.get_landmarks)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.get_landmarks](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.get_landmarks)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.get_landmarks](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.get_landmarks)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[inline]
pub fn get_landmarks(
&self,
distance: f64,
stop_at_junction: bool,
) -> crate::Result<LandmarkList> {
self.all_landmarks_in_distance(distance, stop_at_junction)
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Waypoint.get_landmarks_of_type](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Waypoint.get_landmarks_of_type)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Waypoint.get_landmarks_of_type](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Waypoint.get_landmarks_of_type)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Waypoint.get_landmarks_of_type](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Waypoint.get_landmarks_of_type)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[inline]
pub fn get_landmarks_of_type(
&self,
distance: f64,
type_: &str,
stop_at_junction: bool,
) -> crate::Result<LandmarkList> {
self.landmarks_of_type_in_distance(distance, type_, stop_at_junction)
}
pub(crate) fn from_cxx(ptr: SharedPtr<FfiWaypoint>) -> Option<Self> {
if ptr.is_null() {
None
} else {
Some(Self { inner: ptr })
}
}
}
assert_impl_all!(Waypoint: Send, Sync);