-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from pollen-robotics/develop
update
- Loading branch information
Showing
10 changed files
with
295 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[workspace] | ||
resolver = "2" | ||
|
||
members = [ | ||
"orbita2d_c_api", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
use std::time::Duration; | ||
|
||
use clap::Parser; | ||
|
||
#[macro_use] | ||
extern crate timeit; | ||
|
||
/// Benchmark the communication with an Orbita2d | ||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Args { | ||
/// Name of the person to greet | ||
#[arg(short, long)] | ||
configfile: String, | ||
|
||
/// Number of iterations | ||
#[arg(short, long, default_value = "1000")] | ||
iterations: usize, | ||
} | ||
|
||
fn controller_hwi_read_iteration( | ||
orbita2d: &mut orbita2d_controller::Orbita2dController, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
let _ = orbita2d.get_current_orientation()?; | ||
|
||
let _ = orbita2d.is_torque_on()?; | ||
|
||
let _ = orbita2d.get_raw_motors_torque_limit()?; | ||
let _ = orbita2d.get_raw_motors_velocity_limit()?; | ||
let _ = orbita2d.get_raw_motors_pid_gains()?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn controller_hwi_write_iteration( | ||
orbita2d: &mut orbita2d_controller::Orbita2dController, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
orbita2d.set_target_orientation([0.0, 0.0])?; | ||
orbita2d.enable_torque(false)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn controller_hwi_iteration( | ||
orbita2d: &mut orbita2d_controller::Orbita2dController, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
controller_hwi_read_iteration(orbita2d)?; | ||
controller_hwi_write_iteration(orbita2d)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let args = Args::parse(); | ||
|
||
println!("Benchmarking Orbita2d:"); | ||
println!("---------------------:"); | ||
println!("Results:"); | ||
|
||
println!("\tConnecting to Orbita2d: {:?}", args.configfile); | ||
let mut orbita2d = orbita2d_controller::Orbita2dController::with_config(&args.configfile)?; | ||
|
||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
let _ = orbita2d.get_current_orientation()?; | ||
})); | ||
println!( | ||
"\tReading current position: {} ms", | ||
dur.as_millis() as f64 / args.iterations as f64 | ||
); | ||
|
||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
controller_hwi_read_iteration(&mut orbita2d)?; | ||
})); | ||
println!( | ||
"\tRead hwi iteration loop: {} ms", | ||
dur.as_millis() as f64 / args.iterations as f64 | ||
); | ||
|
||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
controller_hwi_write_iteration(&mut orbita2d)?; | ||
})); | ||
println!( | ||
"\tWrite hwi iteration loop: {} ms", | ||
dur.as_millis() as f64 / args.iterations as f64 | ||
); | ||
|
||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
controller_hwi_iteration(&mut orbita2d)?; | ||
})); | ||
println!( | ||
"\tRead/Write hwi iteration loop: {} ms", | ||
dur.as_millis() as f64 / args.iterations as f64 | ||
); | ||
|
||
let kin = orbita2d_kinematics::Orbita2dKinematicsModel::new(-47.519, -47.519); | ||
|
||
let thetas = [0.20, -1.0]; | ||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
kin.compute_forward_kinematics(thetas); | ||
})); | ||
println!( | ||
"\tForward kinematics: {} µs", | ||
dur.as_micros() as f64 / args.iterations as f64 | ||
); | ||
|
||
let rot = kin.compute_forward_kinematics(thetas); | ||
let dur = Duration::from_secs_f64(timeit_loops!(args.iterations, { | ||
let _ = kin.compute_inverse_kinematics(rot); | ||
})); | ||
println!( | ||
"\tInverse kinematics: {} µs", | ||
dur.as_micros() as f64 / args.iterations as f64 | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
orbita2d_description/ros2_control/orbita2d_actuator_control.ros2_control.xacro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" ?> | ||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
<xacro:macro name="orbita2d_actuator_control" params="name"> | ||
|
||
<gpio name="${name}"> | ||
<state_interface name="torque"> | ||
<param name="initial_value">0.0</param> | ||
</state_interface> | ||
|
||
<command_interface name="torque"/> | ||
|
||
</gpio> | ||
|
||
</xacro:macro> | ||
</robot> |
18 changes: 18 additions & 0 deletions
18
orbita2d_description/ros2_control/orbita2d_axis_control.ros2_control.xacro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" ?> | ||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
<xacro:macro name="orbita2d_axis_control" params="name"> | ||
<joint name="${name}"> | ||
<state_interface name="position"> | ||
<param name="initial_value">0.0</param> | ||
</state_interface> | ||
<state_interface name="velocity"> | ||
<param name="initial_value">0.0</param> | ||
</state_interface> | ||
<state_interface name="effort"> | ||
<param name="initial_value">0.0</param> | ||
</state_interface> | ||
|
||
<command_interface name="position"/> | ||
</joint> | ||
</xacro:macro> | ||
</robot> |
24 changes: 24 additions & 0 deletions
24
orbita2d_description/ros2_control/orbita2d_raw_motor_control.ros2_control.xacro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" ?> | ||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
<xacro:macro name="orbita2d_raw_motor_control" params="name"> | ||
<gpio name="${name}"> | ||
<state_interface name="speed_limit"/> | ||
<command_interface name="speed_limit"/> | ||
|
||
<state_interface name="torque_limit"/> | ||
<command_interface name="torque_limit"/> | ||
|
||
<state_interface name="p_gain"/> | ||
<command_interface name="p_gain"/> | ||
<state_interface name="i_gain"/> | ||
<command_interface name="i_gain"/> | ||
<state_interface name="d_gain"/> | ||
<command_interface name="d_gain"/> | ||
</gpio> | ||
|
||
</xacro:macro> | ||
</robot> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.