bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::envs::multi_agent::MultiRobotNavigation Class Referencefinal

Differential drive robots that cross a circle to the opposite point, all at the same time, without driving into each other. More...

#include <multi_robot_navigation.h>

Inheritance diagram for bitrl::envs::multi_agent::MultiRobotNavigation:
Collaboration diagram for bitrl::envs::multi_agent::MultiRobotNavigation:

Public Types

typedef MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > > base_type
typedef base_type::time_step_type time_step_type
typedef base_type::joint_action_type joint_action_type
Public Types inherited from bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >
typedef std::vector< real_t > observation_type
typedef std::array< real_t, 2 > action_type
typedef MultiAgentTimeStep< std::vector< real_t > > time_step_type
typedef std::vector< action_type > joint_action_type
 One action per agent, in the order of the agents.

Public Member Functions

 MultiRobotNavigation ()
void make (const std::string &version, const std::unordered_map< std::string, std::any > &make_options, const std::unordered_map< std::string, std::any > &reset_options) override
 Build the environment.
time_step_type reset (uint_t seed) override
 Start a new episode with the given seed.
time_step_type step (const joint_action_type &actions) override
 Apply one action per agent.
uint_t observation_size () const noexcept
 The size of the observation of one robot.
const std::vector< RobotPose > & poses () const noexcept
const std::vector< std::array< real_t, 2 > > & goals () const noexcept
const std::vector< std::array< real_t, 2 > > & velocities () const noexcept
 The velocity {vx, vy} of every robot in the last step.
real_t robot_radius () const noexcept
real_t circle_radius () const noexcept
real_t dt () const noexcept
real_t max_v () const noexcept
real_t max_w () const noexcept
real_t distance_to_goal (uint_t robot) const
 The distance of robot to its goal.
uint_t n_collisions () const noexcept
 The moves cancelled by collisions in the current episode.
real_t min_separation () const noexcept
 The smallest distance between the centres of two robots in the current episode.
time_step_type reset ()
 Start a new episode with the next seed.
Public Member Functions inherited from bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >
virtual ~MultiAgentEnvBase ()=default
time_step_type reset ()
 Start a new episode with the next seed.
virtual void close ()
 Release the environment; make() builds it again.
uint_t n_agents () const noexcept
const std::string & agent_name (uint_t agent) const
 The name of an agent, for printing.
bool is_created () const noexcept
std::string env_name () const noexcept
std::string version () const noexcept
uint_t n_steps () const noexcept
 The steps of the current episode so far.
uint_t max_steps () const noexcept
 The steps after which an episode is truncated.
uint_t last_reset_seed () const noexcept
const std::unordered_map< std::string, std::any > & make_options () const noexcept

Additional Inherited Members

Static Public Attributes inherited from bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >
static constexpr uint_t DEFAULT_ENV_SEED
Protected Member Functions inherited from bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >
 MultiAgentEnvBase (const std::string &name)
void set_agents_ (std::vector< std::string > names)
 Name the agents; their number is the number of names.
void set_max_steps_ (uint_t max_steps) noexcept
void make_created_ () noexcept
void start_episode_ () noexcept
 Start counting the steps of a new episode, for reset().
bool count_step_ () noexcept
 Count a step, for step().
void check_step_ (const joint_action_type &actions) const
 Throw unless make() was called and actions has one action per agent.
T option_ (const std::string &name, const T &default_value) const
 Read a make option, or give default_value when it is missing.

Detailed Description

Differential drive robots that cross a circle to the opposite point, all at the same time, without driving into each other.

The robots start evenly spaced on a circle, facing its centre, and each has to reach the point of the circle opposite its start, so that all of them meet in the middle. A robot moves with the kinematics of bitsim::dynamics::DiffDriveDynamics: its action is a linear and an angular velocity, {v, w}, clipped to max_v and max_w. The robots are discs of radius robot_radius; a move that would make two discs overlap is cancelled, the robot stands still for that step and the move counts as a collision. A robot within goal_tolerance of its goal is done and stops.

