Ignore:
Timestamp:
12/05/17 14:20:54 (5 years ago)
Author:
Sanahuja Guillaume
Message:

TrajectoryGenerator1D::GetPercentageOfCompletion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairFilter/src/TrajectoryGenerator1D_impl.cpp

    r177 r205  
    8585
    8686  // configure trajectory
    87   end_position = end_pos;
     87  this->start_pos = start_pos;
     88  this->end_pos = end_pos;
    8889  pos = start_pos;
    8990  acc = acceleration->Value();
     
    9596      v = -max_veloctity->Value();
    9697  }
    97   if (end_position < start_pos) {
     98  if (end_pos < start_pos) {
    9899    acc = -acc;
    99100    // max_veloctity=-max_veloctity;
     
    106107  v = 0;
    107108  // output->SetValue(1,0,v);
     109}
     110
     111float TrajectoryGenerator1D_impl::GetPercentageOfCompletion(void) const {
     112  if(!is_started) {
     113    return 0;
     114  } else {
     115    return (pos-start_pos)/(end_pos-start_pos)*100;
     116  }
    108117}
    109118
     
    140149      }
    141150      pos += v * delta_t;
    142       if (end_position - v * v / (2 * acc) <= pos && v >= 0)
     151      if (end_pos - v * v / (2 * acc) <= pos && v >= 0)
    143152        acc = -acc;
    144       if (end_position - v * v / (2 * acc) >= pos && v < 0)
     153      if (end_pos - v * v / (2 * acc) >= pos && v < 0)
    145154        acc = -acc;
    146       if (pos >= end_position && v >= 0)
     155      if (pos >= end_pos && v >= 0)
    147156        is_finished = true;
    148       if (pos <= end_position && v < 0)
     157      if (pos <= end_pos && v < 0)
    149158        is_finished = true;
    150159    }
     
    152161    if (is_finished == true) {
    153162      v = 0;
    154       pos = end_position;
     163      pos = end_pos;
    155164    }
    156165  }
Note: See TracChangeset for help on using the changeset viewer.