Behavior Group#

#include "navground/core/behavior_group.h"
class BehaviorGroup#

Behavior group holds a list of behaviors for which they compute control commands at once.

Public Functions

inline const std::vector<Behavior*> &get_members()#

Gets the members of the group.

Returns:

The behaviors.

size_t size() const#

Returns the size of the group.

Returns:

The number of behaviors

Protected Functions

virtual std::vector<Twist2> compute_cmds(ng_float_t time_step) = 0#

Calculates the commands for all behaviors at once.

Commands should (but not strictly required) be feasible.

This method is called each time the behavior at the first index requires a command.

Users must override this method to define a BehaviorGroup.

Parameters:

time_step[in] The time step

Returns:

The commands.

class BehaviorGroupMember : public navground::core::Behavior#

Members of a behavior group delegate the computation of their control commands to the group.

Warning

Users must call Behavior::prepare before the first call to Behavior::compute_cmd to setup the group and call Behavior::close after the last call to tear it down.

Public Types

using Groups = std::map<size_t, std::shared_ptr<BehaviorGroup>>#

A map of groups indexed by an integer key, which may be computed using hashing.

Public Functions

inline std::shared_ptr<BehaviorGroup> get_group() const#

Gets the group.

Returns:

The group.

Protected Functions

virtual std::shared_ptr<BehaviorGroup> make_group() const = 0#

Makes a group.

Users must specialize this method when defining a new group/member pair.

Returns:

The new group

inline virtual size_t get_group_hash() const#

Gets the key associated to the group.

Users can specialize this method when defining a new group/member pair. The default implementation returns 0, i.e., it groups all behaviors together.

Returns:

The hash key.

virtual Groups *get_groups()#

Returns all groups.

Users must specialize this method when defining a new group/member pair.

Returns:

All groups.