1pub mod rules;
32
33#[cxx::bridge(namespace = "maliput::api")]
34#[allow(clippy::needless_lifetimes)] #[allow(clippy::missing_safety_doc)]
36pub mod ffi {
37 struct ConstLanePtr {
40 pub lane: *const Lane,
41 }
42 struct MutIntersectionPtr {
45 pub intersection: *mut Intersection,
46 }
47 struct ConstLaneSRangeRef<'a> {
50 pub lane_s_range: &'a LaneSRange,
51 }
52
53 unsafe extern "C++" {
54 include!("api/api.h");
55 include!("cxx_utils/error_handling.h");
56
57 #[namespace = "maliput::math"]
58 type Vector3 = crate::math::ffi::Vector3;
59 #[namespace = "maliput::math"]
60 type Quaternion = crate::math::ffi::Quaternion;
61 #[namespace = "maliput::math"]
62 type Matrix3 = crate::math::ffi::Matrix3;
63 #[namespace = "maliput::math"]
64 type RollPitchYaw = crate::math::ffi::RollPitchYaw;
65 #[namespace = "maliput::api::rules"]
66 type RoadRulebook = crate::api::rules::ffi::RoadRulebook;
67 #[namespace = "maliput::api::rules"]
68 type TrafficLightBook = crate::api::rules::ffi::TrafficLightBook;
69
70 #[namespace = "maliput::api"]
71 type RoadNetwork;
73 fn road_geometry(self: &RoadNetwork) -> *const RoadGeometry;
74 fn intersection_book(self: Pin<&mut RoadNetwork>) -> *mut IntersectionBook;
75 fn traffic_light_book(self: &RoadNetwork) -> *const TrafficLightBook;
76 fn rulebook(self: &RoadNetwork) -> *const RoadRulebook;
77
78 type RoadGeometry;
80 fn RoadGeometry_id(road_geometry: &RoadGeometry) -> String;
81 fn num_junctions(self: &RoadGeometry) -> i32;
82 fn linear_tolerance(self: &RoadGeometry) -> f64;
83 fn angular_tolerance(self: &RoadGeometry) -> f64;
84 fn num_branch_points(self: &RoadGeometry) -> i32;
85 fn RoadGeometry_ToRoadPosition(
86 rg: &RoadGeometry,
87 inertial_position: &InertialPosition,
88 ) -> Result<UniquePtr<RoadPositionResult>>;
89 fn RoadGeometry_FindRoadPositions(
90 rg: &RoadGeometry,
91 inertial_position: &InertialPosition,
92 radius: f64,
93 ) -> Result<UniquePtr<CxxVector<RoadPositionResult>>>;
94 fn RoadGeometry_GetLane(rg: &RoadGeometry, lane_id: &String) -> ConstLanePtr;
95 fn RoadGeometry_GetLanes(rg: &RoadGeometry) -> UniquePtr<CxxVector<ConstLanePtr>>;
96 fn RoadGeometry_GetSegment(rg: &RoadGeometry, segment_id: &String) -> *const Segment;
97 fn RoadGeometry_GetJunction(rg: &RoadGeometry, junction_id: &String) -> *const Junction;
98 fn RoadGeometry_GetBranchPoint(rg: &RoadGeometry, branch_point_id: &String) -> *const BranchPoint;
99 fn RoadGeometry_BackendCustomCommand(rg: &RoadGeometry, command: &String) -> Result<String>;
100 fn RoadGeometry_GeoReferenceInfo(rg: &RoadGeometry) -> String;
101 type LanePosition;
103 fn LanePosition_new(s: f64, r: f64, h: f64) -> UniquePtr<LanePosition>;
104 fn s(self: &LanePosition) -> f64;
105 fn r(self: &LanePosition) -> f64;
106 fn h(self: &LanePosition) -> f64;
107 fn set_s(self: Pin<&mut LanePosition>, s: f64);
108 fn set_r(self: Pin<&mut LanePosition>, r: f64);
109 fn set_h(self: Pin<&mut LanePosition>, h: f64);
110 fn srh(self: &LanePosition) -> &Vector3;
111 fn set_srh(self: Pin<&mut LanePosition>, srh: &Vector3);
112 fn LanePosition_to_str(lane_pos: &LanePosition) -> String;
113
114 type InertialPosition;
116 fn InertialPosition_new(x: f64, y: f64, z: f64) -> UniquePtr<InertialPosition>;
117 fn x(self: &InertialPosition) -> f64;
118 fn y(self: &InertialPosition) -> f64;
119 fn z(self: &InertialPosition) -> f64;
120 fn set_x(self: Pin<&mut InertialPosition>, x: f64);
121 fn set_y(self: Pin<&mut InertialPosition>, y: f64);
122 fn set_z(self: Pin<&mut InertialPosition>, z: f64);
123 fn xyz(self: &InertialPosition) -> &Vector3;
124 fn set_xyz(self: Pin<&mut InertialPosition>, xyz: &Vector3);
125 fn length(self: &InertialPosition) -> f64;
126 fn Distance(self: &InertialPosition, other: &InertialPosition) -> f64;
127 fn InertialPosition_to_str(inertial_pos: &InertialPosition) -> String;
128 fn InertialPosition_operator_eq(lhs: &InertialPosition, rhs: &InertialPosition) -> bool;
129 fn InertialPosition_operator_sum(lhs: &InertialPosition, rhs: &InertialPosition)
130 -> UniquePtr<InertialPosition>;
131 fn InertialPosition_operator_sub(lhs: &InertialPosition, rhs: &InertialPosition)
132 -> UniquePtr<InertialPosition>;
133 fn InertialPosition_operator_mul_scalar(lhs: &InertialPosition, scalar: f64) -> UniquePtr<InertialPosition>;
134
135 type Lane;
137 fn to_left(self: &Lane) -> *const Lane;
138 fn to_right(self: &Lane) -> *const Lane;
139 fn index(self: &Lane) -> i32;
140 fn length(self: &Lane) -> f64;
141 fn Contains(self: &Lane, lane_position: &LanePosition) -> bool;
142 fn segment(self: &Lane) -> *const Segment;
143 fn Lane_id(lane: &Lane) -> String;
144 fn Lane_lane_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
145 fn Lane_segment_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
146 fn Lane_elevation_bounds(lane: &Lane, s: f64, r: f64) -> Result<UniquePtr<HBounds>>;
147 fn Lane_GetOrientation(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<Rotation>>;
148 fn Lane_ToInertialPosition(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<InertialPosition>>;
149 fn Lane_ToLanePosition(
150 lane: &Lane,
151 inertial_position: &InertialPosition,
152 ) -> Result<UniquePtr<LanePositionResult>>;
153 fn Lane_ToSegmentPosition(
154 lane: &Lane,
155 inertial_position: &InertialPosition,
156 ) -> Result<UniquePtr<LanePositionResult>>;
157 fn Lane_GetBranchPoint(lane: &Lane, start: bool) -> *const BranchPoint;
158 fn Lane_GetConfluentBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
159 fn Lane_GetOngoingBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
160 fn Lane_GetDefaultBranch(lane: &Lane, start: bool) -> UniquePtr<LaneEnd>;
161 fn Lane_EvalMotionDerivatives(
162 lane: &Lane,
163 lane_position: &LanePosition,
164 sigma_v: f64,
165 rho_v: f64,
166 eta_v: f64,
167 ) -> UniquePtr<LanePosition>;
168
169 type Segment;
171 fn num_lanes(self: &Segment) -> i32;
172 fn junction(self: &Segment) -> Result<*const Junction>;
173 fn lane(self: &Segment, index: i32) -> Result<*const Lane>;
174 fn Segment_id(segment: &Segment) -> String;
175
176 type Junction;
178 fn road_geometry(self: &Junction) -> *const RoadGeometry;
179 fn num_segments(self: &Junction) -> i32;
180 fn segment(self: &Junction, index: i32) -> Result<*const Segment>;
181 fn Junction_id(junction: &Junction) -> String;
182
183 type RoadPosition;
185 unsafe fn RoadPosition_new(lane: *const Lane, lane_pos: &LanePosition) -> UniquePtr<RoadPosition>;
189 fn RoadPosition_ToInertialPosition(road_position: &RoadPosition) -> UniquePtr<InertialPosition>;
190 fn RoadPosition_lane(road_position: &RoadPosition) -> *const Lane;
191 fn RoadPosition_pos(road_position: &RoadPosition) -> UniquePtr<LanePosition>;
192
193 type RoadPositionResult;
195 fn RoadPositionResult_road_position(result: &RoadPositionResult) -> UniquePtr<RoadPosition>;
196 fn RoadPositionResult_nearest_position(result: &RoadPositionResult) -> UniquePtr<InertialPosition>;
197 fn RoadPositionResult_distance(result: &RoadPositionResult) -> f64;
198
199 type LanePositionResult;
201 fn LanePositionResult_road_position(result: &LanePositionResult) -> UniquePtr<LanePosition>;
202 fn LanePositionResult_nearest_position(result: &LanePositionResult) -> UniquePtr<InertialPosition>;
203 fn LanePositionResult_distance(result: &LanePositionResult) -> f64;
204
205 type Rotation;
207 fn Rotation_new() -> UniquePtr<Rotation>;
208 fn Rotation_from_quat(q: &Quaternion) -> UniquePtr<Rotation>;
209 fn Rotation_from_rpy(rpy: &RollPitchYaw) -> UniquePtr<Rotation>;
210 fn roll(self: &Rotation) -> f64;
211 fn pitch(self: &Rotation) -> f64;
212 fn yaw(self: &Rotation) -> f64;
213 fn quat(self: &Rotation) -> &Quaternion;
214 fn Distance(self: &Rotation, other: &Rotation) -> f64;
215 fn Rotation_set_quat(r: Pin<&mut Rotation>, q: &Quaternion);
216 fn Rotation_rpy(r: &Rotation) -> UniquePtr<RollPitchYaw>;
217 fn Rotation_matrix(r: &Rotation) -> UniquePtr<Matrix3>;
218 fn Rotation_Apply(r: &Rotation, ip: &InertialPosition) -> UniquePtr<InertialPosition>;
219 fn Rotation_Reverse(r: &Rotation) -> UniquePtr<Rotation>;
220
221 type RBounds;
223 fn min(self: &RBounds) -> f64;
224 fn max(self: &RBounds) -> f64;
225
226 type HBounds;
228 fn min(self: &HBounds) -> f64;
229 fn max(self: &HBounds) -> f64;
230
231 type SRange;
233 fn SRange_new(s0: f64, s1: f64) -> UniquePtr<SRange>;
234 fn s0(self: &SRange) -> f64;
235 fn s1(self: &SRange) -> f64;
236 fn set_s0(self: Pin<&mut SRange>, s0: f64);
237 fn set_s1(self: Pin<&mut SRange>, s1: f64);
238 fn size(self: &SRange) -> f64;
239 fn WithS(self: &SRange) -> bool;
240 fn Intersects(self: &SRange, other: &SRange, tolerance: f64) -> bool;
241 fn Contains(self: &SRange, s_range: &SRange, tolerance: f64) -> bool;
242 fn SRange_GetIntersection(s_range: &SRange, other: &SRange, tolerance: f64) -> UniquePtr<SRange>;
243
244 type LaneSRange;
246 fn LaneSRange_new(lane_id: &String, s_range: &SRange) -> UniquePtr<LaneSRange>;
247 fn length(self: &LaneSRange) -> f64;
248 fn Intersects(self: &LaneSRange, other: &LaneSRange, tolerance: f64) -> bool;
249 fn Contains(self: &LaneSRange, lane_s_range: &LaneSRange, tolerance: f64) -> bool;
250 fn LaneSRange_lane_id(lane_s_range: &LaneSRange) -> String;
251 fn LaneSRange_s_range(lane_s_range: &LaneSRange) -> UniquePtr<SRange>;
252 fn LaneSRange_GetIntersection(
253 lane_s_range: &LaneSRange,
254 other: &LaneSRange,
255 tolerance: f64,
256 ) -> UniquePtr<LaneSRange>;
257
258 type LaneSRoute;
260 fn LaneSRoute_new(ranges: &CxxVector<ConstLaneSRangeRef>) -> UniquePtr<LaneSRoute>;
261 fn length(self: &LaneSRoute) -> f64;
262 fn Intersects(self: &LaneSRoute, other: &LaneSRoute, tolerance: f64) -> bool;
263 fn ranges(self: &LaneSRoute) -> &CxxVector<LaneSRange>;
264
265 type LaneEnd;
267 unsafe fn LaneEnd_new(lane: *const Lane, start: bool) -> UniquePtr<LaneEnd>;
273 fn LaneEnd_lane(lane_end: &LaneEnd) -> *const Lane;
274 fn LaneEnd_is_start(lane_end: &LaneEnd) -> bool;
275
276 type LaneEndSet;
278 fn size(self: &LaneEndSet) -> i32;
279 fn get(self: &LaneEndSet, index: i32) -> Result<&LaneEnd>;
280
281 type BranchPoint;
283 fn BranchPoint_id(branch_point: &BranchPoint) -> String;
284 fn road_geometry(self: &BranchPoint) -> *const RoadGeometry;
285 fn GetConfluentBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
286 fn GetOngoingBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
287 fn GetASide(self: &BranchPoint) -> *const LaneEndSet;
288 fn GetBSide(self: &BranchPoint) -> *const LaneEndSet;
289 fn BranchPoint_GetDefaultBranch(branch_point: &BranchPoint, end: &LaneEnd) -> UniquePtr<LaneEnd>;
290
291 type Intersection;
293 fn Intersection_id(intersection: &Intersection) -> String;
294
295 type IntersectionBook;
297 fn IntersectionBook_GetIntersection(book: Pin<&mut IntersectionBook>, id: &String) -> MutIntersectionPtr;
298 fn IntersectionBook_GetIntersections(
299 book: Pin<&mut IntersectionBook>,
300 ) -> UniquePtr<CxxVector<MutIntersectionPtr>>;
301
302 }
303 impl UniquePtr<RoadNetwork> {}
304 impl UniquePtr<LanePosition> {}
305}