bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
acrobot_vec_env.h
Go to the documentation of this file.
1#ifndef ACROBOT_ENV_H
2#define ACROBOT_ENV_H
3
11
17#include "bitsim/extern/nlohmann/json/json.hpp"
18
19#include <any>
20#include <string>
21#include <vector>
22
23namespace bitrl
24{
25
27template <typename StateTp> class VectorTimeStep;
28
29namespace envs::gymnasium
30{
31
32namespace detail_
33{
34
36{
37
39
41
46
48
52 typedef std::vector<typename action_space::space_item_type> action_type;
53
58};
59
60} // namespace detail_
61
65class AcrobotV final : public GymnasiumVecEnvBase<VectorTimeStep<detail_::AcrobotVEnv::state_type>,
66 detail_::AcrobotVEnv>
67{
68
69 public:
73 static const std::string name;
74
78 static const std::string URI;
79
85
91
96
101
106
111
116
120 AcrobotV(const AcrobotV &other);
121
125 ~AcrobotV() override = default;
126
130 virtual void
131 make(const std::string &version, const std::unordered_map<std::string, std::any> &,
132 const std::unordered_map<std::string, std::any> &reset_options) override final;
133
137 virtual time_step_type step(const action_type &action) override final;
138
142 uint_t n_actions() const noexcept { return action_space_type::size; }
143
144 protected:
148 virtual time_step_type
149 create_time_step_from_response_(const nlohmann::json &response) const override final;
150};
151
152} // namespace envs::gymnasium
153} // namespace bitrl
154
155#endif // PENDULUM_ENV_H
Forward declaration.
Definition vector_time_step.h:21
SpaceType::state_space state_space_type
Type describing the environment state space.
Definition env_base.h:45
SpaceType::state_type state_type
Type describing an individual state.
Definition env_base.h:48
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Definition env_base.h:105
SpaceType::action_space action_space_type
Type describing the environment action space.
Definition env_base.h:51
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:42
SpaceType::action_type action_type
Type representing an individual action.
Definition env_base.h:54
GymnasiumVecEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >::base_type base_type
Base class type.
Definition acrobot_vec_env.h:84
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition acrobot_vec_env.h:100
base_type::state_type state_type
The type of the state.
Definition acrobot_vec_env.h:110
~AcrobotV() override=default
~Acrobot. Destructor
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
static const std::string name
name
Definition acrobot_vec_env.h:73
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition acrobot_vec_env.h:142
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition acrobot_vec_env.h:95
static const std::string URI
The URI for accessing the environment.
Definition acrobot_vec_env.h:78
AcrobotV(network::RESTRLEnvClient &api_server)
Acrobot. Constructor.
AcrobotV(const AcrobotV &other)
copy ctor
virtual time_step_type step(const action_type &action) override final
step. Step in the environment following the given action
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition acrobot_vec_env.h:105
virtual void make(const std::string &version, const std::unordered_map< std::string, std::any > &, const std::unordered_map< std::string, std::any > &reset_options) override final
make. Build the environment
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition acrobot_vec_env.h:90
GymnasiumVecEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Definition gymnasium_vector_env_base.h:105
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
Definition acrobot_vec_env.h:33
Definition lunar_lander_env.h:18
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
Definition space_type.h:138
std::vector< real_t > space_item_type
Definition space_type.h:150
static constexpr uint_t size
Definition space_type.h:145
A scalar discrete space can be used to denote a space that only has a single value at each time....
Definition space_type.h:22
static constexpr uint_t size
Definition space_type.h:38
Definition acrobot_vec_env.h:36
ScalarDiscreteSpace< 0, 3 > action_space
Definition acrobot_vec_env.h:47
static constexpr uint_t ACTION_SPACE_SIZE
state space size
Definition acrobot_vec_env.h:57
std::vector< typename action_space::space_item_type > action_type
the Action type
Definition acrobot_vec_env.h:52
state_space::space_item_type state_type
Definition acrobot_vec_env.h:40
static constexpr uint_t STATE_SPACE_SIZE
state space size
Definition acrobot_vec_env.h:45
ContinuousVectorSpace< 6, real_t > state_space
Definition acrobot_vec_env.h:38