How to use
=============
The following is an example how to use the
``FrozenLake`` environment from Gymnasium.
.. code-block::
#include "rlenvs/rlenvs_types_v2.h"
#include "rlenvs/envs/gymnasium/toy_text/frozen_lake_env.h"
#include "rlenvs/envs/api_server/apiserver.h"
#include
#include
#include
#include
namespace example_1{
const std::string SERVER_URL = "http://0.0.0.0:8001/api";
using rlenvscpp::envs::gymnasium::FrozenLake;
using rlenvscpp::envs::RESTApiServerWrapper;
void test_frozen_lake(const RESTApiServerWrapper& server){
FrozenLake<4> env(server);
std::cout<<"Environame URL: "< options;
options.insert({"is_slippery", false});
env.make("v1", options);
std::cout<<"Is environment created? "<());
std::cout<<"Reward on reset: "<`_ specification.
For more details see the ```rlenvscpp``` environment specification document.
The general use case is to build the library and link it with your driver code to access its functionality.
The environments specified as using REST in the tables above, that is all ``Gymnasium``, ``gym_pybullet_drones`` and ``GymWalk``
environments are accessed via a client/server pattern. Namely, they are exposed via an API developed using
`FastAPI `_.
You need to fire up the FastAPI server, see the dependencies, before using the environments in your code.
To do so
.. code-block::
./start_uvicorn.sh
By default the ``uvicorn`` server listents on port 8001. Change this if needed. You can access the OpenAPI specification at
.. code-block::
http://0.0.0.0:8001/docs
Note that currently the implementation is not thread/process safe i.e. if multiple threads/processes access the environment
a global instance of the environment is manipulated. Thus no session based environment exists.
However, you can create copies of the same environment and access this via its dedicate index.
If just one thread/process touches this specific environment you should be ok.
Notice that the FastAPI server only uses a single process to manage all the environments.
In addition, if you need multiple instances of the same environment you can also use one
of the exissting vectorised environments (see table above).
Finally, you can choose to launch several instances of ``uvirocrn`` (listening on different ports).
However in this case you need to implement all the interactions logic yourself as currently no implementation exists to handle such a scenario.