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