Skip to main content

Path

warning

The coordinates must to be in (inches), orientation in (degrees) and velocity units in (inches/seconds).

Otherwise, the code will not work as expected.

Constructors

Path()

Constructor that initializes a Path object with specified parameters.

note

For this constructor the B constant is setted to .75 and the tolerance a value of .001

Path(const std::vector<double> &X, const std::vector<double> &Y,bool _reverse, int _spacing);

Parameters
XA vector that includes the x coordinates of each point.
YA vector that includes the y coordinates of each point.
_reverseA boolean flag indicating if the path should be reversed. True if reversed.
_spacingThe space that would exist between each point for the injection method.

Path()

Constructor that initializes a Path object with FULL parameters.

This constructor initializes a Path object using the provided coordinates, reverse flag, and spacing value and with B and Tolerance constants.

  Path(const std::vector<double> &X, const std::vector<double> &Y,bool _reverse, int _spacing, const double B, const double Tolerance);

Parameters
XA vector that includes the x coordinates of each point.
YA vector that includes the y coordinates of each point.
_reverseA boolean flag indicating if the path should be reversed. True if reversed.
_spacingThe space that would exist between each point for the injection method.
BWeight_smooth constant, larger b means a smoother path, a value between .75 and .98 works well.
ToleranceIt is the tolerance, a value of .001 works pretty well.

Path tuning functions

inject_points()

Injects point to the current Path (using _spacing as parameter).

    void inject_points(void);


smoother

Smooths the current Path.

    void smoother(void);


upgrade()

Upgrades the path using the injecting and smoothing algorithm.

tip

Instead of using inject_points and then the smoother function you can simply use upgrade!

    void upgrade(void);


Setters

set_max_lineal_velocity()

warning

This function it is essencial. You must invoke before using the make_calcs function.

Sets the maximum velocity (inches/second) for the path.

   void set_max_lineal_velocity(double velocity);

Parameters
velocityThe max velocity in inches/second.

set_reverse()

Sets if the path is reversed.

void set_reverse(bool _is_reverse);

Parameters
_is_reverseYour path it is reversed?

Calcs functions

make_calcs()

Makes all the calculations that need to calculates the target velocities.

note

Is neccesary to set the max velocity first.

void make_calcs(const float k);

Param
kit is constant, how slow you want the robot to go around turns. (aroud 1-5)

calc_orientation()

Calculates the orientation allong the path.

note

The orientation is the angle between the points.

void calc_orientation(const float offset);
Parameters
offsetThe offset, if you want to set an orientation offset

calc_target_angular_velocities()

Calculates the target angular velocities.

warning

The functions must to be invoke after using the make_calcs function.

void calc_target_angular_velocities();

Getters

get_curvature_vector()

Gets the curvature vector.

    std::vector<double> get_curvature_vector() const;

Returns: A new vector with all the curvatures.


get_distance_vector()

Gets the distance vector.

std::vector<double> get_distance_vector() const;

Returns: A new vector with the distance between each point.


get_maximum_lineal_velocities()

Gets the maximum lineal velocities vector.

std::vector<double> get_maximum_lineal_velocities() const;

Returns: A new vector with the maximum lineal velocities in each point.


get_target_lineal_velocities()

Gets the target lineal velocities vector.

std::vector<double> get_target_lineal_velocities() const;

Returns: A new vector with the target lineal velocity in each point.


get_orientation_vector()

Gets the orientation vector.

std::vector<double> get_orientation_vector() const;

Returns: A new vector filled with the orientation target.


get_target_angular_velocities()

Gets the target angular velocities vector.

  std::vector<double> get_target_angular_velocities() const;

Returns: A new vector filled with the target angular velocities.


get_size()

Gets the path size.

int16_t get_size() const;

Returns: The Path size.


get_point_at()

Retrieves a point given an index.

This method returns the coordinates of a point at the specified index in the Path.

std::vector<double> get_point_at(const int index) const;
Parameters
indexThe index of the point to retrieve.

Returns: A vector containing the x and y coordinates of the point.


get_x_at()

Retrieves the x coordinate of a point given an index.

This method returns the x coordinate of the point at the specified index in the Path.

double get_x_at(const int index) const;
Parameters
indexThe index of the point to retrieve the x coordinate from.

Returns: The x coordinate of the point.


get_y_at()

Retrieves the y coordinate of a point given an index.

This method returns the y coordinate of the point at the specified index in the Path.

double get_y_at(const int index) const;
Parameters
indexThe index of the point to retrieve the y coordinate from.

Returns: The y coordinate of the point.


get_target_lineal_velocity_at()

Retrieves the target linear velocity at a given index.

This method returns the target linear velocity at the specified index in the Path.

double get_target_lineal_velocity_at(const int index) const;
Parameters
indexThe index of the point to retrieve the target linear velocity from.

Returns: The target linear velocity at the specified index.


get_maximum_lineal_velocity()

Gets the maximum lineal velocity of the Path.

double get_maximum_lineal_velocity() const;

Returns: The maximum velocity.


get_theta_at()

Retrieves the orientation (theta) at a given index

 double get_theta_at(const int index) const;
Parameters
indexThe Index the index of the point to retrieve the orientation(theta)

Returns: The theta at the specified index.


get_target_angular_velocity_at()

Retrieves the target angular velocity at a given index.

double get_target_angular_velocity_at(const int index) const;
Parameters
indexThe index of the point to retrieve the target angular velocity.

Returns: The theta at the specified index.


Checkers

Checks if the Path is raw.

note

When the Path is not injected or smoothed, is it considered raw.

bool is_raw() const;

is_inject()

Checks if the path was injected.

bool is_inject() const;

is_smooth()

Checks if the path it is smooth.

bool is_smooth() const;

is_ready()

Checks if the path it is ready.

note

When the Path is injected, smoothed, with the maximum velocity set, and the velocities calculated, it is considered ready.

bool is_ready() const;

is_reverse()

Checks if the path it is reversed.

bool is_reverse() const;

Operators

std::ostream &operator<<

Prints the Path coordinates in the integrated terminal.

std::ostream &operator<<(std::ostream &os, const Path &path);