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

The Pendulum class. Interface for Pendulum environment. More...

#include <pendulum_env.h>

Inheritance diagram for bitrl::envs::gymnasium::Pendulum:
Collaboration diagram for bitrl::envs::gymnasium::Pendulum:

Public Types

typedef GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >::base_type base_type
 Base class type.
typedef base_type::time_step_type time_step_type
 The time step type we return every time a step in the environment is performed.
typedef base_type::state_space_type state_space_type
 The type describing the state space for the environment.
typedef base_type::action_space_type action_space_type
 The type of the action space for the environment.
typedef base_type::action_type action_type
 The type of the action to be undertaken in the environment.
typedef base_type::state_type state_type
 The type of the state.
Public Types inherited from bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
typedef EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > > base_type
 Base environment type alias.
typedef base_type::time_step_type time_step_type
 Time step returned at each environment step.
typedef base_type::state_space_type state_space_type
 Type describing the observation/state space of the environment.
typedef base_type::action_space_type action_space_type
 Type describing the action space of the environment.
typedef base_type::action_type action_type
 Type representing a valid action to execute.
typedef base_type::state_type state_type
 Type representing a state/observation returned by the environment.
Public Types inherited from bitrl::envs::EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
typedef TimeStep< std::vector< real_t > > time_step_type
 Alias for the type returned when stepping the environment.
typedef ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >::state_space state_space_type
 Type describing the environment state space.
typedef ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >::state_type state_type
 Type describing an individual state.
typedef ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >::action_space action_space_type
 Type describing the environment action space.
typedef ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >::action_type action_type
 Type representing an individual action.
Public Types inherited from bitrl::envs::ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >
typedef ContinuousVectorSpace< StateSpaceSize, real_t > state_space
 The type of the state space.
typedef state_space::space_item_type state_type
 the State type
typedef ScalarDiscreteSpace< action_start, action_end > action_space
 item_t
typedef RealRange<-2.0, 2.0 >::value_type action_type
 the Action type is real valued

Public Member Functions

 Pendulum (network::RESTRLEnvClient &api_server)
 Pendulum. Constructor.
 Pendulum (const Pendulum &other)
 copy ctor
 ~Pendulum () override=default
 ~Pendulum. Destructor
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
virtual time_step_type step (const action_type &action) override final
 step. Step in the environment following the given action
uint_t n_actions () const noexcept
 n_actions. Returns the number of actions
Public Member Functions inherited from bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
virtual ~GymnasiumEnvBase ()
 Virtual destructor.
virtual bool is_alive () const
 Check whether the environment is still alive/connected.
virtual void close () override
 Close the environment on the server and release any resources.
virtual time_step_type reset () override
 Reset the environment to an initial state using the reset options specified during make.
uint_t n_copies () const
network::RESTRLEnvClient & get_api_server () const
 Retrieve the REST API wrapper instance used for communication.
std::string get_url () const
 Get the full URL for this environment endpoint on the server.
Public Member Functions inherited from bitrl::envs::EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
virtual ~EnvBase ()=default
 Virtual destructor.
virtual time_step_type step (const action_type &action)=0
 Perform one step in the environment using an action.
const std::unordered_map< std::string, std::any > & make_options () const noexcept
 Access the configuration options provided to make().
const std::unordered_map< std::string, std::any > & reset_options () const noexcept
 Access the configuration options provided to make().
T read_option (const std::string &op_name) const
 Read a specific make() option and cast it to the requested type.
std::string idx () const noexcept
 Get the id identifying this environment within a simulation batch. The id is valid only if make has been called.
bool is_created () const noexcept
 Check if make() has successfully initialized the environment.
std::string env_name () const noexcept
 Get the name of this environment instance.
std::string version () const noexcept
 Get the environment version set during make().
uint_t last_reset_seed () const noexcept
 The seed of the latest reset(), for the environments that take one. The first reset after make() uses the "seed" reset option, or DEFAULT_ENV_SEED, and every reset after it the next seed, so that the episodes start differently and a run is the same every time.

