Target#

#include "navground/core/target.h"
struct Path#

A generic, twice differentiable, curve (to follow), parametrized by length.

Public Types

using Point = std::tuple<Vector2, float, float>#
using Projection = std::function<ng_float_t(const Vector2&, ng_float_t, ng_float_t)>#

The projection of a curve parametrized by length.

The function finds the coordinate in [begin, end] where curve(coordinate) is nearest to the given point point:

(point, begin, end) -> coordinate

using Curve = std::function<Point(ng_float_t)>#

The parametrization of a (G2) curve by length.

The function returns position, tangential orientation and curvature at a coordinate:

(coordinate) -> (point, orientation, curvature)

Public Functions

inline Path(const Projection &projection, const Curve &curve_fn, ng_float_t length, bool loop = false)#

Constructs a new instance.

Parameters:
  • projection[in] The projection

  • curve_fn[in] The parametrized curve

  • length[in] The curve length

  • loop[in] Whether the path is an infinite loop

inline ng_float_t track(const Vector2 &position, ng_float_t look_ahead = 0)#

Returns the coordinate ahead of a position.

It projects the point to the curve using project, updates coordinate with this value. It returns the value advanced by the look-ahead distance.

Parameters:
  • position[in] The position

  • look_ahead[in] The look ahead distance

Returns:

The coordinate.

inline Point get_point(const Vector2 &position, ng_float_t look_ahead = 0)#

Returns the point the point corresponding the track coordinate.

Parameters:
  • position[in] The position

  • look_ahead[in] The look ahead distance

Returns:

The point.

Public Members

Projection project#

The projection

Curve curve#

The parametrized curve

ng_float_t coordinate#

The current coordinate during tracking. A negative value means undefined.

ng_float_t length#

The curve length

bool loop#

Whether the path is an infinite loop

struct Target#

Represents the union of all targets supported by a generic Behavior.

  • poses

  • positions

  • orientations

  • directions

  • velocities

  • twists

  • paths to be followed to reach a position

Public Functions

inline Target(const std::optional<Vector2> &position = std::nullopt, const std::optional<Radians> &orientation = std::nullopt, const std::optional<ng_float_t> &speed = std::nullopt, const std::optional<Vector2> &direction = std::nullopt, const std::optional<ng_float_t> &angular_speed = std::nullopt, const std::optional<Path> &path = std::nullopt, ng_float_t position_tolerance = 0, ng_float_t orientation_tolerance = 0)#

Constructs a new instance.

Parameters:
  • position[in] The position

  • orientation[in] The orientation

  • speed[in] The speed

  • direction[in] The direction

  • angular_speed[in] The angular speed

  • path[in] The path

  • position_tolerance[in] The position tolerance

  • orientation_tolerance[in] The orientation tolerance

inline bool valid() const#

Verify that a target is set.

Returns:

True if the target is not empty.

inline bool satisfied(Radians angle) const#

Returns whether a given orientation satisfies the target.

The target is satisfied if it does not have an angular speed and if the given value is near to the target’s orientation.

Parameters:

angle[in] The orientation

Returns:

True if the target is satisfied.

inline bool satisfied(const Vector2 &point) const#

Returns whether a given position satisfies the target.

The target is satisfied if it does not have an linear speed and if the given value is near to the target’s position.

Parameters:

point[in] The position

Returns:

True if the target is satisfied.

inline bool satisfied(const Pose2 &pose) const#

Returns whether a given pose satisfies the target.

The target is satisfied if the position and orientation are both satisfied.

Parameters:

pose[in] The pose

Returns:

True if the target is satisfied.

Public Members

std::optional<Vector2> position = std::nullopt#

The position

std::optional<Radians> orientation = std::nullopt#

The orientation

std::optional<ng_float_t> speed = std::nullopt#

The speed

std::optional<Vector2> direction = std::nullopt#

The direction

std::optional<ng_float_t> angular_speed = std::nullopt#

The angular speed

std::optional<Path> path = std::nullopt#

The path to follow.

ng_float_t position_tolerance = 0#

The position tolerance

ng_float_t orientation_tolerance = 0#

The orientation tolerance

Public Static Functions

static inline Target Point(const Vector2 &position, ng_float_t tolerance = 0, std::optional<Path> along_path = std::nullopt)#

Constructs a target to reach a point.

Parameters:
  • position[in] The target position

  • tolerance[in] The tolerance

  • along_path[in] The path to follow

Returns:

The target

static inline Target Pose(const Pose2 &pose, ng_float_t position_tolerance = 0, ng_float_t orientation_tolerance = 0, std::optional<Path> along_path = std::nullopt)#

Constructs a target to reach a pose.

Parameters:
  • pose[in] The pose

  • position_tolerance[in] The position tolerance

  • orientation_tolerance[in] The orientation tolerance

  • along_path[in] The path to follow

Returns:

The target

static inline Target Orientation(Radians orientation, Radians tolerance = 0)#

Constructs a target to reach an orietation.

Parameters:
  • orientation[in] The orientation

  • tolerance[in] The tolerance

Returns:

The target

static inline Target Velocity(const Vector2 &velocity)#

Constructs a target to follow a velocity.

Parameters:

velocity[in] The velocity

Returns:

The target

static inline Target Direction(const Vector2 &direction)#

Constructs a target to follow a direction.

Parameters:

direction[in] The direction

Returns:

The target

static inline Target Twist(const Twist2 &twist)#

Constructs a target to follow a twist.

Parameters:

twist[in] The twist

Returns:

The target

static inline Target Stop()#

Constructs a target to stop.

Returns:

The target