#include <any>
#include <iostream>
#include <string>
#include <unordered_map>
{
const std::string
SERVER_URL =
"http://0.0.0.0:8001/api";
{
<< std::endl;
GymWalk<4> env(server);
std::cout << "Is environment registered: " << server.is_env_registered(env.env_name())
<< std::endl;
std::cout << "Environment URL: " << env.get_url() << std::endl;
std::unordered_map<std::string, std::any> make_ops;
std::unordered_map<std::string, std::any> reset_ops;
reset_ops.insert({
"seed",
static_cast<uint_t>(42)});
env.make("v1", make_ops, reset_ops);
std::cout << "Environment version: " << env.version() << std::endl;
std::cout << "Environment idx is: " << env.idx() << std::endl;
std::cout << "Is environment created? " << env.is_created() << std::endl;
std::cout << "Is environment alive? " << env.is_alive() << std::endl;
std::cout << "Number of valid actions? " << env.n_actions() << std::endl;
std::cout << "Number of states? " << env.n_states() << std::endl;
auto time_step = env.reset();
std::cout << "Reward on reset: " << time_step.reward() << std::endl;
std::cout << "Observation on reset: " << time_step.observation() << std::endl;
std::cout << "Is terminal state: " << time_step.done() << std::endl;
std::cout << time_step << std::endl;
auto new_time_step = env.step(1);
std::cout << new_time_step << std::endl;
auto state = 0;
auto action = 1;
std::cout << "Dynamics for state=" << state << " and action=" << action << std::endl;
{
std::cout << std::get<0>(item) << std::endl;
std::cout << std::get<1>(item) << std::endl;
std::cout << std::get<2>(item) << std::endl;
std::cout << std::get<3>(item) << std::endl;
}
std::cout <<
"Action sampled: " <<
action << std::endl;
new_time_step =
env.step(action);
std::cout << new_time_step << std::endl;
}
}
{
std::cout << "Testing GymWalk..." << std::endl;
std::cout << "====================" << std::endl;
return 0;
}
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
bool is_env_registered(const std::string &env_name) const noexcept
static const std::string name
Definition gym_walk.h:45
int main()
Definition discounted_returns.cpp:19
Models of how things move: wheeled robots, a bicycle, a quadrotor and a fixed wing aircraft,...
Definition bicycle_vehicle_model_dynamics.cpp:10
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
Definition gym_walk.cpp:11
void test_gymwalk(RESTRLEnvClient &server)
Definition gym_walk.cpp:19
const std::string SERVER_URL
Definition gym_walk.cpp:14
dict action
Definition play.py:46