pub struct GyroSensor { /* private fields */ }
Expand description
LEGO EV3 gyro sensor.
Implementations§
Source§impl GyroSensor
impl GyroSensor
Sourcepub const MODE_GYRO_ANG: &'static str = "GYRO-ANG"
pub const MODE_GYRO_ANG: &'static str = "GYRO-ANG"
Angle
Sourcepub const MODE_GYRO_RATE: &'static str = "GYRO-RATE"
pub const MODE_GYRO_RATE: &'static str = "GYRO-RATE"
Rotational Speed
Sourcepub const MODE_GYRO_FAS: &'static str = "GYRO-FAS"
pub const MODE_GYRO_FAS: &'static str = "GYRO-FAS"
Raw sensor value ???
Sourcepub const MODE_GYRO_G_AND_A: &'static str = "GYRO-G&A"
pub const MODE_GYRO_G_AND_A: &'static str = "GYRO-G&A"
Angle and Rotational Speed
Sourcepub const MODE_GYRO_CAL: &'static str = "GYRO-CAL"
pub const MODE_GYRO_CAL: &'static str = "GYRO-CAL"
Calibration ???
Sourcepub const MODE_TILT_RATE: &'static str = "TILT-RATE"
pub const MODE_TILT_RATE: &'static str = "TILT-RATE"
Rotational Speed (2nd axis)
Sourcepub const MODE_TILT_ANG: &'static str = "TILT-ANG"
pub const MODE_TILT_ANG: &'static str = "TILT-ANG"
Angle (2nd axis)
Sourcepub fn get(port: SensorPort) -> Ev3Result<Self>
pub fn get(port: SensorPort) -> Ev3Result<Self>
Try to get a Self
on the given port. Returns None
if port is not used or another device is connected.
Sourcepub fn find() -> Ev3Result<Self>
pub fn find() -> Ev3Result<Self>
Try to find a Self
. Only returns a motor if their is exactly one connected, Error::NotFound
otherwise.
Sourcepub fn set_mode_gyro_ang(&self) -> Ev3Result<()>
pub fn set_mode_gyro_ang(&self) -> Ev3Result<()>
Angle
Sourcepub fn is_mode_gyro_ang(&self) -> Ev3Result<bool>
pub fn is_mode_gyro_ang(&self) -> Ev3Result<bool>
Angle
Sourcepub fn set_mode_gyro_rate(&self) -> Ev3Result<()>
pub fn set_mode_gyro_rate(&self) -> Ev3Result<()>
Rotational Speed
Sourcepub fn is_mode_gyro_rate(&self) -> Ev3Result<bool>
pub fn is_mode_gyro_rate(&self) -> Ev3Result<bool>
Rotational Speed
Sourcepub fn set_mode_gyro_fas(&self) -> Ev3Result<()>
pub fn set_mode_gyro_fas(&self) -> Ev3Result<()>
Raw sensor value ???
Sourcepub fn is_mode_gyro_fas(&self) -> Ev3Result<bool>
pub fn is_mode_gyro_fas(&self) -> Ev3Result<bool>
Raw sensor value ???
Sourcepub fn set_mode_gyro_g_and_a(&self) -> Ev3Result<()>
pub fn set_mode_gyro_g_and_a(&self) -> Ev3Result<()>
Angle and Rotational Speed
Sourcepub fn is_mode_gyro_g_and_a(&self) -> Ev3Result<bool>
pub fn is_mode_gyro_g_and_a(&self) -> Ev3Result<bool>
Angle and Rotational Speed
Sourcepub fn set_mode_gyro_cal(&self) -> Ev3Result<()>
pub fn set_mode_gyro_cal(&self) -> Ev3Result<()>
Calibration ???
Sourcepub fn is_mode_gyro_cal(&self) -> Ev3Result<bool>
pub fn is_mode_gyro_cal(&self) -> Ev3Result<bool>
Calibration ???
Sourcepub fn set_mode_tilt_rate(&self) -> Ev3Result<()>
pub fn set_mode_tilt_rate(&self) -> Ev3Result<()>
Rotational Speed (2nd axis)
Sourcepub fn is_mode_tilt_rate(&self) -> Ev3Result<bool>
pub fn is_mode_tilt_rate(&self) -> Ev3Result<bool>
Rotational Speed (2nd axis)
Sourcepub fn set_mode_tilt_ang(&self) -> Ev3Result<()>
pub fn set_mode_tilt_ang(&self) -> Ev3Result<()>
Angle (2nd axis)
Sourcepub fn is_mode_tilt_ang(&self) -> Ev3Result<bool>
pub fn is_mode_tilt_ang(&self) -> Ev3Result<bool>
Angle (2nd axis)
Sourcepub fn get_angle(&self) -> Ev3Result<i32>
pub fn get_angle(&self) -> Ev3Result<i32>
Gets the angle, ranging from -32768 to 32767 Fails if it has been set in the wrong mode
Sourcepub fn get_rotational_speed(&self) -> Ev3Result<i32>
pub fn get_rotational_speed(&self) -> Ev3Result<i32>
Gets the rotational speed value, ranging from -440 to 440 Fails is it has been set in the wrong mode: for example, fails if we ask for rotational speed while in MODE_GYRO_ANG mode
Trait Implementations§
Source§impl Clone for GyroSensor
impl Clone for GyroSensor
Source§fn clone(&self) -> GyroSensor
fn clone(&self) -> GyroSensor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GyroSensor
impl Debug for GyroSensor
Source§impl Device for GyroSensor
impl Device for GyroSensor
Source§fn get_attribute(&self, name: &str) -> Attribute
fn get_attribute(&self, name: &str) -> Attribute
Source§fn get_address(&self) -> Ev3Result<String>
fn get_address(&self) -> Ev3Result<String>
Source§fn set_command(&self, command: &str) -> Ev3Result<()>
fn set_command(&self, command: &str) -> Ev3Result<()>
Source§fn get_commands(&self) -> Ev3Result<Vec<String>>
fn get_commands(&self) -> Ev3Result<Vec<String>>
Source§fn get_driver_name(&self) -> Ev3Result<String>
fn get_driver_name(&self) -> Ev3Result<String>
Source§impl Sensor for GyroSensor
impl Sensor for GyroSensor
Source§fn get_bin_data(&self) -> Ev3Result<String>
fn get_bin_data(&self) -> Ev3Result<String>
value<N>
attributes.
Use bin_data_format
, num_values
and the individual sensor documentation to determine how to interpret the data.Source§fn get_bin_data_format(&self) -> Ev3Result<String>
fn get_bin_data_format(&self) -> Ev3Result<String>
bin_data
for the current mode. Possible values are:Source§fn get_decimals(&self) -> Ev3Result<i32>
fn get_decimals(&self) -> Ev3Result<i32>
value<N>
attributes of the current mode.Source§fn get_fw_version(&self) -> Ev3Result<String>
fn get_fw_version(&self) -> Ev3Result<String>
Source§fn get_mode(&self) -> Ev3Result<String>
fn get_mode(&self) -> Ev3Result<String>
Source§fn set_mode(&self, mode: &str) -> Ev3Result<()>
fn set_mode(&self, mode: &str) -> Ev3Result<()>
Source§fn get_modes(&self) -> Ev3Result<Vec<String>>
fn get_modes(&self) -> Ev3Result<Vec<String>>
Source§fn get_num_values(&self) -> Ev3Result<i32>
fn get_num_values(&self) -> Ev3Result<i32>
value<N>
attributes that will return a valid value for the current mode.Source§fn get_poll_ms(&self) -> Ev3Result<i32>
fn get_poll_ms(&self) -> Ev3Result<i32>
-EOPNOTSUPP
if changing polling is not supported.
Note: Setting poll_ms too high can cause the input port auto detection to fail.
If this happens, use the mode attribute of the port to force the port to nxt-i2c mode
. Values must not be negative.Source§fn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()>
fn set_poll_ms(&self, poll_ms: i32) -> Ev3Result<()>
nxt-i2c mode
. Values must not be negative.Source§fn get_units(&self) -> Ev3Result<String>
fn get_units(&self) -> Ev3Result<String>
Source§fn get_value(&self, index: u8) -> Ev3Result<i32>
fn get_value(&self, index: u8) -> Ev3Result<i32>
value{index}
value if available.Source§fn get_value0(&self) -> Ev3Result<i32>
fn get_value0(&self) -> Ev3Result<i32>
value0
value if available.Source§fn get_value1(&self) -> Ev3Result<i32>
fn get_value1(&self) -> Ev3Result<i32>
value1
value if available.Source§fn get_value2(&self) -> Ev3Result<i32>
fn get_value2(&self) -> Ev3Result<i32>
value2
value if available.Source§fn get_value3(&self) -> Ev3Result<i32>
fn get_value3(&self) -> Ev3Result<i32>
value3
value if available.Source§fn get_value4(&self) -> Ev3Result<i32>
fn get_value4(&self) -> Ev3Result<i32>
value4
value if available.Source§fn get_value5(&self) -> Ev3Result<i32>
fn get_value5(&self) -> Ev3Result<i32>
value5
value if available.Source§fn get_value6(&self) -> Ev3Result<i32>
fn get_value6(&self) -> Ev3Result<i32>
value6
value if available.Source§fn get_value7(&self) -> Ev3Result<i32>
fn get_value7(&self) -> Ev3Result<i32>
value7
value if available.Source§fn get_text_value(&self) -> Ev3Result<String>
fn get_text_value(&self) -> Ev3Result<String>
-EOPNOTSUPP
if a sensor does not support text values.Auto Trait Implementations§
impl !Freeze for GyroSensor
impl !RefUnwindSafe for GyroSensor
impl Send for GyroSensor
impl !Sync for GyroSensor
impl Unpin for GyroSensor
impl UnwindSafe for GyroSensor
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
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>
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>
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 more