|
|
|
|
186
|
|
186
|
|
187
|
long acceleration = block->acceleration_st;
|
187
|
long acceleration = block->acceleration_st;
|
188
|
int32_t accelerate_steps =
|
188
|
int32_t accelerate_steps =
|
189
|
- ceil(estimate_acceleration_distance(block->initial_rate, block->nominal_rate, acceleration));
|
|
|
|
|
189
|
+ ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration));
|
190
|
int32_t decelerate_steps =
|
190
|
int32_t decelerate_steps =
|
191
|
- floor(estimate_acceleration_distance(block->nominal_rate, block->final_rate, -acceleration));
|
|
|
|
|
191
|
+ floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -acceleration));
|
192
|
|
192
|
|
193
|
// Calculate the size of Plateau of Nominal Rate.
|
193
|
// Calculate the size of Plateau of Nominal Rate.
|
194
|
int32_t plateau_steps = block->step_event_count-accelerate_steps-decelerate_steps;
|
194
|
int32_t plateau_steps = block->step_event_count-accelerate_steps-decelerate_steps;
|
|
|
|
|
197
|
// have to use intersection_distance() to calculate when to abort acceleration and start braking
|
197
|
// have to use intersection_distance() to calculate when to abort acceleration and start braking
|
198
|
// in order to reach the final_rate exactly at the end of this block.
|
198
|
// in order to reach the final_rate exactly at the end of this block.
|
199
|
if (plateau_steps < 0) {
|
199
|
if (plateau_steps < 0) {
|
200
|
- accelerate_steps = ceil(intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
|
|
|
|
|
200
|
+ accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count));
|
201
|
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off
|
201
|
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off
|
202
|
accelerate_steps = min((uint32_t)accelerate_steps,block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero)
|
202
|
accelerate_steps = min((uint32_t)accelerate_steps,block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero)
|
203
|
plateau_steps = 0;
|
203
|
plateau_steps = 0;
|