Skip to content

Commit 464ba90

Browse files
committed
footprint smaller
1 parent 839d277 commit 464ba90

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

src/common/base_classes/FOCMotor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ FOCMotor::FOCMotor()
2727
target = 0;
2828
profile_state.position = 0;
2929
profile_state.velocity = 0;
30-
profile_state.acceleration = 0;
31-
profile_state.target = 0;
3230
profile_state.initialized = false;
3331
open_loop_velocity = 0;
3432
voltage.d = 0;
@@ -606,7 +604,6 @@ void FOCMotor::updateMotionControlType(MotionControlType new_motion_controller)
606604
profile_state.initialized = false;
607605
} else if (controller == MotionControlType::angle_profile) {
608606
profile_state.velocity = 0.0f;
609-
profile_state.acceleration = 0.0f;
610607
profile_state.initialized = false;
611608
}
612609

src/common/trajectory.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ void trajectoryResetTrapezoidal(TrapezoidalProfileState& state,
1010
float target_position) {
1111
state.position = current_position;
1212
state.velocity = current_velocity;
13-
state.acceleration = 0.0f;
14-
state.target = target_position;
1513
state.initialized = true;
1614
}
1715
// Bang-bang acceleration control with trapezoidal velocity profile
@@ -36,20 +34,18 @@ TrapezoidalProfileOutput trajectoryStepTrapezoidal(TrapezoidalProfileState& stat
3634
if (!state.initialized) {
3735
trajectoryResetTrapezoidal(state, current_position, current_velocity, target_position);
3836
}
39-
state.target = target_position;
4037

4138
// Disabled acceleration limit means direct target snap.
4239
if (!_isset(acceleration_abs_limit) || acceleration_abs_limit <= 0.0f) {
43-
state.position = state.target;
40+
state.position = target_position;
4441
state.velocity = 0.0f;
45-
state.acceleration = 0.0f;
4642
out.position = state.position;
4743
out.velocity = state.velocity;
48-
out.acceleration = state.acceleration;
44+
out.acceleration = 0.0f;
4945
return out;
5046
}
5147

52-
float position_error = state.target - state.position;
48+
float position_error = target_position - state.position;
5349
float direction_to_target = _sign(position_error);
5450
float commanded_accel = 0.0f;
5551
float distance_remaining = fabsf(position_error);
@@ -63,7 +59,7 @@ TrapezoidalProfileOutput trajectoryStepTrapezoidal(TrapezoidalProfileState& stat
6359

6460
// If nearly at target and almost stopped, finalize immediately.
6561
if (distance_remaining < 1e-6f && speed_magnitude < (acceleration_abs_limit * dt)) {
66-
state.position = state.target;
62+
state.position = target_position;
6763
state.velocity = 0.0f;
6864
commanded_accel = 0.0f;
6965
} else {
@@ -92,17 +88,16 @@ TrapezoidalProfileOutput trajectoryStepTrapezoidal(TrapezoidalProfileState& stat
9288
float position_step = state.velocity * dt;
9389
if (fabsf(position_error) <= fabsf(position_step)) {
9490
// Clamp final step to avoid overshoot around the endpoint.
95-
state.position = state.target;
91+
state.position = target_position;
9692
state.velocity = 0.0f;
9793
commanded_accel = 0.0f;
9894
} else {
9995
state.position += position_step;
10096
}
10197
}
10298

103-
state.acceleration = commanded_accel;
99+
out.acceleration = commanded_accel;
104100
out.position = state.position;
105101
out.velocity = state.velocity;
106-
out.acceleration = state.acceleration;
107102
return out;
108103
}

src/common/trajectory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
struct TrapezoidalProfileState {
1010
float position = 0.0f;
1111
float velocity = 0.0f;
12-
float acceleration = 0.0f;
13-
float target = 0.0f;
12+
// float acceleration = 0.0f; // not used so commented to save memory
13+
// float target = 0.0f;
1414
bool initialized = false;
1515
};
1616

0 commit comments

Comments
 (0)