Static Public Attributes

static const std::string name
 name
static const std::string URI
 The URI for accessing the environment.
Static Public Attributes inherited from bitrl::envs::EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
static constexpr uint_t DEFAULT_ENV_SEED
 Default seed used in reset() if none provided.
Static Public Attributes inherited from bitrl::envs::ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t >
static constexpr uint_t STATE_SPACE_SIZE
 state space size
static constexpr RealRange<-2.0, 2.0 > action_limits
 the action limits
static constexpr uint_t ACTION_SPACE_SIZE
 action space size

Protected Member Functions

virtual time_step_type create_time_step_from_response_ (const nlohmann::json &response) const override final
 Handle the reset response from the environment server.
Protected Member Functions inherited from bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
 GymnasiumEnvBase (network::RESTRLEnvClient &api_server, const std::string &name)
 Constructor.
Protected Member Functions inherited from bitrl::envs::EnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
 EnvBase (const std::string &idx=bitsim::consts::INVALID_STR, const std::string &name=bitsim::consts::INVALID_STR)
 Constructor (protected — for subclassing only).
void set_version_ (const std::string &version) noexcept
 Set internal version string.
void set_idx_ (const std::string &idx) noexcept
 Set the id of the environment.
void set_make_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store options for future access.
void set_reset_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store reset options for future access.
uint_t next_reset_seed_ ()
 The seed for the next reset: the "seed" reset option, or DEFAULT_ENV_SEED, plus the number of resets since make().
void invalidate_is_created_flag_ () noexcept
 Mark environment as not created.
void make_created_ () noexcept
 Mark environment creation as successful.
time_step_type & get_current_time_step_ () noexcept
 Mutable access to the current time step.

Additional Inherited Members

Protected Attributes inherited from bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >
network::RESTRLEnvClient * api_server_
 Server wrapper handling communication with remote Gymnasium environment.

Detailed Description

The Pendulum class. Interface for Pendulum environment.

Member Typedef Documentation

◆ action_space_type

The type of the action space for the environment.

◆ action_type

The type of the action to be undertaken in the environment.

◆ base_type

◆ state_space_type

The type describing the state space for the environment.

◆ state_type

◆ time_step_type

The time step type we return every time a step in the environment is performed.

Constructor & Destructor Documentation

◆ Pendulum() [1/2]

bitrl::envs::gymnasium::Pendulum::Pendulum ( network::RESTRLEnvClient & api_server)

Pendulum. Constructor.

◆ Pendulum() [2/2]

bitrl::envs::gymnasium::Pendulum::Pendulum ( const Pendulum & other)

copy ctor

◆ ~Pendulum()

bitrl::envs::gymnasium::Pendulum::~Pendulum ( )
overridedefault

~Pendulum. Destructor

Member Function Documentation

◆ create_time_step_from_response_()

virtual time_step_type bitrl::envs::gymnasium::Pendulum::create_time_step_from_response_ ( const nlohmann::json & response) const
finaloverrideprotectedvirtual

◆ make()

virtual void bitrl::envs::gymnasium::Pendulum::make ( const std::string & version,
const std::unordered_map< std::string, std::any > & ,
const std::unordered_map< std::string, std::any > & reset_options )
finaloverridevirtual

◆ n_actions()

uint_t bitrl::envs::gymnasium::Pendulum::n_actions ( ) const
inlinenoexcept

n_actions. Returns the number of actions

◆ step()

virtual time_step_type bitrl::envs::gymnasium::Pendulum::step ( const action_type & action)
finaloverridevirtual

step. Step in the environment following the given action

Member Data Documentation

◆ name

const std::string bitrl::envs::gymnasium::Pendulum::name
static

name

◆ URI

const std::string bitrl::envs::gymnasium::Pendulum::URI
static

The URI for accessing the environment.


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