bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
acrobot_env.h
Go to the documentation of this file.
1#ifndef ACROBOT_ENV_H
2#define ACROBOT_ENV_H
3
7
130
132#include "bitrl/envs/env_types.h"
134#include "bitrl/envs/time_step.h"
136#include "bitsim/extern/nlohmann/json/json.hpp"
137
138#include <any>
139#include <string>
140#include <tuple>
141#include <vector>
142
143namespace bitrl
144{
145namespace envs::gymnasium
146{
147
151class Acrobot final
152 : public GymnasiumEnvBase<TimeStep<std::vector<real_t>>,
153 ContinuousVectorStateDiscreteActionEnv<6, 2, 0, real_t>>
154{
155
156 public:
160 static const std::string name;
161
165 static const std::string URI;
166
171 ContinuousVectorStateDiscreteActionEnv<6, // size of state space
172 2, // end of action space
173 0, // start of action space
174 real_t> // type of state
181
186
191
196
201
203
204 Acrobot(const Acrobot &other);
205
206 ~Acrobot() override = default;
207
214 virtual void
215 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
216 const std::unordered_map<std::string, std::any> &reset_options) override final;
217
222 virtual time_step_type step(const action_type &action) override final;
223
227 uint_t n_actions() const noexcept { return action_space_type::size; }
228
229 protected:
233 virtual time_step_type
234 create_time_step_from_response_(const nlohmann::json &response) const override final;
235};
236
237} // namespace envs::gymnasium
238} // namespace bitrl
239
240#endif // PENDULUM_ENV_H
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
GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >::base_type base_type
Base class type.
Definition acrobot_env.h:175
Acrobot(network::RESTRLEnvClient &api_server)
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
base_type::state_type state_type
The type of the state.
Definition acrobot_env.h:200
virtual time_step_type step(const action_type &action) override final
step. Step in the environment following the given action.
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition acrobot_env.h:185
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition acrobot_env.h:195
Acrobot(const Acrobot &other)
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition acrobot_env.h:190
static const std::string URI
The URI for accessing the environment.
Definition acrobot_env.h:165
static const std::string name
The name of the environment.
Definition acrobot_env.h:160
virtual void make(const std::string &version, const std::unordered_map< std::string, std::any > &options, 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_env.h:180
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition acrobot_env.h:227
GymnasiumEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Definition gymnasium_env_base.h:139
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
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
double real_t
real_t
Definition bitsim_types.h:20