Changeset 205 in flair-src


Ignore:
Timestamp:
Dec 5, 2017, 2:20:54 PM (4 years ago)
Author:
Sanahuja Guillaume
Message:

TrajectoryGenerator1D::GetPercentageOfCompletion?

Location:
trunk/lib/FlairFilter/src
Files:
4 edited

Legend:

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

    r177 r205  
    8989}
    9090
     91float TrajectoryGenerator1D::GetPercentageOfCompletion(void) const {
     92  return pimpl_->GetPercentageOfCompletion();
     93}
     94
    9195} // end namespace filter
    9296} // end namespace flair
  • trunk/lib/FlairFilter/src/TrajectoryGenerator1D.h

    r177 r205  
    127127  * \brief Position
    128128  *
     129  * \return the actual position
    129130  */
    130131  float Position(void) const;
     
    133134  * \brief Speed
    134135  *
     136  * \return the actual speed
    135137  */
    136138  float Speed(void) const;
     139 
     140  /*!
     141  * \brief Get percentage of completion
     142  *
     143  * Value is between 0 and 100.
     144  *
     145  * \return the percentage of completion (in position)
     146  */
     147  float GetPercentageOfCompletion(void) const;
    137148
    138149  /*!
  • 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  }
  • trunk/lib/FlairFilter/src/unexported/TrajectoryGenerator1D_impl.h

    r177 r205  
    3838  void StopTraj(void);
    3939  void Reset(void);
     40  float GetPercentageOfCompletion(void) const;
    4041  flair::core::cvmatrix *output;
    4142  float pos_off, vel_off;
     
    4344
    4445private:
    45   float end_position;
     46  float start_pos,end_pos;
    4647  float pos, v, acc;
    4748  flair::core::Time previous_time;
Note: See TracChangeset for help on using the changeset viewer.