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_GetLane(rg: &RoadGeometry, lane_id: &String) -> ConstLanePtr;
216 fn RoadGeometry_GetLanes(rg: &RoadGeometry) -> UniquePtr<CxxVector<ConstLanePtr>>;
217 fn RoadGeometry_GetSegment(rg: &RoadGeometry, segment_id: &String) -> *const Segment;
218 fn RoadGeometry_GetJunction(rg: &RoadGeometry, junction_id: &String) -> *const Junction;
219 fn RoadGeometry_GetBranchPoint(rg: &RoadGeometry, branch_point_id: &String) -> *const BranchPoint;
220 fn RoadGeometry_BackendCustomCommand(rg: &RoadGeometry, command: &String) -> Result<String>;
221 fn RoadGeometry_GeoReferenceInfo(rg: &RoadGeometry) -> String;
222 fn RoadGeometry_GetLaneBoundary(rg: &RoadGeometry, lane_boundary_id: &String) -> *const LaneBoundary;
223 type LanePosition;
225 fn LanePosition_new(s: f64, r: f64, h: f64) -> UniquePtr<LanePosition>;
226 fn s(self: &LanePosition) -> f64;
227 fn r(self: &LanePosition) -> f64;
228 fn h(self: &LanePosition) -> f64;
229 fn set_s(self: Pin<&mut LanePosition>, s: f64);
230 fn set_r(self: Pin<&mut LanePosition>, r: f64);
231 fn set_h(self: Pin<&mut LanePosition>, h: f64);
232 fn srh(self: &LanePosition) -> &Vector3;
233 fn set_srh(self: Pin<&mut LanePosition>, srh: &Vector3);
234 fn LanePosition_to_str(lane_pos: &LanePosition) -> String;
235
236 type InertialPosition;
238 fn InertialPosition_new(x: f64, y: f64, z: f64) -> UniquePtr<InertialPosition>;
239 fn x(self: &InertialPosition) -> f64;
240 fn y(self: &InertialPosition) -> f64;
241 fn z(self: &InertialPosition) -> f64;
242 fn set_x(self: Pin<&mut InertialPosition>, x: f64);
243 fn set_y(self: Pin<&mut InertialPosition>, y: f64);
244 fn set_z(self: Pin<&mut InertialPosition>, z: f64);
245 fn xyz(self: &InertialPosition) -> &Vector3;
246 fn set_xyz(self: Pin<&mut InertialPosition>, xyz: &Vector3);
247 fn length(self: &InertialPosition) -> f64;
248 fn Distance(self: &InertialPosition, other: &InertialPosition) -> f64;
249 fn InertialPosition_to_str(inertial_pos: &InertialPosition) -> String;
250 fn InertialPosition_operator_eq(lhs: &InertialPosition, rhs: &InertialPosition) -> bool;
251 fn InertialPosition_operator_sum(lhs: &InertialPosition, rhs: &InertialPosition)
252 -> UniquePtr<InertialPosition>;
253 fn InertialPosition_operator_sub(lhs: &InertialPosition, rhs: &InertialPosition)
254 -> UniquePtr<InertialPosition>;
255 fn InertialPosition_operator_mul_scalar(lhs: &InertialPosition, scalar: f64) -> UniquePtr<InertialPosition>;
256
257 type Lane;
259 fn to_left(self: &Lane) -> *const Lane;
260 fn to_right(self: &Lane) -> *const Lane;
261 fn index(self: &Lane) -> i32;
262 fn length(self: &Lane) -> f64;
263 fn Contains(self: &Lane, lane_position: &LanePosition) -> bool;
264 fn segment(self: &Lane) -> *const Segment;
265 fn GetCurvature(self: &Lane, lane_position: &LanePosition) -> Result<f64>;
266 fn Lane_id(lane: &Lane) -> String;
267 fn Lane_lane_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
268 fn Lane_segment_bounds(lane: &Lane, s: f64) -> Result<UniquePtr<RBounds>>;
269 fn Lane_elevation_bounds(lane: &Lane, s: f64, r: f64) -> Result<UniquePtr<HBounds>>;
270 fn Lane_GetOrientation(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<Rotation>>;
271 fn Lane_ToInertialPosition(lane: &Lane, lane_position: &LanePosition) -> Result<UniquePtr<InertialPosition>>;
272 fn Lane_ToLanePosition(
273 lane: &Lane,
274 inertial_position: &InertialPosition,
275 ) -> Result<UniquePtr<LanePositionResult>>;
276 fn Lane_ToSegmentPosition(
277 lane: &Lane,
278 inertial_position: &InertialPosition,
279 ) -> Result<UniquePtr<LanePositionResult>>;
280 fn Lane_GetBranchPoint(lane: &Lane, start: bool) -> *const BranchPoint;
281 fn Lane_GetConfluentBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
282 fn Lane_GetOngoingBranches(lane: &Lane, start: bool) -> Result<*const LaneEndSet>;
283 fn Lane_GetDefaultBranch(lane: &Lane, start: bool) -> UniquePtr<LaneEnd>;
284 fn Lane_EvalMotionDerivatives(
285 lane: &Lane,
286 lane_position: &LanePosition,
287 sigma_v: f64,
288 rho_v: f64,
289 eta_v: f64,
290 ) -> UniquePtr<LanePosition>;
291 type LaneType;
292 fn Lane_type(lane: &Lane) -> LaneType;
293 fn left_boundary(self: &Lane) -> Result<*const LaneBoundary>;
294 fn right_boundary(self: &Lane) -> Result<*const LaneBoundary>;
295
296 type Segment;
298 fn num_lanes(self: &Segment) -> i32;
299 fn junction(self: &Segment) -> Result<*const Junction>;
300 fn lane(self: &Segment, index: i32) -> Result<*const Lane>;
301 fn Segment_id(segment: &Segment) -> String;
302 fn num_boundaries(self: &Segment) -> i32;
303 fn boundary(self: &Segment, index: i32) -> Result<*const LaneBoundary>;
304
305 type Junction;
307 fn road_geometry(self: &Junction) -> *const RoadGeometry;
308 fn num_segments(self: &Junction) -> i32;
309 fn segment(self: &Junction, index: i32) -> Result<*const Segment>;
310 fn Junction_id(junction: &Junction) -> String;
311
312 type RoadPosition;
314 unsafe fn RoadPosition_new(lane: *const Lane, lane_pos: &LanePosition) -> UniquePtr<RoadPosition>;
318 fn RoadPosition_ToInertialPosition(road_position: &RoadPosition) -> Result<UniquePtr<InertialPosition>>;
319 fn RoadPosition_lane(road_position: &RoadPosition) -> *const Lane;
320 fn RoadPosition_pos(road_position: &RoadPosition) -> UniquePtr<LanePosition>;
321
322 type RoadPositionResult;
324 fn RoadPositionResult_road_position(result: &RoadPositionResult) -> UniquePtr<RoadPosition>;
325 fn RoadPositionResult_nearest_position(result: &RoadPositionResult) -> UniquePtr<InertialPosition>;
326 fn RoadPositionResult_distance(result: &RoadPositionResult) -> f64;
327
328 type LanePositionResult;
330 fn LanePositionResult_road_position(result: &LanePositionResult) -> UniquePtr<LanePosition>;
331 fn LanePositionResult_nearest_position(result: &LanePositionResult) -> UniquePtr<InertialPosition>;
332 fn LanePositionResult_distance(result: &LanePositionResult) -> f64;
333
334 type Rotation;
336 fn Rotation_new() -> UniquePtr<Rotation>;
337 fn Rotation_from_quat(q: &Quaternion) -> UniquePtr<Rotation>;
338 fn Rotation_from_rpy(rpy: &RollPitchYaw) -> UniquePtr<Rotation>;
339 fn roll(self: &Rotation) -> f64;
340 fn pitch(self: &Rotation) -> f64;
341 fn yaw(self: &Rotation) -> f64;
342 fn quat(self: &Rotation) -> &Quaternion;
343 fn Distance(self: &Rotation, other: &Rotation) -> f64;
344 fn Rotation_set_quat(r: Pin<&mut Rotation>, q: &Quaternion);
345 fn Rotation_rpy(r: &Rotation) -> UniquePtr<RollPitchYaw>;
346 fn Rotation_matrix(r: &Rotation) -> UniquePtr<Matrix3>;
347 fn Rotation_Apply(r: &Rotation, ip: &InertialPosition) -> UniquePtr<InertialPosition>;
348 fn Rotation_Reverse(r: &Rotation) -> UniquePtr<Rotation>;
349
350 type RBounds;
352 fn min(self: &RBounds) -> f64;
353 fn max(self: &RBounds) -> f64;
354
355 type HBounds;
357 fn min(self: &HBounds) -> f64;
358 fn max(self: &HBounds) -> f64;
359
360 type SRange;
362 fn SRange_new(s0: f64, s1: f64) -> UniquePtr<SRange>;
363 fn s0(self: &SRange) -> f64;
364 fn s1(self: &SRange) -> f64;
365 fn set_s0(self: Pin<&mut SRange>, s0: f64);
366 fn set_s1(self: Pin<&mut SRange>, s1: f64);
367 fn size(self: &SRange) -> f64;
368 fn WithS(self: &SRange) -> bool;
369 fn Intersects(self: &SRange, other: &SRange, tolerance: f64) -> bool;
370 fn Contains(self: &SRange, s_range: &SRange, tolerance: f64) -> bool;
371 fn SRange_GetIntersection(s_range: &SRange, other: &SRange, tolerance: f64) -> UniquePtr<SRange>;
372
373 type LaneSRange;
375 fn LaneSRange_new(lane_id: &String, s_range: &SRange) -> UniquePtr<LaneSRange>;
376 fn length(self: &LaneSRange) -> f64;
377 fn Intersects(self: &LaneSRange, other: &LaneSRange, tolerance: f64) -> bool;
378 fn Contains(self: &LaneSRange, lane_s_range: &LaneSRange, tolerance: f64) -> bool;
379 fn LaneSRange_lane_id(lane_s_range: &LaneSRange) -> String;
380 fn LaneSRange_s_range(lane_s_range: &LaneSRange) -> UniquePtr<SRange>;
381 fn LaneSRange_GetIntersection(
382 lane_s_range: &LaneSRange,
383 other: &LaneSRange,
384 tolerance: f64,
385 ) -> UniquePtr<LaneSRange>;
386
387 type LaneSRoute;
389 fn LaneSRoute_new(ranges: &CxxVector<ConstLaneSRangeRef>) -> UniquePtr<LaneSRoute>;
390 fn length(self: &LaneSRoute) -> f64;
391 fn Intersects(self: &LaneSRoute, other: &LaneSRoute, tolerance: f64) -> bool;
392 fn ranges(self: &LaneSRoute) -> &CxxVector<LaneSRange>;
393
394 type LaneEnd;
396 unsafe fn LaneEnd_new(lane: *const Lane, start: bool) -> UniquePtr<LaneEnd>;
402 fn LaneEnd_lane(lane_end: &LaneEnd) -> *const Lane;
403 fn LaneEnd_is_start(lane_end: &LaneEnd) -> bool;
404
405 type LaneEndSet;
407 fn size(self: &LaneEndSet) -> i32;
408 fn get(self: &LaneEndSet, index: i32) -> Result<&LaneEnd>;
409
410 type BranchPoint;
412 fn BranchPoint_id(branch_point: &BranchPoint) -> String;
413 fn road_geometry(self: &BranchPoint) -> *const RoadGeometry;
414 fn GetConfluentBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
415 fn GetOngoingBranches(self: &BranchPoint, end: &LaneEnd) -> Result<*const LaneEndSet>;
416 fn GetASide(self: &BranchPoint) -> *const LaneEndSet;
417 fn GetBSide(self: &BranchPoint) -> *const LaneEndSet;
418 fn BranchPoint_GetDefaultBranch(branch_point: &BranchPoint, end: &LaneEnd) -> UniquePtr<LaneEnd>;
419
420 type Intersection;
422 fn Intersection_id(intersection: &Intersection) -> String;
423 fn Intersection_Phase(intersection: &Intersection) -> UniquePtr<PhaseStateProviderQuery>;
424 fn region(self: &Intersection) -> &CxxVector<LaneSRange>;
425 fn Intersection_ring_id(intersection: &Intersection) -> String;
426 fn Intersection_unique_bulb_ids(intersection: &Intersection) -> UniquePtr<CxxVector<UniqueBulbId>>;
427 fn Intersection_bulb_state(intersection: &Intersection, bulb_id: &UniqueBulbId) -> UniquePtr<BulbState>;
428 fn Intersection_DiscreteValueRuleStates(
429 intersection: &Intersection,
430 ) -> UniquePtr<CxxVector<DiscreteValueRuleState>>;
431 fn Intersection_IncludesTrafficLight(intersection: &Intersection, traffic_light_id: &String) -> bool;
432 fn Intersection_IncludesDiscreteValueRule(intersection: &Intersection, rule_id: &String) -> bool;
433 fn Intersection_IncludesInertialPosition(
434 intersection: &Intersection,
435 inertial_position: &InertialPosition,
436 road_geometry: &RoadGeometry,
437 ) -> bool;
438
439 type IntersectionBook;
441 fn IntersectionBook_GetIntersection(book: &IntersectionBook, id: &String) -> MutIntersectionPtr;
442 fn IntersectionBook_GetIntersections(book: &IntersectionBook) -> UniquePtr<CxxVector<MutIntersectionPtr>>;
443 fn IntersectionBook_FindIntersectionTrafficLight(
444 book: &IntersectionBook,
445 traffic_light_id: &String,
446 ) -> MutIntersectionPtr;
447 fn IntersectionBook_FindIntersectionDiscreteValueRule(
448 book: &IntersectionBook,
449 rule_id: &String,
450 ) -> MutIntersectionPtr;
451 fn IntersectionBook_FindIntersectionInertialPosition(
452 book: &IntersectionBook,
453 inertial_position: &InertialPosition,
454 ) -> MutIntersectionPtr;
455
456 type LaneMarkingLine;
458 fn LaneMarkingLine_length(lane_marking_line: &LaneMarkingLine) -> f64;
459 fn LaneMarkingLine_space(lane_marking_line: &LaneMarkingLine) -> f64;
460 fn LaneMarkingLine_width(lane_marking_line: &LaneMarkingLine) -> f64;
461 fn LaneMarkingLine_r_offset(lane_marking_line: &LaneMarkingLine) -> f64;
462 type LaneMarkingColor;
463 fn LaneMarkingLine_color(lane_marking_line: &LaneMarkingLine) -> LaneMarkingColor;
464
465 type LaneMarking;
467 fn LaneMarking_width(lane_marking: &LaneMarking) -> f64;
468 fn LaneMarking_height(lane_marking: &LaneMarking) -> f64;
469 fn LaneMarking_material(lane_marking: &LaneMarking) -> String;
470 type LaneMarkingType;
471 fn LaneMarking_type(lane_marking: &LaneMarking) -> LaneMarkingType;
472 type LaneMarkingWeight;
473 fn LaneMarking_weight(lane_marking: &LaneMarking) -> LaneMarkingWeight;
474 fn LaneMarking_color(lane_marking: &LaneMarking) -> LaneMarkingColor;
475 type LaneChangePermission;
476 fn LaneMarking_lane_change(lane_marking: &LaneMarking) -> LaneChangePermission;
477 fn LaneMarking_lines(lane_marking: &LaneMarking) -> UniquePtr<CxxVector<LaneMarkingLine>>;
478
479 type LaneMarkingResult;
481 fn LaneMarkingResult_marking(lane_marking_result: &LaneMarkingResult) -> UniquePtr<LaneMarking>;
482 fn LaneMarkingResult_s_start(lane_marking_result: &LaneMarkingResult) -> f64;
483 fn LaneMarkingResult_s_end(lane_marking_result: &LaneMarkingResult) -> f64;
484
485 type LaneBoundary;
487 fn index(self: &LaneBoundary) -> i32;
488 fn lane_to_left(self: &LaneBoundary) -> *const Lane;
489 fn lane_to_right(self: &LaneBoundary) -> *const Lane;
490 fn segment(self: &LaneBoundary) -> *const Segment;
491 fn LaneBoundary_id(lane_boundary: &LaneBoundary) -> String;
492 fn LaneBoundary_GetMarking(lane_boundary: &LaneBoundary, s: f64) -> UniquePtr<LaneMarkingResult>;
493 fn LaneBoundary_GetMarkings(lane_boundary: &LaneBoundary) -> UniquePtr<CxxVector<LaneMarkingResult>>;
494 fn LaneBoundary_GetMarkingsByRange(
495 lane_boundary: &LaneBoundary,
496 s_start: f64,
497 s_end: f64,
498 ) -> UniquePtr<CxxVector<LaneMarkingResult>>;
499 }
500 impl UniquePtr<RoadNetwork> {}
501 impl UniquePtr<LanePosition> {}
502}