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::objects"]
162 type RoadMarkingBook = crate::api::objects::ffi::RoadMarkingBook;
163 #[namespace = "maliput::api::rules"]
164 type PhaseRingBook = crate::api::rules::ffi::PhaseRingBook;
165 #[namespace = "maliput::api::rules"]
166 type RuleRegistry = crate::api::rules::ffi::RuleRegistry;
167 #[namespace = "maliput::api::rules"]
168 type PhaseProvider = crate::api::rules::ffi::PhaseProvider;
169 #[namespace = "maliput::api::rules"]
170 type DiscreteValueRuleStateProvider = crate::api::rules::ffi::DiscreteValueRuleStateProvider;
171 #[namespace = "maliput::api::rules"]
172 type RangeValueRuleStateProvider = crate::api::rules::ffi::RangeValueRuleStateProvider;
173 #[namespace = "maliput::api::rules"]
174 type PhaseStateProviderQuery = crate::api::rules::ffi::PhaseStateProviderQuery;
175 #[namespace = "maliput::api::rules"]
176 type DiscreteValueRuleDiscreteValue = crate::api::rules::ffi::DiscreteValueRuleDiscreteValue;
177 #[namespace = "maliput::api::rules"]
178 type DiscreteValueRuleState = crate::api::rules::ffi::DiscreteValueRuleState;
179 #[namespace = "maliput::api::rules"]
180 type Phase = crate::api::rules::ffi::Phase;
181 #[namespace = "maliput::api::rules"]
182 type NextPhase = crate::api::rules::ffi::NextPhase;
183 #[namespace = "maliput::api::rules"]
184 type BulbState = crate::api::rules::ffi::BulbState;
185 #[namespace = "maliput::api::rules"]
186 type UniqueBulbId = crate::api::rules::ffi::UniqueBulbId;
187
188 #[namespace = "maliput::api"]
189 type RoadNetwork;
191 fn road_geometry(self: &RoadNetwork) -> *const RoadGeometry;
192 fn RoadNetwork_intersection_book(road_network: &RoadNetwork) -> *const IntersectionBook;
193 fn traffic_light_book(self: &RoadNetwork) -> *const TrafficLightBook;
194 fn traffic_sign_book(self: &RoadNetwork) -> *const TrafficSignBook;
195 fn road_object_book(self: &RoadNetwork) -> *const RoadObjectBook;
196 fn road_marking_book(self: &RoadNetwork) -> *const RoadMarkingBook;
197 fn rulebook(self: &RoadNetwork) -> *const RoadRulebook;
198 fn phase_ring_book(self: &RoadNetwork) -> *const PhaseRingBook;
199 fn rule_registry(self: &RoadNetwork) -> *const RuleRegistry;
200 fn RoadNetwork_phase_provider(road_network: &RoadNetwork) -> *const PhaseProvider;
201 fn RoadNetwork_discrete_value_rule_state_provider(
202 road_network: &RoadNetwork,
203 ) -> *const DiscreteValueRuleStateProvider;
204 fn RoadNetwork_range_value_rule_state_provider(
205 road_network: &RoadNetwork,
206 ) -> *const RangeValueRuleStateProvider;
207
208 type RoadGeometry;
210 fn RoadGeometry_id(road_geometry: &RoadGeometry) -> String;
211 fn num_junctions(self: &RoadGeometry) -> i32;
212 fn linear_tolerance(self: &RoadGeometry) -> f64;
213 fn angular_tolerance(self: &RoadGeometry) -> f64;
214 fn num_branch_points(self: &RoadGeometry) -> i32;
215 fn junction(self: &RoadGeometry, index: i32) -> Result<*const Junction>;
216 fn RoadGeometry_ToRoadPosition(
217 rg: &RoadGeometry,
218 inertial_position: &InertialPosition,
219 ) -> Result<UniquePtr<RoadPositionResult>>;
220 fn RoadGeometry_FindRoadPositions(
221 rg: &RoadGeometry,
222 inertial_position: &InertialPosition,
223 radius: f64,
224 ) -> Result<UniquePtr<CxxVector<RoadPositionResult>>>;
225 fn RoadGeometry_FindSurfaceRoadPositionsAtXY(
226 rg: &RoadGeometry,
227 x: f64,
228 y: f64,
229 radius: f64,
230 ) -> Result<UniquePtr<CxxVector<RoadPositionResult>>>;
231 fn RoadGeometry_GetLane(rg: &RoadGeometry, lane_id: &String) -> ConstLanePtr;
232 fn RoadGeometry_GetLanes(rg: &RoadGeometry) -> UniquePtr<CxxVector<ConstLanePtr>>;
233 fn RoadGeometry_GetSegment(rg: &RoadGeometry, segment_id: &String) -> *const Segment;
234 fn RoadGeometry_GetJunction(rg: &RoadGeometry, junction_id: &String) -> *const Junction;
235 fn RoadGeometry_GetBranchPoint(rg: &RoadGeometry, branch_point_id: &String) -> *const BranchPoint;
236 fn RoadGeometry_BackendCustomCommand(rg: &RoadGeometry, command: &String) -> Result<String>;
237 fn RoadGeometry_GeoReferenceInfo(rg: &RoadGeometry) -> String;
238 fn RoadGeometry_GetLaneBoundary(rg: &RoadGeometry, lane_boundary_id: &String) -> *const LaneBoundary;
239 type LanePosition;
241 fn LanePosition_new(s: f64, r: f64, h: f64) -> UniquePtr<LanePosition>;
242 fn s(self: &LanePosition) -> f64;
243 fn r(self: &LanePosition) -> f64;
244 fn h(self: &LanePosition) -> f64;
245 fn set_s(self: Pin<&mut LanePosition>, s: f64);
246 fn set_r(self: Pin<&mut LanePosition>, r: f64);
247 fn set_h(self: Pin<&mut LanePosition>, h: f64);
248 fn srh(self: &LanePosition) -> &Vector3;
249 fn set_srh(self: Pin<&mut LanePosition>, srh: &Vector3);
250 fn LanePosition_to_str(lane_pos: &LanePosition) -> String;
251
252 type InertialPosition;
254 fn InertialPosition_new(x: f64, y: f64, z: f64) -> UniquePtr<InertialPosition>;
255 fn x(self: &InertialPosition) -> f64;
256 fn y(self: &InertialPosition) -> f64;
257 fn z(self: &InertialPosition) -> f64;
258 fn set_x(self: Pin<&mut InertialPosition>, x: f64);
259 fn set_y(self: Pin<&mut InertialPosition>, y: f64);
260 fn set_z(self: Pin<&mut InertialPosition>, z: f64);
261 fn xyz(self: &InertialPosition) -> &Vector3;
262 fn set_xyz(self: Pin<&mut InertialPosition>, xyz: &Vector3);
263 fn length(self: &InertialPosition) -> f64;
264 fn Distance(self: &InertialPosition, other: &InertialPosition) -> f64;
265 fn InertialPosition_to_str(inertial_pos: &InertialPosition) -> String;
266 fn InertialPosition_operator_eq(lhs: &InertialPosition, rhs: &InertialPosition) -> bool;
267 fn InertialPosition_operator_sum(lhs: &InertialPosition, rhs: &InertialPosition)
268 -> UniquePtr<InertialPosition>;
269 fn InertialPosition_operator_sub(lhs: &InertialPosition, rhs: &InertialPosition)
270 -> UniquePtr<InertialPosition>;
271 fn InertialPosition_operator_mul_scalar(lhs: &InertialPosition, scalar: f64) -> UniquePtr<InertialPosition>;
272
273 type Lane;
275 fn to_left(self: &Lane) -> *const Lane;
276 fn to_right(self: &Lane) -> *const Lane;
277 fn index(self: &Lane) -> i32;
278 fn length(self: &Lane) -> f64;
279 fn Contains(self: &Lane, lane_position: &LanePosition) -> bool;
280 fn segment(self: &Lane) -> *const Segment;
281 fn GetCurvature(self: &Lane, lane_position: &LanePosition) -> Result<f64>;
282 fn Lane_id(lane: &Lane) -> String;
283 fn Lane_lane_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
284 fn Lane_segment_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
285 fn Lane_elevation_bounds(lane: &Lane, s: f64, r: f64) -> Result<UniquePtr<HBounds>>;
286 fn Lane_GetOrientation(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<Rotation>>;
287 fn Lane_ToInertialPosition(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<InertialPosition>>;
288 fn Lane_ToLanePosition(
289 lane: &Lane,
290 inertial_position: &InertialPosition,
291 ) -> Result<UniquePtr<LanePositionResult>>;
292 fn Lane_ToSegmentPosition(
293 lane: &Lane,
294 inertial_position: &InertialPosition,
295 ) -> Result<UniquePtr<LanePositionResult>>;
296 fn Lane_GetBranchPoint(lane: &Lane, start: bool) -> *const BranchPoint;
297 fn Lane_GetConfluentBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
298 fn Lane_GetOngoingBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
299 fn Lane_GetDefaultBranch(lane: &Lane, start: bool) -> UniquePtr<LaneEnd>;
300 fn Lane_EvalMotionDerivatives(
301 lane: &Lane,
302 lane_position: &LanePosition,
303 sigma_v: f64,
304 rho_v: f64,
305 eta_v: f64,
306 ) -> UniquePtr<LanePosition>;
307 type LaneType;
308 fn Lane_type(lane: &Lane) -> LaneType;
309 fn left_boundary(self: &Lane) -> Result<*const LaneBoundary>;
310 fn right_boundary(self: &Lane) -> Result<*const LaneBoundary>;
311
312 type Segment;
314 fn num_lanes(self: &Segment) -> i32;
315 fn junction(self: &Segment) -> Result<*const Junction>;
316 fn lane(self: &Segment, index: i32) -> Result<*const Lane>;
317 fn Segment_id(segment: &Segment) -> String;
318 fn num_boundaries(self: &Segment) -> i32;
319 fn boundary(self: &Segment, index: i32) -> Result<*const LaneBoundary>;
320
321 type Junction;
323 fn road_geometry(self: &Junction) -> *const RoadGeometry;
324 fn num_segments(self: &Junction) -> i32;
325 fn segment(self: &Junction, index: i32) -> Result<*const Segment>;
326 fn Junction_id(junction: &Junction) -> String;
327
328 type RoadPosition;
330 unsafe fn RoadPosition_new(lane: *const Lane, lane_pos: &LanePosition) -> UniquePtr<RoadPosition>;
334 fn RoadPosition_ToInertialPosition(road_position: &RoadPosition) -> Result<UniquePtr<InertialPosition>>;
335 fn RoadPosition_lane(road_position: &RoadPosition) -> *const Lane;
336 fn RoadPosition_pos(road_position: &RoadPosition) -> UniquePtr<LanePosition>;
337
338 type RoadPositionResult;
340 fn RoadPositionResult_road_position(result: &RoadPositionResult) -> UniquePtr<RoadPosition>;
341 fn RoadPositionResult_nearest_position(result: &RoadPositionResult) -> UniquePtr<InertialPosition>;
342 fn RoadPositionResult_distance(result: &RoadPositionResult) -> f64;
343
344 type LanePositionResult;
346 fn LanePositionResult_road_position(result: &LanePositionResult) -> UniquePtr<LanePosition>;
347 fn LanePositionResult_nearest_position(result: &LanePositionResult) -> UniquePtr<InertialPosition>;
348 fn LanePositionResult_distance(result: &LanePositionResult) -> f64;
349
350 type Rotation;
352 fn Rotation_new() -> UniquePtr<Rotation>;
353 fn Rotation_from_quat(q: &Quaternion) -> UniquePtr<Rotation>;
354 fn Rotation_from_rpy(rpy: &RollPitchYaw) -> UniquePtr<Rotation>;
355 fn roll(self: &Rotation) -> f64;
356 fn pitch(self: &Rotation) -> f64;
357 fn yaw(self: &Rotation) -> f64;
358 fn quat(self: &Rotation) -> &Quaternion;
359 fn Distance(self: &Rotation, other: &Rotation) -> f64;
360 fn Rotation_set_quat(r: Pin<&mut Rotation>, q: &Quaternion);
361 fn Rotation_rpy(r: &Rotation) -> UniquePtr<RollPitchYaw>;
362 fn Rotation_matrix(r: &Rotation) -> UniquePtr<Matrix3>;
363 fn Rotation_Apply(r: &Rotation, ip: &InertialPosition) -> UniquePtr<InertialPosition>;
364 fn Rotation_Reverse(r: &Rotation) -> UniquePtr<Rotation>;
365
366 type RBounds;
368 fn min(self: &RBounds) -> f64;
369 fn max(self: &RBounds) -> f64;
370
371 type HBounds;
373 fn min(self: &HBounds) -> f64;
374 fn max(self: &HBounds) -> f64;
375
376 type SRange;
378 fn SRange_new(s0: f64, s1: f64) -> UniquePtr<SRange>;
379 fn s0(self: &SRange) -> f64;
380 fn s1(self: &SRange) -> f64;
381 fn set_s0(self: Pin<&mut SRange>, s0: f64);
382 fn set_s1(self: Pin<&mut SRange>, s1: f64);
383 fn size(self: &SRange) -> f64;
384 fn WithS(self: &SRange) -> bool;
385 fn Intersects(self: &SRange, other: &SRange, tolerance: f64) -> bool;
386 fn Contains(self: &SRange, s_range: &SRange, tolerance: f64) -> bool;
387 fn SRange_GetIntersection(s_range: &SRange, other: &SRange, tolerance: f64) -> UniquePtr<SRange>;
388
389 type LaneSRange;
391 fn LaneSRange_new(lane_id: &String, s_range: &SRange) -> UniquePtr<LaneSRange>;
392 fn length(self: &LaneSRange) -> f64;
393 fn Intersects(self: &LaneSRange, other: &LaneSRange, tolerance: f64) -> bool;
394 fn Contains(self: &LaneSRange, lane_s_range: &LaneSRange, tolerance: f64) -> bool;
395 fn LaneSRange_lane_id(lane_s_range: &LaneSRange) -> String;
396 fn LaneSRange_s_range(lane_s_range: &LaneSRange) -> UniquePtr<SRange>;
397 fn LaneSRange_GetIntersection(
398 lane_s_range: &LaneSRange,
399 other: &LaneSRange,
400 tolerance: f64,
401 ) -> UniquePtr<LaneSRange>;
402
403 type LaneSRoute;
405 fn LaneSRoute_new(ranges: &CxxVector<ConstLaneSRangeRef>) -> UniquePtr<LaneSRoute>;
406 fn length(self: &LaneSRoute) -> f64;
407 fn Intersects(self: &LaneSRoute, other: &LaneSRoute, tolerance: f64) -> bool;
408 fn ranges(self: &LaneSRoute) -> &CxxVector<LaneSRange>;
409
410 type LaneEnd;
412 unsafe fn LaneEnd_new(lane: *const Lane, start: bool) -> UniquePtr<LaneEnd>;
418 fn LaneEnd_lane(lane_end: &LaneEnd) -> *const Lane;
419 fn LaneEnd_is_start(lane_end: &LaneEnd) -> bool;
420
421 type LaneEndSet;
423 fn size(self: &LaneEndSet) -> i32;
424 fn get(self: &LaneEndSet, index: i32) -> Result<&LaneEnd>;
425
426 type BranchPoint;
428 fn BranchPoint_id(branch_point: &BranchPoint) -> String;
429 fn road_geometry(self: &BranchPoint) -> *const RoadGeometry;
430 fn GetConfluentBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
431 fn GetOngoingBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
432 fn GetASide(self: &BranchPoint) -> *const LaneEndSet;
433 fn GetBSide(self: &BranchPoint) -> *const LaneEndSet;
434 fn BranchPoint_GetDefaultBranch(branch_point: &BranchPoint, end: &LaneEnd) -> UniquePtr<LaneEnd>;
435
436 type Intersection;
438 fn Intersection_id(intersection: &Intersection) -> String;
439 fn Intersection_Phase(intersection: &Intersection) -> UniquePtr<PhaseStateProviderQuery>;
440 fn region(self: &Intersection) -> &CxxVector<LaneSRange>;
441 fn Intersection_ring_id(intersection: &Intersection) -> String;
442 fn Intersection_unique_bulb_ids(intersection: &Intersection) -> UniquePtr<CxxVector<UniqueBulbId>>;
443 fn Intersection_bulb_state(intersection: &Intersection, bulb_id: &UniqueBulbId) -> UniquePtr<BulbState>;
444 fn Intersection_DiscreteValueRuleStates(
445 intersection: &Intersection,
446 ) -> UniquePtr<CxxVector<DiscreteValueRuleState>>;
447 fn Intersection_IncludesTrafficLight(intersection: &Intersection, traffic_light_id: &String) -> bool;
448 fn Intersection_IncludesDiscreteValueRule(intersection: &Intersection, rule_id: &String) -> bool;
449 fn Intersection_IncludesInertialPosition(
450 intersection: &Intersection,
451 inertial_position: &InertialPosition,
452 road_geometry: &RoadGeometry,
453 ) -> bool;
454
455 type IntersectionBook;
457 fn IntersectionBook_GetIntersection(book: &IntersectionBook, id: &String) -> MutIntersectionPtr;
458 fn IntersectionBook_GetIntersections(book: &IntersectionBook) -> UniquePtr<CxxVector<MutIntersectionPtr>>;
459 fn IntersectionBook_FindIntersectionTrafficLight(
460 book: &IntersectionBook,
461 traffic_light_id: &String,
462 ) -> MutIntersectionPtr;
463 fn IntersectionBook_FindIntersectionDiscreteValueRule(
464 book: &IntersectionBook,
465 rule_id: &String,
466 ) -> MutIntersectionPtr;
467 fn IntersectionBook_FindIntersectionInertialPosition(
468 book: &IntersectionBook,
469 inertial_position: &InertialPosition,
470 ) -> MutIntersectionPtr;
471
472 type LaneMarkingLine;
474 fn LaneMarkingLine_length(lane_marking_line: &LaneMarkingLine) -> f64;
475 fn LaneMarkingLine_space(lane_marking_line: &LaneMarkingLine) -> f64;
476 fn LaneMarkingLine_width(lane_marking_line: &LaneMarkingLine) -> f64;
477 fn LaneMarkingLine_r_offset(lane_marking_line: &LaneMarkingLine) -> f64;
478 type LaneMarkingColor;
479 fn LaneMarkingLine_color(lane_marking_line: &LaneMarkingLine) -> LaneMarkingColor;
480
481 type LaneMarking;
483 fn LaneMarking_width(lane_marking: &LaneMarking) -> f64;
484 fn LaneMarking_height(lane_marking: &LaneMarking) -> f64;
485 fn LaneMarking_material(lane_marking: &LaneMarking) -> String;
486 type LaneMarkingType;
487 fn LaneMarking_type(lane_marking: &LaneMarking) -> LaneMarkingType;
488 type LaneMarkingWeight;
489 fn LaneMarking_weight(lane_marking: &LaneMarking) -> LaneMarkingWeight;
490 fn LaneMarking_color(lane_marking: &LaneMarking) -> LaneMarkingColor;
491 type LaneChangePermission;
492 fn LaneMarking_lane_change(lane_marking: &LaneMarking) -> LaneChangePermission;
493 fn LaneMarking_lines(lane_marking: &LaneMarking) -> UniquePtr<CxxVector<LaneMarkingLine>>;
494
495 type LaneMarkingResult;
497 fn LaneMarkingResult_marking(lane_marking_result: &LaneMarkingResult) -> UniquePtr<LaneMarking>;
498 fn LaneMarkingResult_s_start(lane_marking_result: &LaneMarkingResult) -> f64;
499 fn LaneMarkingResult_s_end(lane_marking_result: &LaneMarkingResult) -> f64;
500
501 type LaneBoundary;
503 fn index(self: &LaneBoundary) -> i32;
504 fn lane_to_left(self: &LaneBoundary) -> *const Lane;
505 fn lane_to_right(self: &LaneBoundary) -> *const Lane;
506 fn segment(self: &LaneBoundary) -> *const Segment;
507 fn LaneBoundary_id(lane_boundary: &LaneBoundary) -> String;
508 fn LaneBoundary_GetMarking(lane_boundary: &LaneBoundary, s: f64) -> UniquePtr<LaneMarkingResult>;
509 fn LaneBoundary_GetMarkings(lane_boundary: &LaneBoundary) -> UniquePtr<CxxVector<LaneMarkingResult>>;
510 fn LaneBoundary_GetMarkingsByRange(
511 lane_boundary: &LaneBoundary,
512 s_start: f64,
513 s_end: f64,
514 ) -> UniquePtr<CxxVector<LaneMarkingResult>>;
515 }
516 impl UniquePtr<RoadNetwork> {}
517 impl UniquePtr<LanePosition> {}
518}