claraty::Trajectory Class Reference
[Algorithms]
#include <trajectory.h>
Inheritance diagram for claraty::Trajectory:


Initialization Functionss | |
| bool | _started |
| bool | _compute_position |
| bool | _compute_velocity |
| bool | _compute_accel |
| Timer | _timer |
| double | _final_position |
| double | _max_velocity |
| double | _accel |
| double | _decel |
| bool | is_started () const |
| void | start () |
| void | stop () |
| void | reset () |
| void | advance_timer_by (double delta_time) |
| virtual void | _compute_profile (double final_position, double max_velocity, double accel, double decel, double init_position=0, double init_velocity=0, double final_velocity=0)=0 |
| virtual void | _compute_setpoint (double time, double &position, double &velocity, double &accel)=0 |
Public Member Functions | |
| Trajectory () | |
| virtual | ~Trajectory () |
| virtual void | set (double final_position, double max_velocity, double accel) |
| virtual void | set (double final_position, double max_velocity, double accel, double decel) |
| virtual void | set (Vector< double > &final_position, Vector< double > &max_velocity, Vector< double > &accel) |
| virtual void | set (Vector< double > &final_position, double max_velocity, double accel) |
Retrieving Setpoints | |
| double | get_position () |
| double | get_position (double time) |
| double | get_velocity () |
| double | get_velocity (double time) |
| double | get_acceleration () |
| double | get_acceleration (double time) |
| void | get_setpoint (double &position, double &velocity, double &accel) |
| void | get_setpoint (double time, double &position, double &velocity, double &accel) |
Detailed Description
Base class which is pure virtual and defines the API for different types of trajectories. Such trajectories include: trapezoidal (and their triangular degenerate case), multi-segement trapezoidals, S-curve trajectories, and so on.
Definition at line 50 of file trajectory.h.
Constructor & Destructor Documentation
| claraty::Trajectory::Trajectory | ( | ) | [inline] |
Definition at line 54 of file trajectory.h.
00054 : _started(false), 00055 _compute_position(false), 00056 _compute_velocity(false), 00057 _compute_accel(false) {}
| virtual claraty::Trajectory::~Trajectory | ( | ) | [inline, virtual] |
Member Function Documentation
| void claraty::Trajectory::set | ( | double | final_position, | |
| double | max_velocity, | |||
| double | accel | |||
| ) | [inline, virtual] |
Various methods to input the trajectory parameters. Note that beyond the setpoint(s) velocity, and acceleration are optional
Definition at line 153 of file trajectory.h.
Referenced by set().
00154 { 00155 set(final_position, max_velocity, accel, accel); 00156 }
| void claraty::Trajectory::set | ( | double | final_position, | |
| double | max_velocity, | |||
| double | accel, | |||
| double | decel | |||
| ) | [inline, virtual] |
-------------------------------------------------------------------------- This function calls the trajectory compute profile using different values for acceleration and deceleration. Currently the specification of a different deceleration capability is not exported.
Definition at line 165 of file trajectory.h.
References _accel, _decel, _final_position, and _max_velocity.
00167 { 00168 // Since this trajectory can be updated during a motion, the 00169 // inital_velocity is computed first to correctly merge the two profiles 00170 00171 _final_position = final_position; // input: signed value 00172 _max_velocity = max_velocity; // input: magnitude value 00173 _accel = fabs(accel); // input: magnitude value 00174 _decel = fabs(decel); // input: magnitude value 00175 }
| void claraty::Trajectory::set | ( | Vector< double > & | positions, | |
| double | velocity, | |||
| double | acceleration | |||
| ) | [inline, virtual] |
------------------------------------------------------------------------- This function sets a multi-waypoint trajectory using the same velocity and acceleration for all the segments of the trajectory
- Parameters:
-
[in] positions A vector of positions relative to the start of the trajectory. [in] velocity The magnitude of the velocity used for each segment of the trajectory. This is an absolute value. [in] acceleration The magnitude of the acceleration used for each segment of the trajectory. This is an absolute value. [out] positions The position at the current time relative to the beginning of the trajectory.
Definition at line 192 of file trajectory.h.
References claraty::Vector< T >::get_size(), and set().
00193 { 00194 int size = positions.get_size(); 00195 00196 Vector<double> v(size), a(size); 00197 v = velocity; 00198 a = acceleration; 00199 00200 return set(positions, v, a); 00201 }
Here is the call graph for this function:

| double claraty::Trajectory::get_position | ( | ) | [inline] |
Various methods to get setpoint information from the trajectory functions. One can get position, velocity, acceleration, or all the above. Trajectory information can be retrieved for the current time (when no time is specified in the function arguments or it can be queried for any future time
Definition at line 210 of file trajectory.h.
References _timer, and claraty::Timer::get_time_elapsed().
00211 { 00212 return get_position(_timer.get_time_elapsed()); 00213 }
Here is the call graph for this function:

| double claraty::Trajectory::get_position | ( | double | time | ) | [inline] |
------------------------------------------------------------------------- This function can be used to predict the position value at current or any time in the future.
- Parameters:
-
time the time at which you want to get the corresponding position value relative to the beginning of the trajectory
- Returns:
- position the position at the given time
Definition at line 223 of file trajectory.h.
References _compute_accel, _compute_position, _compute_setpoint(), and _compute_velocity.
00224 { 00225 _compute_position = true; 00226 _compute_velocity = false; 00227 _compute_accel = false; 00228 double p, v, a; 00229 00230 _compute_setpoint(time, p, v, a); 00231 return p; 00232 }
Here is the call graph for this function:

| double claraty::Trajectory::get_velocity | ( | ) | [inline] |
------------------------------------------------------------------------- This function returns the velocity of the trajectory at the current time. This current time is measured relative to the beginning of the trajectory
- Returns:
- velocity the signed velocity at the current time relative to the beginning of the trajectory
Definition at line 243 of file trajectory.h.
References _timer, and claraty::Timer::get_time_elapsed().
00244 { 00245 return get_velocity(_timer.get_time_elapsed()); 00246 }
Here is the call graph for this function:

| double claraty::Trajectory::get_velocity | ( | double | time | ) | [inline] |
------------------------------------------------------------------------- This function is used to predict the velocity of the trajectory at the any given instance of time
- Parameters:
-
time the time at which you want to get the corresponding velocity value relative to the beginning of the trajectory
- Returns:
- velocity the signed velocity at the given time.
Definition at line 256 of file trajectory.h.
References _compute_accel, _compute_position, _compute_setpoint(), and _compute_velocity.
00257 { 00258 _compute_position = false; 00259 _compute_velocity = true; 00260 _compute_accel = false; 00261 double p, v, a; 00262 00263 _compute_setpoint(time, p, v, a); 00264 return v; 00265 }
Here is the call graph for this function:

| double claraty::Trajectory::get_acceleration | ( | ) | [inline] |
------------------------------------------------------------------------- This function returns the acceleration of the trajectory at the current time. This current time is measured relative to the beginning of the trajectory
- Returns:
- acceleraiton the acceleration at the current time relative to the beginning of the trajectory
Definition at line 276 of file trajectory.h.
References _timer, and claraty::Timer::get_time_elapsed().
00277 { 00278 return get_acceleration(_timer.get_time_elapsed()); 00279 }
Here is the call graph for this function:

| double claraty::Trajectory::get_acceleration | ( | double | time | ) | [inline] |
------------------------------------------------------------------------- This function is used to predict the acceleration of the trajectory at the any given instance of time
- Parameters:
-
time the time at which you want to get the corresponding velocity value relative to the beginning of the trajectory
- Returns:
- acceleration the signed acceleration at the given time.
Definition at line 289 of file trajectory.h.
References _compute_accel, _compute_position, _compute_setpoint(), and _compute_velocity.
00290 { 00291 _compute_position = false; 00292 _compute_velocity = false; 00293 _compute_accel = true; 00294 double p, v, a; 00295 00296 _compute_setpoint(time, p, v, a); 00297 return a; 00298 }
Here is the call graph for this function:

| void claraty::Trajectory::get_setpoint | ( | double & | position, | |
| double & | velocity, | |||
| double & | accel | |||
| ) | [inline] |
------------------------------------------------------------------------- This function returns the trajectory parameters at the current instant of time specified through the timer.
- Returns:
- position relative to the beginning of the trajectory for the current time
Definition at line 307 of file trajectory.h.
References _timer, and claraty::Timer::get_time_elapsed().
Referenced by start(), and stop().
00309 { 00310 return get_setpoint(_timer.get_time_elapsed(), position, velocity, accel); 00311 }
Here is the call graph for this function:

| void claraty::Trajectory::get_setpoint | ( | double | time, | |
| double & | position, | |||
| double & | velocity, | |||
| double & | accel | |||
| ) | [inline] |
------------------------------------------------------------------------- This function returns all the trajectory parameters (position, velocity, acceleration/deceleration for any given instance of time
- Parameters:
-
[in] time The time in seconds relative to the beginning of the trajectory for which at which you want to get the corresponding trajectory values. [out] position The position relative to the beginning of the trajectory. [out] velocity The absolute value of the velocity. [out] accel The value of the acceleration or deceleration that at the given point
Definition at line 330 of file trajectory.h.
References _compute_accel, _compute_position, _compute_setpoint(), and _compute_velocity.
00332 { 00333 _compute_position = true; 00334 _compute_velocity = true; 00335 _compute_accel = true; 00336 00337 _compute_setpoint(time, position, velocity, accel); 00338 return; 00339 }
Here is the call graph for this function:

| bool claraty::Trajectory::is_started | ( | ) | const [inline] |
Various methods start, stop and check whether a given trajectory is labeled as started (or active).
Definition at line 111 of file trajectory.h.
References _started.
Referenced by claraty::operator<<().
00111 {return _started;} // Check is trajectory is started
| void claraty::Trajectory::start | ( | ) | [inline] |
------------------------------------------------------------------------- The trajectory will start its timer only when the start command is issued. If a set command is issued while the trajectory is active, then a second start command needs to be issued for the new trajectory to override/cascade the existing trajectory
Definition at line 348 of file trajectory.h.
References _accel, _compute_profile(), _decel, _final_position, _max_velocity, _started, _timer, get_setpoint(), and claraty::Timer::reset().
00349 { 00350 if (_started) { 00351 // p_0 - initial condition: signed value 00352 // v_0 - initial condition: signed value 00353 double p_0, v_0, a_0; 00354 get_setpoint(p_0, v_0, a_0); 00355 _compute_profile(_final_position, _max_velocity, _accel, _decel, p_0, v_0); 00356 } 00357 else { 00358 // Issuing a start when the trajectory is stopped 00359 _compute_profile(_final_position, _max_velocity, _accel, _decel); 00360 } 00361 _started = true; 00362 _timer.reset(); 00363 }
Here is the call graph for this function:

| void claraty::Trajectory::stop | ( | ) | [inline] |
------------------------------------------------------------------------- This function compute a profile that will cause the trajectory to take the current velocity (v_0) and move it to 0 using the deceleration specified in the profile
Definition at line 371 of file trajectory.h.
References _accel, _compute_profile(), _decel, _started, _timer, get_setpoint(), and claraty::Timer::reset().
00372 { 00373 if (_started) { 00374 // p - initial condition: signed value 00375 // v - initial condition: signed value 00376 double p, v, a; 00377 get_setpoint(p, v, a); 00378 // To generate a deceleration profile, make the final_position be the same 00379 // as the initial_position. This will force the profile compute function 00380 // to decelerate the current trajectory to zero 00381 _compute_profile(p, v, _accel, _decel, p, v, 0.0); 00382 _started = true; 00383 } 00384 else { 00385 _started = false; 00386 } 00387 _timer.reset(); 00388 }
Here is the call graph for this function:

| void claraty::Trajectory::reset | ( | ) | [inline] |
------------------------------------------------------------------------- This function resets the timer and the _started flag
Definition at line 393 of file trajectory.h.
References _started, _timer, and claraty::Timer::reset().
Here is the call graph for this function:

| void claraty::Trajectory::advance_timer_by | ( | double | delta_time | ) | [inline] |
For testing purposes only - this will enable the generation of trajectories much faster
Definition at line 117 of file trajectory.h.
References _timer, and claraty::Timer::advance_time_by().
00117 {_timer.advance_time_by(delta_time);}
Here is the call graph for this function:

| virtual void claraty::Trajectory::_compute_profile | ( | double | final_position, | |
| double | max_velocity, | |||
| double | accel, | |||
| double | decel, | |||
| double | init_position = 0, |
|||
| double | init_velocity = 0, |
|||
| double | final_velocity = 0 | |||
| ) | [protected, pure virtual] |
Implemented in claraty::Trapezoidal_Trajectory, and claraty::Multi_Segment_Trajectory.
| virtual void claraty::Trajectory::_compute_setpoint | ( | double | time, | |
| double & | position, | |||
| double & | velocity, | |||
| double & | accel | |||
| ) | [protected, pure virtual] |
Implemented in claraty::Trapezoidal_Trajectory, and claraty::Multi_Segment_Trajectory.
Referenced by get_acceleration(), get_position(), get_setpoint(), and get_velocity().
Member Data Documentation
bool claraty::Trajectory::_started [protected] |
Definition at line 121 of file trajectory.h.
Referenced by claraty::Trapezoidal_Trajectory::_compute_setpoint(), claraty::Multi_Segment_Trajectory::_compute_setpoint(), is_started(), reset(), start(), and stop().
bool claraty::Trajectory::_compute_position [protected] |
Definition at line 122 of file trajectory.h.
Referenced by claraty::Trapezoidal_Trajectory::_compute_setpoint(), get_acceleration(), get_position(), get_setpoint(), and get_velocity().
bool claraty::Trajectory::_compute_velocity [protected] |
Definition at line 122 of file trajectory.h.
Referenced by claraty::Trapezoidal_Trajectory::_compute_setpoint(), get_acceleration(), get_position(), get_setpoint(), and get_velocity().
bool claraty::Trajectory::_compute_accel [protected] |
Definition at line 122 of file trajectory.h.
Referenced by claraty::Trapezoidal_Trajectory::_compute_setpoint(), get_acceleration(), get_position(), get_setpoint(), and get_velocity().
Timer claraty::Trajectory::_timer [private] |
Definition at line 140 of file trajectory.h.
Referenced by advance_timer_by(), get_acceleration(), get_position(), get_setpoint(), get_velocity(), reset(), start(), and stop().
double claraty::Trajectory::_final_position [private] |
double claraty::Trajectory::_max_velocity [private] |
double claraty::Trajectory::_accel [private] |
double claraty::Trajectory::_decel [private] |
The documentation for this class was generated from the following file: