Struct lss_driver::LSSDriver
source · [−]pub struct LSSDriver { /* private fields */ }
Expand description
Driver for the LSS servo
Implementations
sourceimpl LSSDriver
impl LSSDriver
sourcepub fn with_baud_rate(
port: &str,
baud_rate: u32
) -> Result<LSSDriver, LssDriverError>
pub fn with_baud_rate(
port: &str,
baud_rate: u32
) -> Result<LSSDriver, LssDriverError>
sourcepub fn with_driver(driver: Box<dyn FramedDriver + Send + Sync>) -> LSSDriver
pub fn with_driver(driver: Box<dyn FramedDriver + Send + Sync>) -> LSSDriver
Creates new LSS driver with a custom implementation of the transport
This is used for tests and can be used if you want to reimplement the driver over network
sourcepub async fn query_id(&mut self, id: u8) -> Result<u8, LssDriverError>
pub async fn query_id(&mut self, id: u8) -> Result<u8, LssDriverError>
sourcepub async fn configure_color(
&mut self,
id: u8,
color: LedColor
) -> Result<(), LssDriverError>
pub async fn configure_color(
&mut self,
id: u8,
color: LedColor
) -> Result<(), LssDriverError>
configure color for motor with id (value will be saved)
Arguments
id
- ID of servo you want to controlcolor
- Color to set
sourcepub async fn query_color(&mut self, id: u8) -> Result<LedColor, LssDriverError>
pub async fn query_color(&mut self, id: u8) -> Result<LedColor, LssDriverError>
sourcepub async fn move_to_position(
&mut self,
id: u8,
position: f32
) -> Result<(), LssDriverError>
pub async fn move_to_position(
&mut self,
id: u8,
position: f32
) -> Result<(), LssDriverError>
Move to absolute position in degrees
Supports virtual positions that are more than 360 degrees
Arguments
id
- ID of servo you want to controlposition
- Absolute position in degrees
Example
use lss_driver::LSSDriver;
async fn async_main(){
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_position(5, 180.0).await;
driver.move_to_position(5, 480.0).await;
}
sourcepub async fn move_to_position_with_modifier(
&mut self,
id: u8,
position: f32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
pub async fn move_to_position_with_modifier(
&mut self,
id: u8,
position: f32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
Move to absolute position in degrees with modifier
Supports virtual positions that are more than 360 degrees
Arguments
id
- ID of servo you want to controlposition
- Absolute position in degreesmodifier
- Modifier applied to this motion. Look at the type for more info.
Example
use lss_driver::LSSDriver;
use lss_driver::CommandModifier;
async fn async_main(){
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_position_with_modifier(5, 180.0, CommandModifier::Timed(2500)).await;
driver.move_to_position_with_modifier(5, 480.0, CommandModifier::Timed(2500)).await;
}
sourcepub async fn move_to_position_with_modifiers(
&mut self,
id: u8,
position: f32,
modifiers: &[CommandModifier]
) -> Result<(), LssDriverError>
pub async fn move_to_position_with_modifiers(
&mut self,
id: u8,
position: f32,
modifiers: &[CommandModifier]
) -> Result<(), LssDriverError>
Move to absolute position in degrees with multiple modifiers
Supports virtual positions that are more than 360 degrees Be careful about which modifiers are supported together
Arguments
id
- ID of servo you want to controlposition
- Absolute position in degreesmodifiers
- Array of modifiers applied to this motion. Look at the type for more info.
Example
use lss_driver::LSSDriver;
use lss_driver::CommandModifier;
async fn async_main(){
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_position_with_modifiers(5, 180.0, &[CommandModifier::Timed(2500), CommandModifier::CurrentHold(400)]).await;
}
sourcepub async fn set_target_position(
&mut self,
id: u8,
position: f32
) -> Result<(), LssDriverError>
pub async fn set_target_position(
&mut self,
id: u8,
position: f32
) -> Result<(), LssDriverError>
Move to absolute position in degrees
Same as move_to_position
Arguments
id
- ID of servo you want to controlposition
- Absolute position in degrees
Example
use lss_driver::LSSDriver;
async fn async_main(){
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.set_target_position(5, 180.0).await;
driver.set_target_position(5, 480.0).await;
}
sourcepub async fn query_position(&mut self, id: u8) -> Result<f32, LssDriverError>
pub async fn query_position(&mut self, id: u8) -> Result<f32, LssDriverError>
Query absolute current position in degrees
Supports virtual positions that are more than 360 degrees
Arguments
id
- ID of servo you want to query
sourcepub async fn query_target_position(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
pub async fn query_target_position(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
Query absolute target position in degrees
Supports virtual positions that are more than 360 degrees
Arguments
id
- ID of servo you want to query
sourcepub async fn set_rotation_speed(
&mut self,
id: u8,
speed: f32
) -> Result<(), LssDriverError>
pub async fn set_rotation_speed(
&mut self,
id: u8,
speed: f32
) -> Result<(), LssDriverError>
Set continuous rotation speed in °/s
Arguments
id
- ID of servo you want to controlspeed
- Speed in °/s
sourcepub async fn set_rotation_speed_with_modifier(
&mut self,
id: u8,
speed: f32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
pub async fn set_rotation_speed_with_modifier(
&mut self,
id: u8,
speed: f32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
Set continuous rotation speed in °/s with modifier
Arguments
id
- ID of servo you want to controlspeed
- Speed in °/smodifier
- Modifier applied to this motion. Look at the type for more info.
sourcepub async fn query_rotation_speed(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
pub async fn query_rotation_speed(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
sourcepub async fn query_status(
&mut self,
id: u8
) -> Result<MotorStatus, LssDriverError>
pub async fn query_status(
&mut self,
id: u8
) -> Result<MotorStatus, LssDriverError>
sourcepub async fn query_safety_status(
&mut self,
id: u8
) -> Result<SafeModeStatus, LssDriverError>
pub async fn query_safety_status(
&mut self,
id: u8
) -> Result<SafeModeStatus, LssDriverError>
sourcepub async fn set_motion_profile(
&mut self,
id: u8,
motion_profile: bool
) -> Result<(), LssDriverError>
pub async fn set_motion_profile(
&mut self,
id: u8,
motion_profile: bool
) -> Result<(), LssDriverError>
Set motion profile enabled or disabled. If the motion profile is enabled, angular acceleration (AA) and angular deceleration(AD) will have an effect on the motion. Also, SD/S and T modifiers can be used.
With motion profile enabled servos will follow a motion curve With motion profile disabled servos move towards target location at full speed
Arguments
id
- ID of servo you want to controlmotion_profile
- set motion profile on/off
sourcepub async fn query_motion_profile(
&mut self,
id: u8
) -> Result<bool, LssDriverError>
pub async fn query_motion_profile(
&mut self,
id: u8
) -> Result<bool, LssDriverError>
query motion profile enabled or disabled. If the motion profile is enabled, angular acceleration (AA) and angular deceleration(AD) will have an effect on the motion. Also, SD/S and T modifiers can be used.
With motion profile enabled servos will follow a motion curve With motion profile disabled servos move towards target location at full speed
Arguments
id
- ID of servo you want to query
sourcepub async fn set_filter_position_count(
&mut self,
id: u8,
filter_position_count: u8
) -> Result<(), LssDriverError>
pub async fn set_filter_position_count(
&mut self,
id: u8,
filter_position_count: u8
) -> Result<(), LssDriverError>
sourcepub async fn query_filter_position_count(
&mut self,
id: u8
) -> Result<u8, LssDriverError>
pub async fn query_filter_position_count(
&mut self,
id: u8
) -> Result<u8, LssDriverError>
sourcepub async fn set_angular_stiffness(
&mut self,
id: u8,
angular_stiffness: i32
) -> Result<(), LssDriverError>
pub async fn set_angular_stiffness(
&mut self,
id: u8,
angular_stiffness: i32
) -> Result<(), LssDriverError>
Set angular stiffness
Read more about Angular stiffness
Arguments
id
- ID of servo you want to controlangular_stiffness
- value for angular stiffness (-10 to 10) (recommended -4 to 4)
sourcepub async fn query_angular_stiffness(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_angular_stiffness(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
Query angular stiffness
Read more about Angular stiffness
Arguments
id
- ID of servo you want to query
sourcepub async fn set_angular_holding_stiffness(
&mut self,
id: u8,
angular_holding: i32
) -> Result<(), LssDriverError>
pub async fn set_angular_holding_stiffness(
&mut self,
id: u8,
angular_holding: i32
) -> Result<(), LssDriverError>
Set angular holding stiffness
Read more about Angular holding stiffness
Arguments
id
- ID of servo you want to controlangular_holding
- value for angular holding stiffness (-10 to 10)
sourcepub async fn query_angular_holding_stiffness(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_angular_holding_stiffness(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
Query angular holding stiffness
Read more about Angular holding stiffness
Arguments
id
- ID of servo you want to control
sourcepub async fn set_angular_acceleration(
&mut self,
id: u8,
angular_acceleration: i32
) -> Result<(), LssDriverError>
pub async fn set_angular_acceleration(
&mut self,
id: u8,
angular_acceleration: i32
) -> Result<(), LssDriverError>
Set angular acceleration in degrees per second squared (°/s2)
Accepts values between 1 and 100. Increments of 10 Only used when motion profile is enabled
Read more on the wiki
Arguments
id
- ID of servo you want to controlangular_acceleration
- value for angular acceleration (1 to 100, Increments 10)
sourcepub async fn query_angular_acceleration(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_angular_acceleration(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
sourcepub async fn set_angular_deceleration(
&mut self,
id: u8,
angular_deceleration: i32
) -> Result<(), LssDriverError>
pub async fn set_angular_deceleration(
&mut self,
id: u8,
angular_deceleration: i32
) -> Result<(), LssDriverError>
Set angular deceleration in degrees per second squared (°/s2)
Accepts values between 1 and 100. Increments of 10 Only used when motion profile is enabled
Read more on the wiki
Arguments
id
- ID of servo you want to controlangular_deceleration
- value for angular deceleration (1 to 100, Increments 10)
sourcepub async fn query_angular_deceleration(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_angular_deceleration(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
sourcepub async fn set_maximum_motor_duty(
&mut self,
id: u8,
maximum_motor_duty: i32
) -> Result<(), LssDriverError>
pub async fn set_maximum_motor_duty(
&mut self,
id: u8,
maximum_motor_duty: i32
) -> Result<(), LssDriverError>
sourcepub async fn query_maximum_motor_duty(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_maximum_motor_duty(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
sourcepub async fn set_maximum_speed(
&mut self,
id: u8,
maximum_speed: f32
) -> Result<(), LssDriverError>
pub async fn set_maximum_speed(
&mut self,
id: u8,
maximum_speed: f32
) -> Result<(), LssDriverError>
sourcepub async fn query_maximum_speed(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
pub async fn query_maximum_speed(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
sourcepub async fn limp(&mut self, id: u8) -> Result<(), LssDriverError>
pub async fn limp(&mut self, id: u8) -> Result<(), LssDriverError>
Disables power to motor allowing it to be back driven
Arguments
id
- ID of servo you want to control
sourcepub async fn halt_hold(&mut self, id: u8) -> Result<(), LssDriverError>
pub async fn halt_hold(&mut self, id: u8) -> Result<(), LssDriverError>
Stops any ongoing motor motion and actively holds position
Arguments
id
- ID of servo you want to control
sourcepub async fn query_voltage(&mut self, id: u8) -> Result<f32, LssDriverError>
pub async fn query_voltage(&mut self, id: u8) -> Result<f32, LssDriverError>
sourcepub async fn query_temperature(&mut self, id: u8) -> Result<f32, LssDriverError>
pub async fn query_temperature(&mut self, id: u8) -> Result<f32, LssDriverError>
sourcepub async fn query_current(&mut self, id: u8) -> Result<f32, LssDriverError>
pub async fn query_current(&mut self, id: u8) -> Result<f32, LssDriverError>
sourcepub async fn query_model(&mut self, id: u8) -> Result<Model, LssDriverError>
pub async fn query_model(&mut self, id: u8) -> Result<Model, LssDriverError>
sourcepub async fn query_firmware_version(
&mut self,
id: u8
) -> Result<String, LssDriverError>
pub async fn query_firmware_version(
&mut self,
id: u8
) -> Result<String, LssDriverError>
sourcepub async fn query_serial_number(
&mut self,
id: u8
) -> Result<String, LssDriverError>
pub async fn query_serial_number(
&mut self,
id: u8
) -> Result<String, LssDriverError>
sourcepub async fn set_led_blinking(
&mut self,
id: u8,
blinking_mode: Vec<LedBlinking>
) -> Result<(), LssDriverError>
pub async fn set_led_blinking(
&mut self,
id: u8,
blinking_mode: Vec<LedBlinking>
) -> Result<(), LssDriverError>
sourcepub async fn query_origin_offset(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
pub async fn query_origin_offset(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
sourcepub async fn query_angular_range(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
pub async fn query_angular_range(
&mut self,
id: u8
) -> Result<f32, LssDriverError>
Query the angular range in degrees
Read more on the wiki
Arguments
id
- ID of the servo you want to query
/// # Example
use lss_driver::LSSDriver;
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
let angular_range = driver.query_angular_range(5).await.unwrap();
}
sourcepub async fn set_angular_range(
&mut self,
id: u8,
range: f32
) -> Result<(), LssDriverError>
pub async fn set_angular_range(
&mut self,
id: u8,
range: f32
) -> Result<(), LssDriverError>
Set the angular range in degrees
Read more on the wiki
Arguments
id
- ID of the servo you want to controlrange
- Angular range in degrees
Example
use lss_driver::LSSDriver;
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.set_angular_range(5, 180.0).await;
}
sourcepub async fn query_pwm_position(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
pub async fn query_pwm_position(
&mut self,
id: u8
) -> Result<i32, LssDriverError>
Queries the position in µs.
When the position is inside the angular range it will return a value between 500 and 2500, when the position is outside the angular range it will return either -500 or -2500.
Read more on the wiki
Arguments
id
- ID of the servo you want to control
Example
use lss_driver::LSSDriver;
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
let pwm_position = driver.query_pwm_position(5).await.unwrap();
}
sourcepub async fn set_origin_offset(
&mut self,
id: u8,
origin_offset: f32
) -> Result<(), LssDriverError>
pub async fn set_origin_offset(
&mut self,
id: u8,
origin_offset: f32
) -> Result<(), LssDriverError>
Set origin offset in degrees
Read more on the wiki
Arguments
id
- ID of servo you want to controlorigin_offset
- Offset from factory 0 in degrees
Example
use lss_driver::LSSDriver;
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.set_origin_offset(5, -1.3).await;
}
sourcepub async fn move_to_pwm_position(
&mut self,
id: u8,
position: i32
) -> Result<(), LssDriverError>
pub async fn move_to_pwm_position(
&mut self,
id: u8,
position: i32
) -> Result<(), LssDriverError>
Move to PWM position in µs.
You can use set_angular_range to range.
Read more on the wiki
Arguments
id
- ID of the servo you want to controlposition
- Position in µs in the range [500,2500]
Example
use lss_driver::LSSDriver;
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_pwm_position(5, 2334).await;
}
sourcepub async fn move_to_pwm_position_with_modifier(
&mut self,
id: u8,
position: i32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
pub async fn move_to_pwm_position_with_modifier(
&mut self,
id: u8,
position: i32,
modifier: CommandModifier
) -> Result<(), LssDriverError>
Move to PWM position in µs with modifier.
You can use set_angular_range to range.
Read more on the wiki
Arguments
id
- ID of the servo you want to controlposition
- Position in µs in the range [500,2500]modifier
- Modifier applied to this motion. Look at the type for more info.
Example
use lss_driver::{LSSDriver, CommandModifier};
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_pwm_position_with_modifier(5, 2334, CommandModifier::Speed(750)).await;
}
sourcepub async fn move_to_pwm_position_with_modifiers(
&mut self,
id: u8,
position: i32,
modifiers: &[CommandModifier]
) -> Result<(), LssDriverError>
pub async fn move_to_pwm_position_with_modifiers(
&mut self,
id: u8,
position: i32,
modifiers: &[CommandModifier]
) -> Result<(), LssDriverError>
Move to PWM position in µs with modifiers.
You can use set_angular_range to range.
Read more on the wiki
Arguments
id
- ID of the servo you want to controlposition
- Position in µs in the range [500,2500]modifiers
- Array of modifiers applied to this motion. Look at the type for more info.
Example
use lss_driver::{LSSDriver, CommandModifier};
async fn async_main() {
let mut driver = LSSDriver::with_baud_rate("COM1", 115200).unwrap();
driver.move_to_pwm_position_with_modifiers(5, 2334, &[CommandModifier::Speed(750), CommandModifier::Timed(2500)]).await;
}
Auto Trait Implementations
impl !RefUnwindSafe for LSSDriver
impl Send for LSSDriver
impl Sync for LSSDriver
impl Unpin for LSSDriver
impl !UnwindSafe for LSSDriver
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more