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_pose or navground::core::Controller::go_to_position for the next waypoint after the current has been reached within a tolerance, depending if a goal orientation has been specified using set_orientations or not.

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>{}, ng_float_t wait_time = 0, const std::vector<ng_float_t> &wait_times = 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 specific waypoints.

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

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

  • angular_tolerances[in] The goal angular tolerances applied to specific waypoints.

  • wait_time[in] The time to wait at each waypoint.

  • wait_times[in] The time to wait at specific waypoint.

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 7 numbers [time, action_id, data_1, ..., data_5]:

  • idle: [time, 0, 0, 0, 0, 0, 0]

  • start waiting for t seconds: [time, 1, t, 0, 0, 0, 0]

  • start moving towards pose (x, y, theta): [time, 2, x, y, theta, tolerance, angular tolerance]

  • start moving towards point (x, y): [time, 3, x, y, 0, tolerance, 0]

Returns:

7

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.

If there are more orientations specified than waypoints, those extra orientation are ignore.

If there are less orientations specified than waypoints, the missing orientation are effectively filled with the last orientation during control.

To ignore the orientation at a specific waypoint index, set the related angular tolerance above PI.

Parameters:

values[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 const 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.

If there are more orientations specified than waypoints, those extra orientation are ignore.

If there are less orientations specified than waypoints, the missing orientation are effectively filled with the last orientation during control.

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: 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.

These 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: 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.

These 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: 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.

These 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 specific 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: 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.

These 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.

inline ng_float_t get_effective_wait_time(unsigned index) const#

Gets the effective wait time before moving towards the waypoint at given index.

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

Parameters:

index[in] The index

Returns:

The time in seconds.

inline ng_float_t get_wait_time() const#

Gets the default wait time before moving towards a waypoint.

This value is used in get_effective_wait_time to compute the effective wait time applied to a selected waypoint: specific (positive) wait times returned by get_wait_times will overwrites this default value.

Returns:

The time in seconds.

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

Gets the wait times before moving towards specific waypoints.

These 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 wait times.

inline void set_wait_time(ng_float_t value)#

Sets the default wait time before moving towards a waypoint.

This value is used in get_effective_wait_time to compute the effective wait time applied to a selected waypoint: specific (positive) wait times returned by get_wait_times will overwrites this default value.

Parameters:

value[in] The desired positive value.

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

Sets the wait times before moving towards specific waypoints.

These 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.

Parameters:

values[in] The values

inline std::optional<ng_float_t> get_orientation(unsigned index) const#

Gets the orientation at a given index.

Parameters:

index[in] The index

Returns:

The orientation or null the index is not valid.

inline std::optional<core::Vector2> get_waypoint(unsigned index) const#

Gets the waypoint at a given index.

Parameters:

index[in] The index

Returns:

The waypoint or null the index is not valid.

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.