The observation of robot i, all in the world frame, is [x, y, theta, goal_x - x, goal_y - y, then for every other robot j in order: x_j - x, y_j - y, vx_j, vy_j], so 5 + 4 (n_robots - 1) numbers.

The reward of a robot that is not done is progress_weight times the distance it gained to its goal, plus time_reward, plus collision_reward on a collision and goal_reward when it arrives.

Make options, all optional: "n_robots" (uint_t, 4), "circle_radius" (real_t, 2.0), "robot_radius" (real_t, 0.15), "goal_tolerance" (real_t, 0.1), "dt" (real_t, 0.1), "max_v" (real_t, 0.5), "max_w" (real_t, 2.0), "progress_weight" (real_t, 1.0), "time_reward" (real_t, -0.01), "collision_reward" (real_t, -1.0), "goal_reward" (real_t, 10.0), "start_noise" (real_t, 0.0: the standard deviation of a random shift of the starts, drawn with the seed of the reset), "max_steps" (uint_t, 400).

Member Typedef Documentation

◆ base_type

◆ joint_action_type

◆ time_step_type

Constructor & Destructor Documentation

◆ MultiRobotNavigation()

bitrl::envs::multi_agent::MultiRobotNavigation::MultiRobotNavigation ( )

Member Function Documentation

◆ circle_radius()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::circle_radius ( ) const
inlinenoexcept

◆ distance_to_goal()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::distance_to_goal ( uint_t robot) const

The distance of robot to its goal.

◆ dt()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::dt ( ) const
inlinenoexcept

◆ goals()

const std::vector< std::array< real_t, 2 > > & bitrl::envs::multi_agent::MultiRobotNavigation::goals ( ) const
inlinenoexcept

◆ make()

void bitrl::envs::multi_agent::MultiRobotNavigation::make ( const std::string & version,
const std::unordered_map< std::string, std::any > & make_options,
const std::unordered_map< std::string, std::any > & reset_options )
overridevirtual

Build the environment.

Parameters
versionthe version of the environment
make_optionsthe options of the environment; see the derived class
reset_optionsthe options of reset(), "seed" for one

Reimplemented from bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >.

◆ max_v()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::max_v ( ) const
inlinenoexcept

◆ max_w()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::max_w ( ) const
inlinenoexcept

◆ min_separation()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::min_separation ( ) const
inlinenoexcept

The smallest distance between the centres of two robots in the current episode.

◆ n_collisions()

uint_t bitrl::envs::multi_agent::MultiRobotNavigation::n_collisions ( ) const
inlinenoexcept

The moves cancelled by collisions in the current episode.

◆ observation_size()

uint_t bitrl::envs::multi_agent::MultiRobotNavigation::observation_size ( ) const
inlinenoexcept

The size of the observation of one robot.

◆ poses()

const std::vector< RobotPose > & bitrl::envs::multi_agent::MultiRobotNavigation::poses ( ) const
inlinenoexcept

◆ reset() [1/2]

time_step_type bitrl::envs::multi_agent::MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > >::reset ( )
inline

Start a new episode with the next seed.

◆ reset() [2/2]

time_step_type bitrl::envs::multi_agent::MultiRobotNavigation::reset ( uint_t seed)
overridevirtual

◆ robot_radius()

real_t bitrl::envs::multi_agent::MultiRobotNavigation::robot_radius ( ) const
inlinenoexcept

◆ step()

time_step_type bitrl::envs::multi_agent::MultiRobotNavigation::step ( const joint_action_type & actions)
overridevirtual

◆ velocities()

const std::vector< std::array< real_t, 2 > > & bitrl::envs::multi_agent::MultiRobotNavigation::velocities ( ) const
inlinenoexcept

The velocity {vx, vy} of every robot in the last step.


The documentation for this class was generated from the following file: