1pub mod rules;
32
33#[cxx::bridge(namespace = "maliput::api")]
34#[allow(clippy::missing_safety_doc)]
35pub mod ffi {
36 struct ConstLanePtr {
39 pub lane: *const Lane,
40 }
41 struct MutIntersectionPtr {
44 pub intersection: *mut Intersection,
45 }
46 struct ConstLaneSRangeRef<'a> {
49 pub lane_s_range: &'a LaneSRange,
50 }
51
52 #[repr(u32)]
56 pub enum LaneType {
57 kUnknown,
58 kDriving,
59 kTurn,
60 kHov,
61 kBus,
62 kTaxi,
63 kEmergency,
64 kShoulder,
65 kBiking,
66 kWalking,
67 kParking,
68 kStop,
69 kBorder,
70 kCurb,
71 kMedian,
72 kRestricted,
73 kConstruction,
74 kRail,
75 kEntry,
76 kExit,
77 kOnRamp,
78 kOffRamp,
79 kConnectingRamp,
80 kSlipLane,
81 kVirtual,
82 }
83
84 #[repr(u32)]
88 pub enum LaneMarkingType {
89 kUnknown,
90 kNone,
91 kSolid,
92 kBroken,
93 kSolidSolid,
94 kSolidBroken,
95 kBrokenSolid,
96 kBrokenBroken,
97 kBottsDots,
98 kGrass,
99 kCurb,
100 kEdge,
101 }
102
103 #[repr(u32)]
107 pub enum LaneMarkingWeight {
108 kUnknown,
109 kStandard,
110 kBold,
111 }
112
113 #[repr(u32)]
117 pub enum LaneMarkingColor {
118 kUnknown,
119 kWhite,
120 kYellow,
121 kOrange,
122 kRed,
123 kBlue,
124 kGreen,
125 kViolet,
126 }
127
128 #[repr(u32)]
132 pub enum LaneChangePermission {
133 kUnknown,
134 kAllowed,
135 kToLeft,
136 kToRight,
137 kProhibited,
138 }
139
140 unsafe extern "C++" {
141 include!("api/api.h");
142 include!("cxx_utils/error_handling.h");
143
144 #[namespace = "maliput::math"]
145 type Vector3 = crate::math::ffi::Vector3;
146 #[namespace = "maliput::math"]
147 type Quaternion = crate::math::ffi::Quaternion;
148 #[namespace = "maliput::math"]
149 type Matrix3 = crate::math::ffi::Matrix3;
150 #[namespace = "maliput::math"]
151 type RollPitchYaw = crate::math::ffi::RollPitchYaw;
152 #[namespace = "maliput::api::rules"]
153 type RoadRulebook = crate::api::rules::ffi::RoadRulebook;
154 #[namespace = "maliput::api::rules"]
155 type TrafficLightBook = crate::api::rules::ffi::TrafficLightBook;
156 #[namespace = "maliput::api::rules"]
157 type PhaseRingBook = crate::api::rules::ffi::PhaseRingBook;
158 #[namespace = "maliput::api::rules"]
159 type RuleRegistry = crate::api::rules::ffi::RuleRegistry;
160 #[namespace = "maliput::api::rules"]
161 type PhaseProvider = crate::api::rules::ffi::PhaseProvider;
162 #[namespace = "maliput::api::rules"]
163 type DiscreteValueRuleStateProvider = crate::api::rules::ffi::DiscreteValueRuleStateProvider;
164 #[namespace = "maliput::api::rules"]
165 type RangeValueRuleStateProvider = crate::api::rules::ffi::RangeValueRuleStateProvider;
166 #[namespace = "maliput::api::rules"]
167 type PhaseStateProviderQuery = crate::api::rules::ffi::PhaseStateProviderQuery;
168 #[namespace = "maliput::api::rules"]
169 type DiscreteValueRuleDiscreteValue = crate::api::rules::ffi::DiscreteValueRuleDiscreteValue;
170 #[namespace = "maliput::api::rules"]
171 type DiscreteValueRuleState = crate::api::rules::ffi::DiscreteValueRuleState;
172 #[namespace = "maliput::api::rules"]
173 type Phase = crate::api::rules::ffi::Phase;
174 #[namespace = "maliput::api::rules"]
175 type NextPhase = crate::api::rules::ffi::NextPhase;
176 #[namespace = "maliput::api::rules"]
177 type BulbState = crate::api::rules::ffi::BulbState;
178 #[namespace = "maliput::api::rules"]
179 type UniqueBulbId = crate::api::rules::ffi::UniqueBulbId;
180
181 #[namespace = "maliput::api"]
182 type RoadNetwork;
184 fn road_geometry(self: &RoadNetwork) -> *const RoadGeometry;
185 fn RoadNetwork_intersection_book(road_network: &RoadNetwork) -> *const IntersectionBook;
186 fn traffic_light_book(self: &RoadNetwork) -> *const TrafficLightBook;
187 fn rulebook(self: &RoadNetwork) -> *const RoadRulebook;
188 fn phase_ring_book(self: &RoadNetwork) -> *const PhaseRingBook;
189 fn rule_registry(self: &RoadNetwork) -> *const RuleRegistry;
190 fn RoadNetwork_phase_provider(road_network: &RoadNetwork) -> *const PhaseProvider;
191 fn RoadNetwork_discrete_value_rule_state_provider(
192 road_network: &RoadNetwork,
193 ) -> *const DiscreteValueRuleStateProvider;
194 fn RoadNetwork_range_value_rule_state_provider(
195 road_network: &RoadNetwork,
196 ) -> *const RangeValueRuleStateProvider;
197
198 type RoadGeometry;
200 fn RoadGeometry_id(road_geometry: &RoadGeometry) -> String;
201 fn num_junctions(self: &RoadGeometry) -> i32;
202 fn linear_tolerance(self: &RoadGeometry) -> f64;
203 fn angular_tolerance(self: &RoadGeometry) -> f64;
204 fn num_branch_points(self: &RoadGeometry) -> i32;
205 fn junction(self: &RoadGeometry, index: i32) -> Result<*const Junction>;
206 fn RoadGeometry_ToRoadPosition(
207 rg: &RoadGeometry,
208 inertial_position: &InertialPosition,
209 ) -> Result<UniquePtr<RoadPositionResult>>;
210 fn RoadGeometry_FindRoadPositions(
211 rg: &RoadGeometry,
212 inertial_position: &InertialPosition,
213 radius: f64,
214 ) -> Result<UniquePtr<CxxVector<RoadPositionResult>>>;
215 fn RoadGeometry_FindSurfaceRoadPositionsAtXY(
216 rg: &RoadGeometry,
217 x: f64,
218 y: f64,
219 radius: f64,
220 ) -> Result<UniquePtr<CxxVector<RoadPositionResult>>>;
221 fn RoadGeometry_GetLane(rg: &RoadGeometry, lane_id: &String) -> ConstLanePtr;
222 fn RoadGeometry_GetLanes(rg: &RoadGeometry) -> UniquePtr<CxxVector<ConstLanePtr>>;
223 fn RoadGeometry_GetSegment(rg: &RoadGeometry, segment_id: &String) -> *const Segment;
224 fn RoadGeometry_GetJunction(rg: &RoadGeometry, junction_id: &String) -> *const Junction;
225 fn RoadGeometry_GetBranchPoint(rg: &RoadGeometry, branch_point_id: &String) -> *const BranchPoint;
226 fn RoadGeometry_BackendCustomCommand(rg: &RoadGeometry, command: &String) -> Result<String>;
227 fn RoadGeometry_GeoReferenceInfo(rg: &RoadGeometry) -> String;
228 fn RoadGeometry_GetLaneBoundary(rg: &RoadGeometry, lane_boundary_id: &String) -> *const LaneBoundary;
229 type LanePosition;
231 fn LanePosition_new(s: f64, r: f64, h: f64) -> UniquePtr<LanePosition>;
232 fn s(self: &LanePosition) -> f64;
233 fn r(self: &LanePosition) -> f64;
234 fn h(self: &LanePosition) -> f64;
235 fn set_s(self: Pin<&mut LanePosition>, s: f64);
236 fn set_r(self: Pin<&mut LanePosition>, r: f64);
237 fn set_h(self: Pin<&mut LanePosition>, h: f64);
238 fn srh(self: &LanePosition) -> &Vector3;
239 fn set_srh(self: Pin<&mut LanePosition>, srh: &Vector3);
240 fn LanePosition_to_str(lane_pos: &LanePosition) -> String;
241
242 type InertialPosition;
244 fn InertialPosition_new(x: f64, y: f64, z: f64) -> UniquePtr<InertialPosition>;
245 fn x(self: &InertialPosition) -> f64;
246 fn y(self: &InertialPosition) -> f64;
247 fn z(self: &InertialPosition) -> f64;
248 fn set_x(self: Pin<&mut InertialPosition>, x: f64);
249 fn set_y(self: Pin<&mut InertialPosition>, y: f64);
250 fn set_z(self: Pin<&mut InertialPosition>, z: f64);
251 fn xyz(self: &InertialPosition) -> &Vector3;
252 fn set_xyz(self: Pin<&mut InertialPosition>, xyz: &Vector3);
253 fn length(self: &InertialPosition) -> f64;
254 fn Distance(self: &InertialPosition, other: &InertialPosition) -> f64;
255 fn InertialPosition_to_str(inertial_pos: &InertialPosition) -> String;
256 fn InertialPosition_operator_eq(lhs: &InertialPosition, rhs: &InertialPosition) -> bool;
257 fn InertialPosition_operator_sum(lhs: &InertialPosition, rhs: &InertialPosition)
258 -> UniquePtr<InertialPosition>;
259 fn InertialPosition_operator_sub(lhs: &InertialPosition, rhs: &InertialPosition)
260 -> UniquePtr<InertialPosition>;
261 fn InertialPosition_operator_mul_scalar(lhs: &InertialPosition, scalar: f64) -> UniquePtr<InertialPosition>;
262
263 type Lane;
265 fn to_left(self: &Lane) -> *const Lane;
266 fn to_right(self: &Lane) -> *const Lane;
267 fn index(self: &Lane) -> i32;
268 fn length(self: &Lane) -> f64;
269 fn Contains(self: &Lane, lane_position: &LanePosition) -> bool;
270 fn segment(self: &Lane) -> *const Segment;
271 fn GetCurvature(self: &Lane, lane_position: &LanePosition) -> Result<f64>;
272 fn Lane_id(lane: &Lane) -> String;
273 fn Lane_lane_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
274 fn Lane_segment_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
275 fn Lane_elevation_bounds(lane: &Lane, s: f64, r: f64) -> Result<UniquePtr<HBounds>>;
276 fn Lane_GetOrientation(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<Rotation>>;
277 fn Lane_ToInertialPosition(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<InertialPosition>>;
278 fn Lane_ToLanePosition(
279 lane: &Lane,
280 inertial_position: &InertialPosition,
281 ) -> Result<UniquePtr<LanePositionResult>>;
282 fn Lane_ToSegmentPosition(
283 lane: &Lane,
284 inertial_position: &InertialPosition,
285 ) -> Result<UniquePtr<LanePositionResult>>;
286 fn Lane_GetBranchPoint(lane: &Lane, start: bool) -> *const BranchPoint;
287 fn Lane_GetConfluentBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
288 fn Lane_GetOngoingBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
289 fn Lane_GetDefaultBranch(lane: &Lane, start: bool) -> UniquePtr<LaneEnd>;
290 fn Lane_EvalMotionDerivatives(
291 lane: &Lane,
292 lane_position: &LanePosition,
293 sigma_v: f64,
294 rho_v: f64,
295 eta_v: f64,
296 ) -> UniquePtr<LanePosition>;
297 type LaneType;
298 fn Lane_type(lane: &Lane) -> LaneType;
299 fn left_boundary(self: &Lane) -> Result<*const LaneBoundary>;
300 fn right_boundary(self: &Lane) -> Result<*const LaneBoundary>;
301
302 type Segment;
304 fn num_lanes(self: &Segment) -> i32;
305 fn junction(self: &Segment) -> Result<*const Junction>;
306 fn lane(self: &Segment, index: i32) -> Result<*const Lane>;
307 fn Segment_id(segment: &Segment) -> String;
308 fn num_boundaries(self: &Segment) -> i32;
309 fn boundary(self: &Segment, index: i32) -> Result<*const LaneBoundary>;
310
311 type Junction;
313 fn road_geometry(self: &Junction) -> *const RoadGeometry;
314 fn num_segments(self: &Junction) -> i32;
315 fn segment(self: &Junction, index: i32) -> Result<*const Segment>;
316 fn Junction_id(junction: &Junction) -> String;
317
318 type RoadPosition;
320 unsafe fn RoadPosition_new(lane: *const Lane, lane_pos: &LanePosition) -> UniquePtr<RoadPosition>;
324 fn RoadPosition_ToInertialPosition(road_position: &RoadPosition) -> Result<UniquePtr<InertialPosition>>;
325 fn RoadPosition_lane(road_position: &RoadPosition) -> *const Lane;
326 fn RoadPosition_pos(road_position: &RoadPosition) -> UniquePtr<LanePosition>;
327
328 type RoadPositionResult;
330 fn RoadPositionResult_road_position(result: &RoadPositionResult) -> UniquePtr<RoadPosition>;
331 fn RoadPositionResult_nearest_position(result: &RoadPositionResult) -> UniquePtr<InertialPosition>;
332 fn RoadPositionResult_distance(result: &RoadPositionResult) -> f64;
333
334 type LanePositionResult;
336 fn LanePositionResult_road_position(result: &LanePositionResult) -> UniquePtr<LanePosition>;
337 fn LanePositionResult_nearest_position(result: &LanePositionResult) -> UniquePtr<InertialPosition>;
338 fn LanePositionResult_distance(result: &LanePositionResult) -> f64;
339
340 type Rotation;
342 fn Rotation_new() -> UniquePtr<Rotation>;
343 fn Rotation_from_quat(q: &Quaternion) -> UniquePtr<Rotation>;
344 fn Rotation_from_rpy(rpy: &RollPitchYaw) -> UniquePtr<Rotation>;
345 fn roll(self: &Rotation) -> f64;
346 fn pitch(self: &Rotation) -> f64;
347 fn yaw(self: &Rotation) -> f64;
348 fn quat(self: &Rotation) -> &Quaternion;
349 fn Distance(self: &Rotation, other: &Rotation) -> f64;
350 fn Rotation_set_quat(r: Pin<&mut Rotation>, q: &Quaternion);
351 fn Rotation_rpy(r: &Rotation) -> UniquePtr<RollPitchYaw>;
352 fn Rotation_matrix(r: &Rotation) -> UniquePtr<Matrix3>;
353 fn Rotation_Apply(r: &Rotation, ip: &InertialPosition) -> UniquePtr<InertialPosition>;
354 fn Rotation_Reverse(r: &Rotation) -> UniquePtr<Rotation>;
355
356 type RBounds;
358 fn min(self: &RBounds) -> f64;
359 fn max(self: &RBounds) -> f64;
360
361 type HBounds;
363 fn min(self: &HBounds) -> f64;
364 fn max(self: &HBounds) -> f64;
365
366 type SRange;
368 fn SRange_new(s0: f64, s1: f64) -> UniquePtr<SRange>;
369 fn s0(self: &SRange) -> f64;
370 fn s1(self: &SRange) -> f64;
371 fn set_s0(self: Pin<&mut SRange>, s0: f64);
372 fn set_s1(self: Pin<&mut SRange>, s1: f64);
373 fn size(self: &SRange) -> f64;
374 fn WithS(self: &SRange) -> bool;
375 fn Intersects(self: &SRange, other: &SRange, tolerance: f64) -> bool;
376 fn Contains(self: &SRange, s_range: &SRange, tolerance: f64) -> bool;
377 fn SRange_GetIntersection(s_range: &SRange, other: &SRange, tolerance: f64) -> UniquePtr<SRange>;
378
379 type LaneSRange;
381 fn LaneSRange_new(lane_id: &String, s_range: &SRange) -> UniquePtr<LaneSRange>;
382 fn length(self: &LaneSRange) -> f64;
383 fn Intersects(self: &LaneSRange, other: &LaneSRange, tolerance: f64) -> bool;
384 fn Contains(self: &LaneSRange, lane_s_range: &LaneSRange, tolerance: f64) -> bool;
385 fn LaneSRange_lane_id(lane_s_range: &LaneSRange) -> String;
386 fn LaneSRange_s_range(lane_s_range: &LaneSRange) -> UniquePtr<SRange>;
387 fn LaneSRange_GetIntersection(
388 lane_s_range: &LaneSRange,
389 other: &LaneSRange,
390 tolerance: f64,
391 ) -> UniquePtr<LaneSRange>;
392
393 type LaneSRoute;
395 fn LaneSRoute_new(ranges: &CxxVector<ConstLaneSRangeRef>) -> UniquePtr<LaneSRoute>;
396 fn length(self: &LaneSRoute) -> f64;
397 fn Intersects(self: &LaneSRoute, other: &LaneSRoute, tolerance: f64) -> bool;
398 fn ranges(self: &LaneSRoute) -> &CxxVector<LaneSRange>;
399
400 type LaneEnd;
402 unsafe fn LaneEnd_new(lane: *const Lane, start: bool) -> UniquePtr<LaneEnd>;
408 fn LaneEnd_lane(lane_end: &LaneEnd) -> *const Lane;
409 fn LaneEnd_is_start(lane_end: &LaneEnd) -> bool;
410
411 type LaneEndSet;
413 fn size(self: &LaneEndSet) -> i32;
414 fn get(self: &LaneEndSet, index: i32) -> Result<&LaneEnd>;
415
416 type BranchPoint;
418 fn BranchPoint_id(branch_point: &BranchPoint) -> String;
419 fn road_geometry(self: &BranchPoint) -> *const RoadGeometry;
420 fn GetConfluentBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
421 fn GetOngoingBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
422 fn GetASide(self: &BranchPoint) -> *const LaneEndSet;
423 fn GetBSide(self: &BranchPoint) -> *const LaneEndSet;
424 fn BranchPoint_GetDefaultBranch(branch_point: &BranchPoint, end: &LaneEnd) -> UniquePtr<LaneEnd>;
425
426 type Intersection;
428 fn Intersection_id(intersection: &Intersection) -> String;
429 fn Intersection_Phase(intersection: &Intersection) -> UniquePtr<PhaseStateProviderQuery>;
430 fn region(self: &Intersection) -> &CxxVector<LaneSRange>;
431 fn Intersection_ring_id(intersection: &Intersection) -> String;
432 fn Intersection_unique_bulb_ids(intersection: &Intersection) -> UniquePtr<CxxVector<UniqueBulbId>>;
433 fn Intersection_bulb_state(intersection: &Intersection, bulb_id: &UniqueBulbId) -> UniquePtr<BulbState>;
434 fn Intersection_DiscreteValueRuleStates(
435 intersection: &Intersection,
436 ) -> UniquePtr<CxxVector<DiscreteValueRuleState>>;
437 fn Intersection_IncludesTrafficLight(intersection: &Intersection, traffic_light_id: &String) -> bool;
438 fn Intersection_IncludesDiscreteValueRule(intersection: &Intersection, rule_id: &String) -> bool;
439 fn Intersection_IncludesInertialPosition(
440 intersection: &Intersection,
441 inertial_position: &InertialPosition,
442 road_geometry: &RoadGeometry,
443 ) -> bool;
444
445 type IntersectionBook;
447 fn IntersectionBook_GetIntersection(book: &IntersectionBook, id: &String) -> MutIntersectionPtr;
448 fn IntersectionBook_GetIntersections(book: &IntersectionBook) -> UniquePtr<CxxVector<MutIntersectionPtr>>;
449 fn IntersectionBook_FindIntersectionTrafficLight(
450 book: &IntersectionBook,
451 traffic_light_id: &String,
452 ) -> MutIntersectionPtr;
453 fn IntersectionBook_FindIntersectionDiscreteValueRule(
454 book: &IntersectionBook,
455 rule_id: &String,
456 ) -> MutIntersectionPtr;
457 fn IntersectionBook_FindIntersectionInertialPosition(
458 book: &IntersectionBook,
459 inertial_position: &InertialPosition,
460 ) -> MutIntersectionPtr;
461
462 type LaneMarkingLine;
464 fn LaneMarkingLine_length(lane_marking_line: &LaneMarkingLine) -> f64;
465 fn LaneMarkingLine_space(lane_marking_line: &LaneMarkingLine) -> f64;
466 fn LaneMarkingLine_width(lane_marking_line: &LaneMarkingLine) -> f64;
467 fn LaneMarkingLine_r_offset(lane_marking_line: &LaneMarkingLine) -> f64;
468 type LaneMarkingColor;
469 fn LaneMarkingLine_color(lane_marking_line: &LaneMarkingLine) -> LaneMarkingColor;
470
471 type LaneMarking;
473 fn LaneMarking_width(lane_marking: &LaneMarking) -> f64;
474 fn LaneMarking_height(lane_marking: &LaneMarking) -> f64;
475 fn LaneMarking_material(lane_marking: &LaneMarking) -> String;
476 type LaneMarkingType;
477 fn LaneMarking_type(lane_marking: &LaneMarking) -> LaneMarkingType;
478 type LaneMarkingWeight;
479 fn LaneMarking_weight(lane_marking: &LaneMarking) -> LaneMarkingWeight;
480 fn LaneMarking_color(lane_marking: &LaneMarking) -> LaneMarkingColor;
481 type LaneChangePermission;
482 fn LaneMarking_lane_change(lane_marking: &LaneMarking) -> LaneChangePermission;
483 fn LaneMarking_lines(lane_marking: &LaneMarking) -> UniquePtr<CxxVector<LaneMarkingLine>>;
484
485 type LaneMarkingResult;
487 fn LaneMarkingResult_marking(lane_marking_result: &LaneMarkingResult) -> UniquePtr<LaneMarking>;
488 fn LaneMarkingResult_s_start(lane_marking_result: &LaneMarkingResult) -> f64;
489 fn LaneMarkingResult_s_end(lane_marking_result: &LaneMarkingResult) -> f64;
490
491 type LaneBoundary;
493 fn index(self: &LaneBoundary) -> i32;
494 fn lane_to_left(self: &LaneBoundary) -> *const Lane;
495 fn lane_to_right(self: &LaneBoundary) -> *const Lane;
496 fn segment(self: &LaneBoundary) -> *const Segment;
497 fn LaneBoundary_id(lane_boundary: &LaneBoundary) -> String;
498 fn LaneBoundary_GetMarking(lane_boundary: &LaneBoundary, s: f64) -> UniquePtr<LaneMarkingResult>;
499 fn LaneBoundary_GetMarkings(lane_boundary: &LaneBoundary) -> UniquePtr<CxxVector<LaneMarkingResult>>;
500 fn LaneBoundary_GetMarkingsByRange(
501 lane_boundary: &LaneBoundary,
502 s_start: f64,
503 s_end: f64,
504 ) -> UniquePtr<CxxVector<LaneMarkingResult>>;
505 }
506 impl UniquePtr<RoadNetwork> {}
507 impl UniquePtr<LanePosition> {}
508}