Behavior groups#

Behaviors may be grouped to compute their commands all together, like for example to implement a centralized controller.

Groups#

Behaviors group must implement a single interface compute_cmds (C++, Python) that computes the commands for all members. Commands should be kinematically feasible, but it is not strictly required.

Virtual methods#

C++ method

Python method

override

compute_cmds

compute_cmds

must

Class skeleton#

#include "navground/core/behavior_group.h"

namespace core = navground::core;

struct MyBehaviorGroup : public core::BehaviorGroup {
  // MUST override
  core::Twist2 compute_cmd_internal(ng_float_t time_step) override;
};

Members#

Members of the groups are behaviors that delegates their compute_cmd_internal (C++, Python) to the group.

Their definition requires to specify:

  • how they are grouped using get_group_hash (C++, Python, behavior with the same key will belong to the same group);

  • where groups are stored (globally) using get_groups (C++, Python);

  • how to create a new group using make_group (C++, Python).

Warning

Users should call prepare (C++, Python) before the first call and close (C++, Python) after the final call of a behavior. This will setup and tear down the groups.

Virtual methods#

C++ method

Python method

override

get_groups

get_groups

must

make_group

make_group

must

get_group_hash

get_group_hash

can

Class skeleton#

#include "navground/core/behavior_group.h"

namespace core = navground::core;

struct MyBehaviorGroupMember : public core::BehaviorGroupMember {
  using core::BehaviorGroupMember::Groups;
  
  // MUST override
  Groups * get_groups() const override;

  // MUST override
  std::shared_ptr<core::BehaviorGroup> * make_group() const override;

  // CAN override
  // size_t get_group_hash() const override;
};