1pub mod rules;
32
33#[cxx::bridge(namespace = "maliput::api")]
34#[allow(clippy::needless_lifetimes)] #[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 unsafe extern "C++" {
54 include!("api/api.h");
55
56 #[namespace = "maliput::math"]
57 type Vector3 = crate::math::ffi::Vector3;
58 #[namespace = "maliput::math"]
59 type Quaternion = crate::math::ffi::Quaternion;
60 #[namespace = "maliput::math"]
61 type Matrix3 = crate::math::ffi::Matrix3;
62 #[namespace = "maliput::math"]
63 type RollPitchYaw = crate::math::ffi::RollPitchYaw;
64 #[namespace = "maliput::api::rules"]
65 type RoadRulebook = crate::api::rules::ffi::RoadRulebook;
66 #[namespace = "maliput::api::rules"]
67 type TrafficLightBook = crate::api::rules::ffi::TrafficLightBook;
68
69 #[namespace = "maliput::api"]
70 type RoadNetwork;
72 fn road_geometry(self: &RoadNetwork) -> *const RoadGeometry;
73 fn intersection_book(self: Pin<&mut RoadNetwork>) -> *mut IntersectionBook;
74 fn traffic_light_book(self: &RoadNetwork) -> *const TrafficLightBook;
75 fn rulebook(self: &RoadNetwork) -> *const RoadRulebook;
76
77 type RoadGeometry;
79 fn RoadGeometry_id(road_geometry: &RoadGeometry) -> String;
80 fn num_junctions(self: &RoadGeometry) -> i32;
81 fn linear_tolerance(self: &RoadGeometry) -> f64;
82 fn angular_tolerance(self: &RoadGeometry) -> f64;
83 fn num_branch_points(self: &RoadGeometry) -> i32;
84 fn RoadGeometry_ToRoadPosition(
85 rg: &RoadGeometry,
86 inertial_position: &InertialPosition,
87 ) -> UniquePtr<RoadPositionResult>;
88 fn RoadGeometry_GetLane(rg: &RoadGeometry, lane_id: &String) -> ConstLanePtr;
89 fn RoadGeometry_GetLanes(rg: &RoadGeometry) -> UniquePtr<CxxVector<ConstLanePtr>>;
90 fn RoadGeometry_GetSegment(rg: &RoadGeometry, segment_id: &String) -> *const Segment;
91 fn RoadGeometry_GetJunction(rg: &RoadGeometry, junction_id: &String) -> *const Junction;
92 fn RoadGeometry_GetBranchPoint(rg: &RoadGeometry, branch_point_id: &String) -> *const BranchPoint;
93 fn RoadGeometry_BackendCustomCommand(rg: &RoadGeometry, command: &String) -> String;
94 type LanePosition;
96 fn LanePosition_new(s: f64, r: f64, h: f64) -> UniquePtr<LanePosition>;
97 fn s(self: &LanePosition) -> f64;
98 fn r(self: &LanePosition) -> f64;
99 fn h(self: &LanePosition) -> f64;
100 fn set_s(self: Pin<&mut LanePosition>, s: f64);
101 fn set_r(self: Pin<&mut LanePosition>, r: f64);
102 fn set_h(self: Pin<&mut LanePosition>, h: f64);
103 fn srh(self: &LanePosition) -> &Vector3;
104 fn set_srh(self: Pin<&mut LanePosition>, srh: &Vector3);
105 fn LanePosition_to_str(lane_pos: &LanePosition) -> String;
106
107 type InertialPosition;
109 fn InertialPosition_new(x: f64, y: f64, z: f64) -> UniquePtr<InertialPosition>;
110 fn x(self: &InertialPosition) -> f64;
111 fn y(self: &InertialPosition) -> f64;
112 fn z(self: &InertialPosition) -> f64;
113 fn set_x(self: Pin<&mut InertialPosition>, x: f64);
114 fn set_y(self: Pin<&mut InertialPosition>, y: f64);
115 fn set_z(self: Pin<&mut InertialPosition>, z: f64);
116 fn xyz(self: &InertialPosition) -> &Vector3;
117 fn set_xyz(self: Pin<&mut InertialPosition>, xyz: &Vector3);
118 fn length(self: &InertialPosition) -> f64;
119 fn Distance(self: &InertialPosition, other: &InertialPosition) -> f64;
120 fn InertialPosition_to_str(inertial_pos: &InertialPosition) -> String;
121 fn InertialPosition_operator_eq(lhs: &InertialPosition, rhs: &InertialPosition) -> bool;
122 fn InertialPosition_operator_sum(lhs: &InertialPosition, rhs: &InertialPosition)
123 -> UniquePtr<InertialPosition>;
124 fn InertialPosition_operator_sub(lhs: &InertialPosition, rhs: &InertialPosition)
125 -> UniquePtr<InertialPosition>;
126 fn InertialPosition_operator_mul_scalar(lhs: &InertialPosition, scalar: f64) -> UniquePtr<InertialPosition>;
127
128 type Lane;
130 fn to_left(self: &Lane) -> *const Lane;
131 fn to_right(self: &Lane) -> *const Lane;
132 fn index(self: &Lane) -> i32;
133 fn length(self: &Lane) -> f64;
134 fn Contains(self: &Lane, lane_position: &LanePosition) -> bool;
135 fn segment(self: &Lane) -> *const Segment;
136 fn Lane_id(lane: &Lane) -> String;
137 fn Lane_lane_bounds(lane: &Lane, s: f64) -> UniquePtr<RBounds>;
138 fn Lane_segment_bounds(lane: &Lane, s: f64) -> UniquePtr<RBounds>;
139 fn Lane_elevation_bounds(lane: &Lane, s: f64, r: f64) -> UniquePtr<HBounds>;
140 fn Lane_GetOrientation(lane: &Lane, lane_position: &LanePosition) -> UniquePtr<Rotation>;
141 fn Lane_ToInertialPosition(lane: &Lane, lane_position: &LanePosition) -> UniquePtr<InertialPosition>;
142 fn Lane_ToLanePosition(lane: &Lane, inertial_position: &InertialPosition) -> UniquePtr<LanePositionResult>;
143 fn Lane_ToSegmentPosition(lane: &Lane, inertial_position: &InertialPosition) -> UniquePtr<LanePositionResult>;
144 fn Lane_GetBranchPoint(lane: &Lane, start: bool) -> *const BranchPoint;
145 fn Lane_GetConfluentBranches(lane: &Lane, start: bool) -> *const LaneEndSet;
146 fn Lane_GetOngoingBranches(lane: &Lane, start: bool) -> *const LaneEndSet;
147 fn Lane_GetDefaultBranch(lane: &Lane, start: bool) -> UniquePtr<LaneEnd>;
148 fn Lane_EvalMotionDerivatives(
149 lane: &Lane,
150 lane_position: &LanePosition,
151 sigma_v: f64,
152 rho_v: f64,
153 eta_v: f64,
154 ) -> UniquePtr<LanePosition>;
155
156 type Segment;
158 fn num_lanes(self: &Segment) -> i32;
159 fn junction(self: &Segment) -> *const Junction;
160 fn lane(self: &Segment, index: i32) -> *const Lane;
161 fn Segment_id(segment: &Segment) -> String;
162
163 type Junction;
165 fn road_geometry(self: &Junction) -> *const RoadGeometry;
166 fn num_segments(self: &Junction) -> i32;
167 fn segment(self: &Junction, index: i32) -> *const Segment;
168 fn Junction_id(junction: &Junction) -> String;
169
170 type RoadPosition;
172 unsafe fn RoadPosition_new(lane: *const Lane, lane_pos: &LanePosition) -> UniquePtr<RoadPosition>;
176 fn RoadPosition_ToInertialPosition(road_position: &RoadPosition) -> UniquePtr<InertialPosition>;
177 fn RoadPosition_lane(road_position: &RoadPosition) -> *const Lane;
178 fn RoadPosition_pos(road_position: &RoadPosition) -> UniquePtr<LanePosition>;
179
180 type RoadPositionResult;
182 fn RoadPositionResult_road_position(result: &RoadPositionResult) -> UniquePtr<RoadPosition>;
183 fn RoadPositionResult_nearest_position(result: &RoadPositionResult) -> UniquePtr<InertialPosition>;
184 fn RoadPositionResult_distance(result: &RoadPositionResult) -> f64;
185
186 type LanePositionResult;
188 fn LanePositionResult_road_position(result: &LanePositionResult) -> UniquePtr<LanePosition>;
189 fn LanePositionResult_nearest_position(result: &LanePositionResult) -> UniquePtr<InertialPosition>;
190 fn LanePositionResult_distance(result: &LanePositionResult) -> f64;
191
192 type Rotation;
194 fn Rotation_new() -> UniquePtr<Rotation>;
195 fn Rotation_from_quat(q: &Quaternion) -> UniquePtr<Rotation>;
196 fn Rotation_from_rpy(rpy: &RollPitchYaw) -> UniquePtr<Rotation>;
197 fn roll(self: &Rotation) -> f64;
198 fn pitch(self: &Rotation) -> f64;
199 fn yaw(self: &Rotation) -> f64;
200 fn quat(self: &Rotation) -> &Quaternion;
201 fn Distance(self: &Rotation, other: &Rotation) -> f64;
202 fn Rotation_set_quat(r: Pin<&mut Rotation>, q: &Quaternion);
203 fn Rotation_rpy(r: &Rotation) -> UniquePtr<RollPitchYaw>;
204 fn Rotation_matrix(r: &Rotation) -> UniquePtr<Matrix3>;
205 fn Rotation_Apply(r: &Rotation, ip: &InertialPosition) -> UniquePtr<InertialPosition>;
206 fn Rotation_Reverse(r: &Rotation) -> UniquePtr<Rotation>;
207
208 type RBounds;
210 fn min(self: &RBounds) -> f64;
211 fn max(self: &RBounds) -> f64;
212
213 type HBounds;
215 fn min(self: &HBounds) -> f64;
216 fn max(self: &HBounds) -> f64;
217
218 type SRange;
220 fn SRange_new(s0: f64, s1: f64) -> UniquePtr<SRange>;
221 fn s0(self: &SRange) -> f64;
222 fn s1(self: &SRange) -> f64;
223 fn set_s0(self: Pin<&mut SRange>, s0: f64);
224 fn set_s1(self: Pin<&mut SRange>, s1: f64);
225 fn size(self: &SRange) -> f64;
226 fn WithS(self: &SRange) -> bool;
227 fn Intersects(self: &SRange, other: &SRange, tolerance: f64) -> bool;
228 fn Contains(self: &SRange, s_range: &SRange, tolerance: f64) -> bool;
229 fn SRange_GetIntersection(s_range: &SRange, other: &SRange, tolerance: f64) -> UniquePtr<SRange>;
230
231 type LaneSRange;
233 fn LaneSRange_new(lane_id: &String, s_range: &SRange) -> UniquePtr<LaneSRange>;
234 fn length(self: &LaneSRange) -> f64;
235 fn Intersects(self: &LaneSRange, other: &LaneSRange, tolerance: f64) -> bool;
236 fn Contains(self: &LaneSRange, lane_s_range: &LaneSRange, tolerance: f64) -> bool;
237 fn LaneSRange_lane_id(lane_s_range: &LaneSRange) -> String;
238 fn LaneSRange_s_range(lane_s_range: &LaneSRange) -> UniquePtr<SRange>;
239 fn LaneSRange_GetIntersection(
240 lane_s_range: &LaneSRange,
241 other: &LaneSRange,
242 tolerance: f64,
243 ) -> UniquePtr<LaneSRange>;
244
245 type LaneSRoute;
247 fn LaneSRoute_new(ranges: &CxxVector<ConstLaneSRangeRef>) -> UniquePtr<LaneSRoute>;
248 fn length(self: &LaneSRoute) -> f64;
249 fn Intersects(self: &LaneSRoute, other: &LaneSRoute, tolerance: f64) -> bool;
250 fn ranges(self: &LaneSRoute) -> &CxxVector<LaneSRange>;
251
252 type LaneEnd;
254 unsafe fn LaneEnd_new(lane: *const Lane, start: bool) -> UniquePtr<LaneEnd>;
260 fn LaneEnd_lane(lane_end: &LaneEnd) -> *const Lane;
261 fn LaneEnd_is_start(lane_end: &LaneEnd) -> bool;
262
263 type LaneEndSet;
265 fn size(self: &LaneEndSet) -> i32;
266 fn get(self: &LaneEndSet, index: i32) -> &LaneEnd;
267
268 type BranchPoint;
270 fn BranchPoint_id(branch_point: &BranchPoint) -> String;
271 fn road_geometry(self: &BranchPoint) -> *const RoadGeometry;
272 fn GetConfluentBranches(self: &BranchPoint, end: &LaneEnd) -> *const LaneEndSet;
273 fn GetOngoingBranches(self: &BranchPoint, end: &LaneEnd) -> *const LaneEndSet;
274 fn GetASide(self: &BranchPoint) -> *const LaneEndSet;
275 fn GetBSide(self: &BranchPoint) -> *const LaneEndSet;
276 fn BranchPoint_GetDefaultBranch(branch_point: &BranchPoint, end: &LaneEnd) -> UniquePtr<LaneEnd>;
277
278 type Intersection;
280 fn Intersection_id(intersection: &Intersection) -> String;
281
282 type IntersectionBook;
284 fn IntersectionBook_GetIntersection(book: Pin<&mut IntersectionBook>, id: &String) -> MutIntersectionPtr;
285 fn IntersectionBook_GetIntersections(
286 book: Pin<&mut IntersectionBook>,
287 ) -> UniquePtr<CxxVector<MutIntersectionPtr>>;
288
289 }
290 impl UniquePtr<RoadNetwork> {}
291 impl UniquePtr<LanePosition> {}
292}