Controller#
Two-dimensional#
#include "navground/core/controller.h"
Holds the state of a long running task and notifies observers when it terminates.
Subclassed by navground::core::FollowAction, navground::core::FollowManualCommandAction, navground::core::FollowTwistAction, navground::core::MoveAction
Public Types
The state of an action.
Values:
the action has not started
the action is running
the action failed
the action succeeded
Public Functions
Return whenever the action is done or not.
- Returns:
True if the action failed or succeeded
Return whenever the action is running.
- Returns:
True if the action is running
Abort the action, calling the done_cb if set.
Public Members
The current state
A callback called when the action is running
The callback argument is the minimal expected time to terminate the action.
A callback called when the action terminates
The callback argument is the final state of the action.
This class exposes a higher level, stateful interface to a behavior, to which it delegates 2D collision avoidance.
The controller provides actions (event-based interfaces) to
go to a point/pose, stopping once the target has been reached,
follow a point/pose, which does not terminates once the target has been reached
follow a velocity/twist
Typical usage of a controller
Pick and configure a Behavior
Initialize and configure the controller
At regular intervals, update the state, using the Behavior API, and call update.
When needed, trigger one of the actions.
Either manually check the action’s get_state or set callbacks to be notified when the action terminates or updates.
Actuate the target command by using the return value of update or by setting a callback set_cmd_cb
Subclassed by navground::core::Controller3
Public Functions
Constructs a new instance.
- Parameters:
behavior – [in] The navigation behavior
Gets the state of the control action.
- Returns:
The state.
Gets the navigation behavior used by the controller.
- Returns:
The navigation behavior.
Sets the navigation behavior used by the controller.
- Parameters:
value – [in] The navigation behavior
Gets the minimal speed to consider the agent as stopped.
The default is 1 cm/s.
- Returns:
The speed tolerance.
Sets the minimal speed to consider the agent as stopped.
- Parameters:
value – [in] The speed tolerance
Gets the frame of reference for the command.
- Returns:
The frame of reference.
Sets the frame of reference for the command.
- Parameters:
frame – [in] The desired value
Starts an action to go to a point.
The action succeed once the agent arrives within a tolerance from the target point and comes to a stop.
If an action is already running, the controller aborts it.
- Parameters:
point – [in] The target point
tolerance – [in] The spatial tolerance
along_path – [in] An optional path to follow
- Returns:
The new action.
Starts an action to go to a pose.
The action succeed once the agent arrives within a tolerance from the target pose and comes to a stop.
If an action is already running, the controller aborts it.
- Parameters:
pose – [in] The target pose
position_tolerance – [in] The spatial tolerance
orientation_tolerance – [in] The spatial tolerance
along_path – [in] An optional path to follow
- Returns:
The new action.
Start following a path.
Internally calls go_to_position to move towards the last point of the path .
- Parameters:
path – [in] The path
tolerance – [in] The spatial tolerance
- Returns:
The new action.
Starts an action to follow a point.
The action keeps running even after the agent arrive at the target.
If an action is already running, the controller aborts it, unless it was following a point/pose, in which case it just updates the target.
- Parameters:
point – [in] The target point
- Returns:
The new action.
Starts an action to follow a pose.
The action keeps running even after the agent arrive at the target.
If an action is already running, the controller aborts it, unless it was following a point/pose, in which case it just updates the target.
- Parameters:
pose – [in] The target pose
- Returns:
The new action.
Starts an action to follow a target direction.
If an action is already running, the controller aborts it, unless it was following a velocity/twist, in which case it just updates the target.
- Parameters:
direction – [in] The target direction. Must have positive norm.
- Returns:
The new action.
Starts an action to follow a target velocity.
If an action is already running, the controller aborts it, unless it was following a velocity/twist, in which case it just updates the target.
- Parameters:
velocity – [in] The target velocity
- Returns:
The new action.
Starts an action to follow a target twist.
If an action is already running, the controller aborts it, unless it was following a velocity/twist, in which case it just updates the target.
- Parameters:
twist – [in] The target twist
- Returns:
The new action.
Returns whether the control action is idle.
- Returns:
True only if the control action is not running.
Abort the running action.
Updates the control for time step.
Internally calls Behavior::compute_cmd for collision avoidance.
- Parameters:
time_step – [in] The time step
- Returns:
The command twist to execute the current action
Sets the callback called each time a command is computed for an active action.
- Parameters:
value – [in] A callback that takes the command twist as argument.
Three-dimensional#
#include "navground/core/controller_3d.h"
Three dimensional obstacles with a vertical cylindrical shape.
Subclassed by navground::core::Neighbor3
Public Functions
Constructs a new instance.
- Parameters:
position – [in] Center of the lower face
radius – [in] Radius of the cylinder
height – [in] Height of the cylinder
Project the cylinder to the two dimensional plane.
- Returns:
The projected disc.
Public Members
Center of the lower face.
Radius of the cylinder
Height of the cylinder
Three dimensional neighbor of a vertical cylindrical shape.
Public Functions
Constructs a new instance.
- Parameters:
position – [in] Center of the lower face
radius – [in] Radius of the cylinder
height – [in] Height of the cylinder
velocity – [in] Planar velocity
id – [in] Neighbor identifier
Project to the two dimensional plane.
- Returns:
The projected neighbor.
Simplistic extension of Controller to 3D.
Assumes that the agent has planar attitude and motion in 3D space.
Relies on the 2D obstacle avoidance Behavior, when provided with all relevant state (i.e., vertical position, speed, and target position), it 1) considers only obstacles that may intersect in three dimensions 2) controls vertical speed with a proportional controller.
Note that this is at best a 2.5D controller, making no attempt at 3D collision avoidance. It is best suited for planar motion at arbitrary altitudes, like when a drone flies above ground robots, effectively ignoring them.
Typical usage
Pick, configure a Behavior, set it to behavior
Initialize and configure the controller
At regular intervals update the state, using the Controller3 API, and call update_3d.
Trigger one of the actions.
Either manually check the action’s get_state or set callbacks to be notified when the action terminates or updates.
Actuate the target command by using the return value of update_3d or by setting a callback set_cmd_cb
Public Functions
Constructs a new instance.
- Parameters:
behavior – [in] The navigation behavior
limit_to_2d – [in] Whether to limit the control to 2D
Sets the neighbors.
Filter relevant neighbors, project them to 2D and pass them to GeometricState::set_neighbors
- Parameters:
neighbors – [in] The neighbors
Sets the static obstacles.
Filter relevant obstacles, project them to 2D and pass them to GeometricState::set_static_obstacles
- Parameters:
obstacles – [in] The obstacles
Gets the pose.
- Returns:
The pose.
Sets the pose.
Automatically also set the behavior 2D pose.
- Parameters:
pose – [in] The pose
Gets the twist.
- Returns:
The twist.
Sets the twist.
Automatically set the behavior 2D twist.
- Parameters:
twist – [in] The twist
Actuate a twist command, integrating using Pose3::integrate.
- Parameters:
twist – [in] The twist
time_step – [in] the time step
Gets the altitude optimal speed.
- Returns:
The altitude optimal speed.
Sets the altitude optimal speed.
- Parameters:
value – [in] The desired value
Gets the altitude relaxation time.
- Returns:
The altitude relaxation time.
Sets the altitude relaxation time.
- Parameters:
value – [in] The desired value
Starts an action to go to a 3D point.
The action succeed once the agent arrives within a tolerance from the target point and comes to a stop.
If an action is already running, the controller aborts it.
- Parameters:
point – [in] The target point
tolerance – [in] The spatial tolerance
- Returns:
The new action.
Starts an action to go to a 3D pose.
The action succeed once the agent arrives within a tolerances from the target pose and comes to a stop.
If an action is already running, the controller aborts it.
- Parameters:
pose – [in] The target pose
position_tolerance – [in] The spatial tolerance
orientation_tolerance – [in] The spatial tolerance
- Returns:
The new action.
Starts an action to follow a 3D point.
The action keeps running even after the agent arrive at the target.
If an action is already running, the controller aborts it, unless it was following a point/pose, in which case it just updates the target.
- Parameters:
point – [in] The target point
- Returns:
The new action.
Starts an action to follow a 3D pose.
The action keeps running even after the agent arrive at the target.
If an action is already running, the controller aborts it, unless it was following a point/pose, in which case it just updates the target.
- Parameters:
pose – [in] The target pose
- Returns:
The new action.
Starts an action to follow a 3D velocity.
If an action is already running, the controller aborts it, unless it was following a velocity/twist, in which case it just updates the target.
- Parameters:
velocity – [in] The target velocity
- Returns:
The new action.
Starts an action to follow a 3D twist.
If an action is already running, the controller aborts it, unless it was following a velocity/twist, in which case it just updates the target.
- Parameters:
twist – [in] The target twist
- Returns:
The new action.
Updates the control for time step, computing a 3D command.
Internally calls Behavior::compute_cmd for collision avoidance.
- Parameters:
time_step – [in] The time step
- Returns:
The command twist to execute the current action
Sets the callback called each time a command is computed for an active action.
- Parameters:
value – [in] The callback that takes the 3D command twist as argument.
Determines if currently limited to 2D control.
- Returns:
True if limited to 2D, False otherwise.
Set if the control should ignore 3D information.
- Parameters:
value – [in] The desired value