Skip to content

Commit 9ff76ec

Browse files
New servo/controller API.
Full macro rework and deveice/servo cleanup.
1 parent ff654b7 commit 9ff76ec

33 files changed

+880
-932
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Package to communicate with Dynamixel motors."
88
homepage = "https://www.pollen-robotics.com"
99
repository = "https://github.com/pollen-robotics/rustypot"
1010
readme = "README.md"
11-
keywords = ["robotics", "dynamixel"]
11+
keywords = ["robotics", "dynamixel", "feetech"]
1212
categories = ["science::robotics"]
1313

1414

examples/dxl_320_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{error::Error, thread, time::Duration};
22

3-
use rustypot::device::xl320;
3+
use rustypot::servo::dynamixel::xl320;
44
use rustypot::DynamixelProtocolHandler;
55

66
fn main() -> Result<(), Box<dyn Error>> {

examples/dxl_force_fan_example.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/dxl_mx_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{error::Error, thread, time::Duration};
22

3-
use rustypot::device::mx;
3+
use rustypot::servo::dynamixel::mx;
44
use rustypot::DynamixelProtocolHandler;
55

66
fn main() -> Result<(), Box<dyn Error>> {

examples/dxl_sinus.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use std::f32::consts::PI;
22
use std::time::SystemTime;
33
use std::{error::Error, thread, time::Duration};
44

5-
use rustypot::device::mx;
5+
use rustypot::servo::dynamixel::mx::{self, conv};
66
use rustypot::DynamixelProtocolHandler;
77

88
use clap::Parser;
9-
use rustypot::device::mx::conv::radians_to_dxl_pos;
109

1110
use signal_hook::flag;
1211

@@ -75,7 +74,7 @@ fn main() -> Result<(), Box<dyn Error>> {
7574
&io,
7675
serial_port.as_mut(),
7776
id,
78-
radians_to_dxl_pos(target.into()),
77+
conv::radians_to_dxl_pos(target.into()),
7978
)?;
8079

8180
thread::sleep(Duration::from_millis(10));

examples/feetech_controller_example.rs renamed to examples/feetech_controller.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{error::Error, thread, time::Duration};
22

3-
use rustypot::device::feetech_controller::FeetechFts3215Controller;
3+
use rustypot::servo::feetech::sts3215::STS3215Controller;
44
fn main() -> Result<(), Box<dyn Error>> {
5-
let serialportname: String = "/dev/tty.usbmodem58FA0818161".to_string();
5+
let serialportname: String = "/dev/tty.usbmodem58FA0822621".to_string();
66
let baudrate: u32 = 1_000_000;
77
let ids = vec![1, 2];
88

@@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn Error>> {
1111
.open()?;
1212
println!("serial port opened");
1313

14-
let mut c = FeetechFts3215Controller::new()
14+
let mut c = STS3215Controller::new()
1515
.with_protocol_v1()
1616
.with_serial_port(serial_port);
1717

examples/feetech_example.rs renamed to examples/feetech_lowlevel_api.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::{error::Error, thread, time::Duration};
22

3-
use rustypot::{device::feetech_sts3215, DynamixelProtocolHandler};
3+
use rustypot::{servo::feetech::sts3215, DynamixelProtocolHandler};
44
fn main() -> Result<(), Box<dyn Error>> {
5-
let serialportname: String = "/dev/ttyACM0".to_string();
5+
let serialportname: String = "/dev/tty.usbmodem58FA0822621".to_string();
66
let baudrate: u32 = 1_000_000;
7-
let ids = vec![20, 21, 22, 23, 24, 10, 11, 12, 13, 14, 30, 31, 32, 33];
7+
let ids = vec![1, 2];
88

99
let mut serial_port = serialport::new(serialportname, baudrate)
1010
.timeout(Duration::from_millis(1000))
@@ -20,11 +20,11 @@ fn main() -> Result<(), Box<dyn Error>> {
2020
while start_overall.elapsed() < duration {
2121
let start_time = std::time::Instant::now();
2222

23-
// let x: i16 = feetech_STS3215::read_present_position(&io, serial_port.as_mut(), ids[0])?;
24-
let x = feetech_sts3215::sync_read_present_position(&io, serial_port.as_mut(), &ids)?;
23+
let _x: i16 = sts3215::read_present_position(&io, serial_port.as_mut(), ids[0])?;
24+
let x = sts3215::sync_read_present_position(&io, serial_port.as_mut(), &ids)?;
2525
let x: Vec<f64> = x
2626
.iter()
27-
.map(|p| feetech_sts3215::conv::dxl_pos_to_radians(*p))
27+
.map(|p| sts3215::conv::dxl_pos_to_radians(*p))
2828
.map(f64::to_degrees)
2929
.collect();
3030
println!("present pos: {:?}", x);

examples/poulpe2d.rs renamed to examples/orbita2d_poulpe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::time::SystemTime;
22
use std::{error::Error, thread, time::Duration, time::Instant};
33

4-
use rustypot::device::orbita2d_poulpe::{self, MotorValue};
4+
use rustypot::servo::orbita::orbita2d_poulpe::{self, MotorValue};
55
// use rustypot::device::orbita3d_poulpe::{self, MotorValue};
66
use rustypot::DynamixelProtocolHandler;
77

@@ -108,7 +108,7 @@ fn main() -> Result<(), Box<dyn Error>> {
108108
// },
109109
// );
110110

111-
let feedback = orbita2d_poulpe::write_target_position(
111+
let feedback = orbita2d_poulpe::write_target_position_fb(
112112
&io,
113113
serial_port.as_mut(),
114114
id,

examples/foc.rs renamed to examples/orbita3d_foc.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::f32::consts::PI;
22
use std::time::SystemTime;
33
use std::{error::Error, thread, time::Duration};
44

5-
use rustypot::device::orbita_foc::{self, DiskValue};
5+
use rustypot::servo::orbita::orbita3d_foc::{self, DiskValue};
66
use rustypot::DynamixelProtocolHandler;
77

88
fn main() -> Result<(), Box<dyn Error>> {
@@ -13,23 +13,23 @@ fn main() -> Result<(), Box<dyn Error>> {
1313
let io = DynamixelProtocolHandler::v1().with_post_delay(Duration::from_millis(1));
1414

1515
let id = 70;
16-
let mut state = orbita_foc::read_motors_drivers_states(&io, serial_port.as_mut(), id)?;
16+
let mut state = orbita3d_foc::read_motors_drivers_states(&io, serial_port.as_mut(), id)?;
1717
println!("state {:#010b}", state);
1818
println!("state {:?}", state);
1919

20-
let fw = orbita_foc::read_firmware_version(&io, serial_port.as_mut(), id)?;
20+
let fw = orbita3d_foc::read_firmware_version(&io, serial_port.as_mut(), id)?;
2121
println!("Firmware version {:?}", fw);
2222

23-
orbita_foc::write_torque_enable(&io, serial_port.as_mut(), id, 1)?;
23+
orbita3d_foc::write_torque_enable(&io, serial_port.as_mut(), id, 1)?;
2424
thread::sleep(Duration::from_millis(1000));
25-
// orbita_foc::write_torque_enable(&io, serial_port.as_mut(), id, 0)?;
25+
// orbita3d_foc::write_torque_enable(&io, serial_port.as_mut(), id, 0)?;
2626

2727
// thread::sleep(Duration::from_millis(1000));
28-
// orbita_foc::write_torque_enable(&io, serial_port.as_mut(), id, 1)?;
28+
// orbita3d_foc::write_torque_enable(&io, serial_port.as_mut(), id, 1)?;
2929

3030
// thread::sleep(Duration::from_millis(1000));
3131

32-
state = orbita_foc::read_motors_drivers_states(&io, serial_port.as_mut(), id)?;
32+
state = orbita3d_foc::read_motors_drivers_states(&io, serial_port.as_mut(), id)?;
3333
println!("state {:#010b}", state);
3434
let now = SystemTime::now();
3535
// let x = io.ping(serial_port.as_mut(), id);
@@ -40,11 +40,11 @@ fn main() -> Result<(), Box<dyn Error>> {
4040
// let x = io.ping(serial_port.as_mut(), id);
4141
// println!("{:?}", x);
4242

43-
let pos = orbita_foc::read_present_position(&io, serial_port.as_mut(), id)?;
43+
let pos = orbita3d_foc::read_present_position(&io, serial_port.as_mut(), id)?;
4444

45-
let tophall = orbita_foc::read_top_present_hall(&io, serial_port.as_mut(), id)?;
46-
let midhall = orbita_foc::read_middle_present_hall(&io, serial_port.as_mut(), id)?;
47-
let bothall = orbita_foc::read_bottom_present_hall(&io, serial_port.as_mut(), id)?;
45+
let tophall = orbita3d_foc::read_top_present_hall(&io, serial_port.as_mut(), id)?;
46+
let midhall = orbita3d_foc::read_middle_present_hall(&io, serial_port.as_mut(), id)?;
47+
let bothall = orbita3d_foc::read_bottom_present_hall(&io, serial_port.as_mut(), id)?;
4848
println!(
4949
"{:?} tophall: {:?} midhal: {:?} bothall: {:?}",
5050
pos, tophall, midhall, bothall
@@ -53,7 +53,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5353
let t = now.elapsed().unwrap().as_secs_f32();
5454
let target = 10.0_f32 * (2.0 * PI * 0.25 * t).sin();
5555

56-
orbita_foc::write_goal_position(
56+
orbita3d_foc::write_goal_position(
5757
&io,
5858
serial_port.as_mut(),
5959
id,
@@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn Error>> {
6969
thread::sleep(Duration::from_millis(10));
7070
total += 0.01;
7171
}
72-
orbita_foc::write_torque_enable(&io, serial_port.as_mut(), id, 0)?;
72+
orbita3d_foc::write_torque_enable(&io, serial_port.as_mut(), id, 0)?;
7373

7474
thread::sleep(Duration::from_millis(1000));
7575
Ok(())

examples/poulpe3d.rs renamed to examples/orbita3d_poulpe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::f32::consts::PI;
22
use std::time::SystemTime;
33
use std::{error::Error, thread, time::Duration, time::Instant};
44

5-
use rustypot::device::orbita3d_poulpe::{self, MotorValue};
5+
use rustypot::servo::orbita::orbita3d_poulpe::{self, MotorValue};
66
use rustypot::DynamixelProtocolHandler;
77

88
use clap::Parser;
@@ -129,7 +129,7 @@ fn main() -> Result<(), Box<dyn Error>> {
129129
t = now.elapsed().unwrap().as_secs_f32();
130130
let target = amplitude * 180.0_f32.to_radians() * (2.0 * PI * 0.5 * t).sin();
131131

132-
let feedback = orbita3d_poulpe::write_target_position(
132+
let feedback = orbita3d_poulpe::write_target_position_fb(
133133
&io,
134134
serial_port.as_mut(),
135135
id,

0 commit comments

Comments
 (0)