Waypoints#
#include "navground/sim/tasks/waypoints.h"
A sequence of points to reach.
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:
waypoints
(list of navground::core::Vector2, get_waypoints)loop
(bool, get_loop)random
(bool, get_random)tolerance
(bool, get_tolerance)tolerances
(list of float, get_tolerances)angular_tolerance
(float, get_angular_tolerance)angular_tolerances
(list of float, get_angular_tolerances)orientations
(list of float, get_orientations)wait_time
(float, get_wait_time)wait_times
(list of float, get_wait_times)
Subclassed by navground::sim::GoToPoseTask
Public Functions
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.
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
Sets the waypoints.
- Parameters:
value – [in] The desired waypoints
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)
Sets whether it should start from begin after reaching the last waypoint.
- Parameters:
value – [in] The desired value
Gets the waypoints.
- Returns:
The waypoints.
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).
Gets whether it should start from begin after reaching the last waypoint.
- Returns:
True if it should loop.
Gets whether to pick the next waypoint randomly.
- Returns:
True if it should pick randomly.
Sets whether to pick the next waypoint randomly.
- Parameters:
value – [in] The desired value
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 to0.25
, the effective tolerances will be0.25, 0.2, 0.25
.- Parameters:
index – [in] The waypoint index
- Returns:
The tolerance in meters.
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.
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
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.
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
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 to0.25
, the effective angular tolerances will be0.25, 0.2, 0.25
.- Parameters:
index – [in] The waypoint index
- Returns:
The angular tolerance in radians.
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
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.
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.
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.
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.
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.
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.
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.
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
Gets the orientation at a given index.
- Parameters:
index – [in] The index
- Returns:
The orientation or null the index is not valid.
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
Whether by default the task loops.
The default goal spatial tolerance.
The default goal orientation tolerance.
By default moves in sequence.