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