Skip to main content

TrapezoidalProfile

warning

The velocity units must be in (inches/seconds) and the acceleration units in (inches/seconds2) Otherwise, the code will not work as expected.

Constructor​

TrapezoidalProfile()​

Trapezoidal profile constructor. Create a new trapezoidal profile.

    TrapezoidalProfile(float max_velocity, float max_acceleration);
Parameters
max_velocityWhat would be the maximum profile velocity?.
max_accelerationWhat would be the maximum profile accleration? .

Functions​

update()​

Updates the trapezoidal profile giving the target and the sample time.

    void update(const float target, float sample_time_sec);
Parameters
targetHow many distance you would travel in inches.
sample_time_secThe update rate in secconds. .

reset()​

Resets the trapezoidal profile.

note

The function erases and clean all the profile.

    void reset();

is_ready()​

Checks if the profile its ready to use.

    bool is_ready() const;

Setters​

set_parameters()​

Sets the main parameters for the profile.

    void set_parameters(const float max_velocity, const float max_acceleration); 
Parameters
max_velocityWhat would be the maximum profile velocity?.
max_accelerationWhat would be the maximum profile accleration? .

set_max_velocity()​

Sets the maximum profile velocity.

    void set_max_velocity(const float max_velocity);
Parameters
max_velocityWhat would be the maximum profile velocity?.

set_max_acceleration()​

Sets the maximum profile acceleration.

    void set_max_acceleration(const float max_acceleration);

Parameters
max_accelerationWhat would be the maximum profile accleration? .

Getters​

get_velocity_at()​

Gets the desired velocity giving a point.

    float get_velocity_at(int index) const;

Parameters
indexIndex the profile index.

Returns: The desired velocity.


get_max_velocity()​

Gets the maximum profile velocity.

    float get_max_velocity() const;

Returns: The maximum velocity.


get_max_acceleration()​

Gets the maximum profile acceleration.

    float get_max_acceleration() const;

Returns: The maximum acceleration.


get_accel_time()​

Gets the acceleration time.

    float get_accel_time() const;

Returns: The acceleration time.


get_accel_distance()​

Gets the acceleration distance (acceleration phase).

    float get_accel_distance() const;

Returns: The acceleration time.


get_desaccel_distance()​

Gets the desacceleration distance (desacceleration phase).

    float get_desaccel_distance() const;

Returns: Gets the desacceleration time.


get_velocity_constant_distance()​

Gets the constant velocity distance (constant acceleration phase).

    float get_velocity_constant_distance() const;

Returns: Gets the constant velocity distance.


get_time_to_arrived()​

Gets the time to arrive.

    float get_time_to_arrived() const; 

Returns: The time to arrive in seconds.


get_size()​

Returns the profile size.

    std::size_t get_size() const; 

Returns: The current profile size.


get_velocities()​

Return a vector with the desired velocities using the trapezoidal profile.

    std::vector<float> get_velocities() const;

Returns: Desired velocities vector.


Operators​

std::ostream &operator <<​

Prints the desired velocities of a TrapezoidalProfile object in Integrated Terminal.

    std::ostream &operator<<(std::ostream &os,const TrapezoidalProfile &profile);