pub struct ImuMeasurement { /* private fields */ }Expand description
IMU (Inertial Measurement Unit) sensor measurement data.
This type represents data from an IMU sensor, including accelerometer (linear acceleration), gyroscope (angular velocity), and compass (orientation) readings. IMU sensors are useful for vehicle dynamics analysis and state estimation.
Corresponds to [carla.IMUMeasurement] in the Python API.
§Examples
use carla::{
client::{ActorBase, Client},
sensor::data::ImuMeasurement,
};
let client = Client::default();
let mut world = client.world();
sensor.listen(|sensor_data| {
if let Ok(imu_data) = ImuMeasurement::try_from(sensor_data) {
let accel = imu_data.accelerometer();
let gyro = imu_data.gyroscope();
let heading = imu_data.compass();
println!(
"Acceleration: ({:.2}, {:.2}, {:.2}) m/s²",
accel.x, accel.y, accel.z
);
println!(
"Angular velocity: ({:.2}, {:.2}, {:.2}) rad/s",
gyro.x, gyro.y, gyro.z
);
println!("Compass heading: {:.2}°", heading);
}
});Implementations§
Source§impl ImuMeasurement
impl ImuMeasurement
Sourcepub fn accelerometer(&self) -> Vector3D
pub fn accelerometer(&self) -> Vector3D
Returns the accelerometer reading (linear acceleration) in m/s².
The vector components represent acceleration in the sensor’s local coordinate system:
- x: forward/backward
- y: left/right
- z: up/down
Sourcepub fn compass(&self) -> f32
pub fn compass(&self) -> f32
Returns the compass heading in radians.
The compass value represents the orientation relative to north (0 radians).
Sourcepub fn gyroscope(&self) -> Vector3D
pub fn gyroscope(&self) -> Vector3D
Returns the gyroscope reading (angular velocity) in rad/s.
The vector components represent rotation rates around the sensor’s local axes:
- x: roll rate (rotation around forward axis)
- y: pitch rate (rotation around lateral axis)
- z: yaw rate (rotation around vertical axis)
Trait Implementations§
Source§impl Clone for ImuMeasurement
impl Clone for ImuMeasurement
Source§fn clone(&self) -> ImuMeasurement
fn clone(&self) -> ImuMeasurement
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ImuMeasurement
impl Debug for ImuMeasurement
Source§impl TryFrom<SensorData> for ImuMeasurement
impl TryFrom<SensorData> for ImuMeasurement
Source§type Error = SensorData
type Error = SensorData
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl !RefUnwindSafe for ImuMeasurement
impl Freeze for ImuMeasurement
impl Send for ImuMeasurement
impl Sync for ImuMeasurement
impl Unpin for ImuMeasurement
impl UnsafeUnpin for ImuMeasurement
impl UnwindSafe for ImuMeasurement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.