Waypoints#

#include "navground/sim/tasks/waypoints.h"
using navground::sim::Waypoints = std::vector<core::Vector2>#

A sequence of points to reach.

struct WaypointsTask : public navground::sim::Task#

This class implement a task that makes the agent reach a sequence of waypoints, calling navground::core::Controller::go_to_position for the next waypoint after the current has been reached within a tolerance.

The task notifies when a new waypoint is set by calling a callback.

Registered properties:

Subclassed by navground::sim::GoToPoseTask

Public Functions

inline explicit WaypointsTask(const Waypoints &waypoints = {}, bool loop = default_loop, ng_float_t tolerance = default_tolerance, bool random = default_random, const std::vector<ng_float_t> &tolerances = std::vector<ng_float_t>{}, const std::vector<ng_float_t> &orientations = {}, ng_float_t angular_tolerance = default_angular_tolerance, const std::vector<ng_float_t> &angular_tolerances = std::vector<ng_float_t>{})#

Constructs a new instance.

Parameters:
  • waypoints[in] The waypoints

  • loop[in] Whether it should start from begin after reaching the last waypoint

  • tolerance[in] The default goal tolerance applied to each waypoint.

  • random[in] Whether to pick the next waypoint randomly

  • tolerances[in] The goal tolerance applied to individual waypoints.

  • orientations[in] The goal orientation at the waypoints.

  • angular_tolerance[in] The default goal angular tolerance applied to each waypoint.

  • angular_tolerance[in] The goal angular tolerance applied to individual waypoints.

inline virtual size_t get_log_size() const override#

The size of the data passed to callbacks when events occur, see TaskCallback and Task::add_callback.

The data is composed of 4 numbers: [time, target_x, target_y, target_theta]

Returns:

4

inline void set_waypoints(const Waypoints &value)#

Sets the waypoints.

Parameters:

value[in] The desired waypoints

inline void set_orientations(const std::vector<ng_float_t> &values)#

Sets the goal orientations at the waypoints.

Parameters:

value[in] The desired orientations (in radians)

inline void set_loop(bool value)#

Sets whether it should start from begin after reaching the last waypoint.

Parameters:

value[in] The desired value

inline Waypoints get_waypoints() const#

Gets the waypoints.

Returns:

The waypoints.

inline const std::vector<ng_float_t> &get_orientations() const#

Gets the goal orientations at the waypoints.

Returns:

The orientations (in radians).

inline bool get_loop() const#

Gets whether it should start from begin after reaching the last waypoint.

Returns:

True if it should loop.

inline bool get_random() const#

Gets whether to pick the next waypoint randomly.

Returns:

True if it should pick randomly.

inline void set_random(bool value)#

Sets whether to pick the next waypoint randomly.

Parameters:

value[in] The desired value

inline ng_float_t get_effective_tolerance(unsigned index) const#

Returns the spatial tolerance applied to the waypoint at a given index.

If a specific positive value is present at the same index in get_tolerances, it returns it. Else it returns the default value from get_tolerance.

For example, if there are three waypoints, the specific tolerances are set to -1, 0.2, and the default tolerance is set to 0.25, the effective tolerances will be 0.25, 0.2, 0.25.

Parameters:

index[in] The waypoint index

Returns:

The tolerance in meters.

inline ng_float_t get_tolerance() const#

Gets the default goal spatial tolerance.

This value is used in get_effective_tolerance to compute the effective tolerance applied to a selected waypoint, where specific (positive) tolerances returned by get_tolerances will overwrites this default value.

Returns:

The default spatial tolerance in meters.

inline const std::vector<ng_float_t> &get_tolerances() const#

Gets the specific goal spatial tolerances.

This values are used in get_effective_tolerance to compute the effective tolerance applied to a selected waypoint: negative values are ignored and replaced by the default value get_tolerance. Extra items (not paired to \get_waypoints) are also ignored.

Returns:

The spatial tolerances of waypoints at specific indices in meters

inline void set_tolerance(ng_float_t value)#

Sets the default goal spatial tolerance.

This value is used in get_effective_tolerance to compute the effective tolerance applied to a selected waypoint, where specific (positive) tolerances set by set_tolerances will overwrites this default value.

Parameters:

value[in] The desired positive value in meters.

inline void set_tolerances(const std::vector<ng_float_t> &values)#

Sets the specific goal spatial tolerances.

This values are used in get_effective_tolerance to compute the effective tolerance applied to a selected waypoint: negative values are ignored and replaced by the default value set with set_tolerance. Extra items (not paired to \get_waypoints) are also ignored.

Parameters:

values[in] The desired values at specific indices in meters

inline ng_float_t get_effective_angular_tolerance(unsigned index) const#

Returns the angular tolerance applied to the waypoint at a given index.

If a specific positive value is present at the same index in get_angular_tolerances, it returns it. Else it returns the default value from get_angular_tolerance.

For example, if there are three waypoints, the specific angular tolerances are set to -1, 0.2, and the default angular tolerance is set to 0.25, the effective angular tolerances will be 0.25, 0.2, 0.25.

Parameters:

index[in] The waypoint index

Returns:

The angular tolerance in radians.

inline ng_float_t get_angular_tolerance() const#

Gets the default goal angular tolerance.

This value is used in get_effective_angular_tolerance to compute the effective angular tolerance applied to a selected waypoint, where specific (positive) angular tolerances returned by get_angular_tolerances will overwrites this default value.

Returns:

The default angular tolerances in meters

inline const std::vector<ng_float_t> &get_angular_tolerances() const#

Gets the specific goal angular tolerances.

This values are used in get_effective_angular_tolerance to compute the effective tolerance applied to a selected waypoint: negative values are ignored and replaced by the default value get_angular_tolerance. Extra items (not paired to \get_waypoints) are also ignored.

Returns:

The individual waypoints angular tolerances.

inline void set_angular_tolerance(ng_float_t value)#

Sets the goal angular tolerance applied to each waypoint.

This value is used in get_effective_angular_tolerance to compute the effective angular tolerance applied to a selected waypoint, where specific (positive) angular tolerances set by set_angular_tolerances will overwrites this default value.

Parameters:

value[in] The desired positive value.

inline void set_angular_tolerances(const std::vector<ng_float_t> &values)#

Sets the specific goal angular tolerances.

This values are used in get_effective_angular_tolerance to compute the effective angular tolerance applied to a selected waypoint: negative values are ignored and replaced by the default value set with set_angular_tolerance. Extra items (not paired to \get_waypoints) are also ignored.

Parameters:

values[in] The desired values at specific indices in radians.

Public Static Attributes

static const bool default_loop = true#

Whether by default the task loops.

static const ng_float_t default_tolerance = 1#

The default goal spatial tolerance.

static const ng_float_t default_angular_tolerance = std::numeric_limits<ng_float_t>::infinity()#

The default goal orientation tolerance.

static const bool default_random = false#

By default moves in sequence.