bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
epuck_simple_grid_world.h
Go to the documentation of this file.
1#ifndef EPUCK_SIMPLE_GRID_WORLD_H
2#define EPUCK_SIMPLE_GRID_WORLD_H
3
7
8#include "rlenvs/bitrl_config.h"
9
10#ifdef BITRL_WEBOTS
11
12#include "rlenvs/envs/env_types.h"
13#include "rlenvs/envs/time_step.h"
14#include "rlenvs/envs/webots_envs/webots_base_env.h"
15#include "rlenvs/rigid_bodies/webots_robots/epuck_robot.h"
16#include "rlenvs/rlenvs_types_v2.h"
17
18#include <webots/PositionSensor.hpp>
19#include <webots/Robot.hpp>
20
21#include <any>
22#include <exception>
23#include <vector>
24
25namespace rlenvscpp
26{
27namespace envs
28{
29namespace webots_envs
30{
31
32using namespace rlenvscpp::rigid_bodies::webots_robots;
33
45class EpuckSimpleGridWorld final
46 : public WebotsEnvBase<TimeStep<std::vector<real_t>>,
47 ContinuousVectorStateDiscreteActionEnv<3, // the state space has size 3
48 1, // the action space ends at 1
49 0, // the action space starts at 0
50 real_t>>
51{
52
53 public:
57 static const std::string name;
58
62 typedef WebotsEnvBase<
63 TimeStep<state_type>,
64 envs::ContinuousVectorStateDiscreteActionEnv<3, // the state space has size 2
65 1, // the action space ends at 1
66 0, // the action space starts at 0
67 real_t>>
68 base_type;
69
74 typedef typename base_type::time_step_type time_step_type;
75
79 typedef typename base_type::state_space_type state_space_type;
80
84 typedef typename base_type::action_space_type action_space_type;
85
89 typedef typename base_type::action_type action_type;
90
94 typedef typename base_type::state_type state_type;
95
99 using base_type::reset;
100
104 EpuckSimpleGridWorld();
105
116 virtual void make(const std::string &version,
117 const std::unordered_map<std::string, std::any> &options) override final;
118
123 virtual void close() override final;
124
128 virtual void pause_simulation() override final;
129
134 virtual time_step_type
135 reset(uint_t /*seed*/,
136 const std::unordered_map<std::string, std::any> & /*options*/) override final;
137
142 virtual time_step_type step(const action_type &action) override final;
143
147 uint_t n_actions() const noexcept { return action_space_type::size; }
148
152 real_t compute_reward() const;
153
157 EpuckRobot &get_robot() noexcept { return robot_; }
158
162 const EpuckRobot &get_robot() const noexcept { return robot_; }
163
164 private:
168 EpuckRobot robot_;
169
174 void build_make_options_(const std::unordered_map<std::string, std::any> &options);
175
179 void activate_robot_();
180
184 time_step_type on_stop_();
185
189 time_step_type on_move_();
190};
191
192} // namespace webots_envs
193} // namespace envs
194} // namespace rlenvscpp
195
196#endif
197#endif
double real_t
real_t
Definition bitrl_types.h:23
std::pair< uint_t, uint_t > state_type
Definition example_15.cpp:28
Definition quadcopter_sim_env.cpp:16