| Crates.io | servo-libs-simulator |
| lib.rs | servo-libs-simulator |
| version | 0.1.3 |
| created_at | 2025-10-03 11:09:24.128471+00 |
| updated_at | 2025-10-04 02:25:03.721354+00 |
| description | Servo motor simulation crate with channel management |
| homepage | |
| repository | https://github.com/kchhero/suker_rust_project/tree/master/servo-libs-simulator |
| max_upload_size | |
| id | 1866534 |
| size | 120,381 |
A simple Rust crate for simulating and managing servo motors.
Supports angle <-> pulse width conversion, channel management, and serialization.
use servo_sim::{ServoSystem, ServoChannel, ServoSpec};
fn main() {
let mut system = ServoSystem::new();
system.add_channel(ServoChannel::new(0, "base", ServoSpec::mg996r()));
system.add_channel(ServoChannel::new(1, "shoulder", ServoSpec::mg996r()));
// Set angle
if let Some(servo) = system.get_channel_mut(0) {
servo.set_angle(90.0);
println!("Base angle = {}, pulse = {}", servo.angle, servo.get_pulse());
}
// Set pulse
if let Some(servo) = system.get_channel_mut(1) {
servo.set_pulse(350);
println!("Shoulder pulse=350 -> angle = {}", servo.angle);
}
}
git clone https://github.com/kchhero/suker_rust_project.git
cd suker_rust_project/servo-libs-simulator
cargo build
cargo run --example basic