bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
multi_robot_navigation.h
Go to the documentation of this file.
1#ifndef MULTI_ROBOT_NAVIGATION_H
2#define MULTI_ROBOT_NAVIGATION_H
3
6
7#include <any>
8#include <array>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13namespace bitrl
14{
15namespace envs::multi_agent
16{
17
22{
23 real_t x{0.0};
24 real_t y{0.0};
26};
27
54 : public MultiAgentEnvBase<std::vector<real_t>, std::array<real_t, 2>>
55{
56 public:
57 typedef MultiAgentEnvBase<std::vector<real_t>, std::array<real_t, 2>> base_type;
60
62
63 void make(const std::string &version,
64 const std::unordered_map<std::string, std::any> &make_options,
65 const std::unordered_map<std::string, std::any> &reset_options) override;
66
67 using base_type::reset;
68
69 time_step_type reset(uint_t seed) override;
70
71 time_step_type step(const joint_action_type &actions) override;
72
76 uint_t observation_size() const noexcept { return 5 + 4 * (n_agents() - 1); }
77
78 const std::vector<RobotPose> &poses() const noexcept { return poses_; }
79
80 const std::vector<std::array<real_t, 2>> &goals() const noexcept { return goals_; }
81
85 const std::vector<std::array<real_t, 2>> &velocities() const noexcept { return velocities_; }
86
87 real_t robot_radius() const noexcept { return robot_radius_; }
88
89 real_t circle_radius() const noexcept { return circle_radius_; }
90
91 real_t dt() const noexcept { return dt_; }
92
93 real_t max_v() const noexcept { return max_v_; }
94
95 real_t max_w() const noexcept { return max_w_; }
96
101
105 uint_t n_collisions() const noexcept { return n_collisions_; }
106
110 real_t min_separation() const noexcept { return min_separation_; }
111
112 private:
113 time_step_type make_time_step_(TimeStepTp type, std::vector<real_t> rewards, bool truncated,
114 uint_t collisions) const;
115
116 std::vector<real_t> observe_(uint_t robot) const;
117
118 real_t closest_pair_() const;
119
120 std::vector<RobotPose> poses_;
121 std::vector<std::array<real_t, 2>> goals_;
122 std::vector<std::array<real_t, 2>> velocities_;
123 std::vector<bool> dones_;
124 real_t circle_radius_{2.0};
125 real_t robot_radius_{0.15};
126 real_t goal_tolerance_{0.1};
127 real_t dt_{0.1};
128 real_t max_v_{0.5};
129 real_t max_w_{2.0};
130 real_t progress_weight_{1.0};
131 real_t time_reward_{-0.01};
132 real_t collision_reward_{-1.0};
133 real_t goal_reward_{10.0};
134 real_t start_noise_{0.0};
135 uint_t n_collisions_{0};
136 real_t min_separation_{0.0};
137};
138
139} // namespace envs::multi_agent
140} // namespace bitrl
141
142#endif // MULTI_ROBOT_NAVIGATION_H
std::string version() const noexcept
Definition multi_agent_env_base.h:90
MultiAgentEnvBase(const std::string &name)
Definition multi_agent_env_base.h:110
const std::unordered_map< std::string, std::any > & make_options() const noexcept
Definition multi_agent_env_base.h:104
std::vector< action_type > joint_action_type
Definition multi_agent_env_base.h:43
MultiAgentTimeStep< std::vector< real_t > > time_step_type
Definition multi_agent_env_base.h:38
real_t max_w() const noexcept
Definition multi_robot_navigation.h:95
real_t robot_radius() const noexcept
Definition multi_robot_navigation.h:87
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.
MultiAgentEnvBase< std::vector< real_t >, std::array< real_t, 2 > > base_type
Definition multi_robot_navigation.h:57
real_t min_separation() const noexcept
The smallest distance between the centres of two robots in the current episode.
Definition multi_robot_navigation.h:110
base_type::time_step_type time_step_type
Definition multi_robot_navigation.h:58
const std::vector< std::array< real_t, 2 > > & velocities() const noexcept
The velocity {vx, vy} of every robot in the last step.
Definition multi_robot_navigation.h:85
base_type::joint_action_type joint_action_type
Definition multi_robot_navigation.h:59
real_t dt() const noexcept
Definition multi_robot_navigation.h:91
real_t circle_radius() const noexcept
Definition multi_robot_navigation.h:89
real_t distance_to_goal(uint_t robot) const
The distance of robot to its goal.
time_step_type step(const joint_action_type &actions) override
Apply one action per agent.
time_step_type reset(uint_t seed) override
Start a new episode with the given seed.
uint_t observation_size() const noexcept
The size of the observation of one robot.
Definition multi_robot_navigation.h:76
real_t max_v() const noexcept
Definition multi_robot_navigation.h:93
const std::vector< RobotPose > & poses() const noexcept
Definition multi_robot_navigation.h:78
uint_t n_collisions() const noexcept
The moves cancelled by collisions in the current episode.
Definition multi_robot_navigation.h:105
const std::vector< std::array< real_t, 2 > > & goals() const noexcept
Definition multi_robot_navigation.h:80
Definition distributed_agent_env.h:19
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
TimeStepTp
The TimeStepTp enum.
Definition time_step_type.h:15
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
The pose of a robot of MultiRobotNavigation: position and heading.
Definition multi_robot_navigation.h:22
real_t x
Definition multi_robot_navigation.h:23
real_t theta
Definition multi_robot_navigation.h:25
real_t y
Definition multi_robot_navigation.h:24