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