Skip to content

Commit

Permalink
Remove Rust debug prints and dead code (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Feb 29, 2024
1 parent 815aa76 commit debb922
Showing 1 changed file with 6 additions and 49 deletions.
55 changes: 6 additions & 49 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ use tauri::{
use trajoptlib::{
HolonomicTrajectory, InitialGuessPoint, SwerveDrivetrain, SwerveModule, SwervePathBuilder,
};
// A way to make properties that exist on all enum variants accessible from the generic variant
// I have no idea how it works but it came from
// https://users.rust-lang.org/t/generic-referencing-enum-inner-data/66342/9
// macro_rules! define_enum_macro {
// ($Type:ident, $($variant:ident),+ $(,)?) => {
// define_enum_macro!{#internal, [$], $Type, $($variant),+}
// };
// (#internal, [$dollar:tt], $Type:ident, $($variant:ident),+) => {
// macro_rules! $Type {
// ($dollar($field:ident $dollar(: $p:pat)?,)* ..) => {
// $($Type::$variant { $dollar($field $dollar(: $p)?,)* .. } )|+
// }
// }
// };
// }

#[derive(Clone, serde::Serialize, Debug)]
struct OpenFileEventPayload<'a> {
Expand Down Expand Up @@ -85,7 +70,6 @@ async fn delete_file(dir: String, name: String) {

#[tauri::command]
async fn delete_traj_segments(dir: String, traj_name: String) -> Result<(), String> {
println!("{}", traj_name);
let dir_path = Path::new(&dir);
if dir_path.is_dir() {
let traj_segment_regex =
Expand All @@ -110,7 +94,6 @@ async fn delete_traj_segments(dir: String, traj_name: String) -> Result<(), Stri
return file_str.map_or(false, |file_str| re.is_match(file_str));
});
if matches {
println!("{:?}", path);
let _ = fs::remove_file(path);
} else {
continue;
Expand All @@ -129,8 +112,7 @@ async fn delete_traj_segments(dir: String, traj_name: String) -> Result<(), Stri
#[tauri::command]
async fn delete_dir(dir: String) {
let dir_path = Path::new(&dir);
let res = fs::remove_dir_all(dir_path);
println!("{:?}", res);
let _ = fs::remove_dir_all(dir_path);
}

#[tauri::command]
Expand Down Expand Up @@ -218,8 +200,6 @@ enum Constraints {
scope: ChoreoConstraintScope,
},
}
// Also add the constraint type here
//define_enum_macro!(BoundsZeroVelocity, WptVelocityDirection, WptZeroVelocity);

#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[allow(non_snake_case)]
Expand Down Expand Up @@ -314,22 +294,12 @@ async fn generate_trajectory(
for c in 0..constraints.len() {
let constraint: &Constraints = &constraints[c];
match constraint {
Constraints::WptVelocityDirection { scope, direction } => {
// maybe make a macro or find a way to specify some constraints have a specific scope
/*
ifWaypoint((idx)=>{
println!("WptVelocityDirection {} {}", *idx, *direction);
path_builder.wpt_velocity_direction(*idx, *direction);
})
*/
match scope {
ChoreoConstraintScope::Waypoint(idx) => {
path_builder
.wpt_linear_velocity_direction(fix_scope(idx[0], &rm), *direction);
}
_ => {}
Constraints::WptVelocityDirection { scope, direction } => match scope {
ChoreoConstraintScope::Waypoint(idx) => {
path_builder.wpt_linear_velocity_direction(fix_scope(idx[0], &rm), *direction);
}
}
_ => {}
},
Constraints::WptZeroVelocity { scope } => match scope {
ChoreoConstraintScope::Waypoint(idx) => {
path_builder.wpt_linear_velocity_max_magnitude(fix_scope(idx[0], &rm), 0.0f64);
Expand Down Expand Up @@ -366,11 +336,9 @@ async fn generate_trajectory(
Constraints::StraightLine { scope } => {
match scope {
ChoreoConstraintScope::Segment(idx) => {
println!("Scope {} {}", idx[0], idx[1]);
for point in idx[0]..idx[1] {
let this_pt = fix_scope(point, &rm);
let next_pt = fix_scope(point + 1, &rm);
println!("{} {}", this_pt, next_pt);
if this_pt != fix_scope(idx[0], &rm) {
// points in between straight-line segments are automatically zero-velocity points
path_builder.wpt_linear_velocity_max_magnitude(this_pt, 0.0f64);
Expand All @@ -390,17 +358,6 @@ async fn generate_trajectory(
}
} // add more cases here to impl each constraint.
}
// The below might be helpful
// let Constraints!(scope, ..) = constraint;
// match scope {
// ChoreoConstraintScope::Full(_) =>
// println!("Full Path")
// ,
// ChoreoConstraintScope::Segment(range) =>
// println!("From {} to {}", range.start, range.end),
// ChoreoConstraintScope::Waypoint(idx) =>
// println!("At {}", idx)
// }
}
let half_wheel_base = config.wheelbase / 2.0;
let half_track_width = config.trackWidth / 2.0;
Expand Down

0 comments on commit debb922

Please sign in to comment.