bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
example Namespace Reference

Classes

class  ApproxMC
 
struct  ArduinoOFFCMD
 
struct  ArduinoONCMD
 
struct  DistanceHeuristic
 
struct  Edge
 
struct  fcost_comparison
 
class  Graph
 
struct  id_comparison
 
struct  Node
 
struct  Policy
 
class  searchable_priority_queue
 
struct  Transition
 

Typedefs

typedef gymfcpp::TimeStep< uint_ttime_step_t
 
typedef std::pair< uint_t, uint_tstate_type
 
typedef boost::python::api::object obj_t
 

Functions

template<typename ItrTp , typename StateTp >
ItrTp is_state_included (ItrTp begin, ItrTp end, const StateTp &state)
 
template<typename BinType >
std::pair< uint_t, uint_tget_aggregated_state (const std::pair< real_t, real_t > &obs, const BinType &pos_bins, const BinType &vel_bins)
 
template<typename IdTp >
std::vector< IdTp > reconstruct_a_star_path (const std::multimap< IdTp, IdTp > &map, const IdTp &start)
 
bool operator== (const Node &n1, const Node &n2)
 
void test_cart_pole (RESTRLEnvClient &server)
 
void test_acrobot (RESTRLEnvClient &server)
 
void test_pendulum (RESTRLEnvClient &server)
 
void test_mountain_car (RESTRLEnvClient &server)
 

Variables

const real_t GAMMA = 1.0
 
const uint_t N_EPISODES = 20000
 
const uint_t N_ITRS_PER_EPISODE = 2000
 
const real_t TOL = 1.0e-8
 
auto pos_bins = std::vector<real_t>({-1.2, -0.95714286, -0.71428571, -0.47142857, -0.22857143, 0.01428571, 0.25714286, 0.5})
 
auto vel_bins = std::vector<real_t>({-0.07, -0.05, -0.03, -0.01, 0.01, 0.03, 0.05, 0.07})
 

Detailed Description

// Code for Arduino

#include <WiFiS3.h>

char ssid[] = "YOU-SSID"; char password[] = "YOUR-PASSWORD";

int status = WL_IDLE_STATUS; WiFiServer server(8005);

void setup() {

pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(9600); delay(1000); if (Serial.available()) { Serial.println("Connecting to WiFi..."); }

while (status != WL_CONNECTED) { Serial.print("Connecting to "); Serial.println(ssid); status = WiFi.begin(ssid, password); delay(5000); }

Serial.println("\nWiFi connected."); Serial.print("IP address: "); Serial.println(WiFi.localIP());

server.begin(); Serial.println("HTTP server started");

}

void loop() {

WiFiClient client = server.available();

if (client) { client.flush(); Serial.println("Client connected."); String request = ""; while (client.connected()) { if (client.available()) { char c = client.read(); request += c; if (c == '
' && request.endsWith("\r\n\r\n")) { break; // End of HTTP headers } } }

String body = ""; while (client.available()) { body += (char)client.read(); }

if(body == "ON"){ digitalWrite(LED_BUILTIN, HIGH); String response = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nLED is ON\n"; client.print(response); } else if(body == "OFF"){ digitalWrite(LED_BUILTIN, LOW); String response = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nLED is OFF\n"; client.print(response);

}

delay(1); client.stop(); Serial.println("Client disconnected."); } }

A* search on a road network. This example requires that the OSMNX (https://osmnx.readthedocs.io/) library is installed as well as the NetworkX (https://networkx.github.io/documentation/stable/) library. The example is taken from the Autonomous Vehicle course on Coursera

Typedef Documentation

◆ obj_t

typedef boost::python::api::object example::obj_t

◆ state_type

typedef std::pair<uint_t, uint_t> example::state_type

◆ time_step_t

typedef gymfcpp::TimeStep<uint_t> example::time_step_t

Function Documentation

◆ get_aggregated_state()

template<typename BinType >
std::pair< uint_t, uint_t > example::get_aggregated_state ( const std::pair< real_t, real_t > &  obs,
const BinType &  pos_bins,
const BinType &  vel_bins 
)

◆ is_state_included()

template<typename ItrTp , typename StateTp >
ItrTp example::is_state_included ( ItrTp  begin,
ItrTp  end,
const StateTp &  state 
)

◆ operator==()

bool example::operator== ( const Node n1,
const Node n2 
)

◆ reconstruct_a_star_path()

template<typename IdTp >
std::vector< IdTp > example::reconstruct_a_star_path ( const std::multimap< IdTp, IdTp > &  map,
const IdTp &  start 
)

◆ test_acrobot()

void example::test_acrobot ( RESTRLEnvClient server)

◆ test_cart_pole()

void example::test_cart_pole ( RESTRLEnvClient server)

◆ test_mountain_car()

void example::test_mountain_car ( RESTRLEnvClient server)

◆ test_pendulum()

void example::test_pendulum ( RESTRLEnvClient server)

Variable Documentation

◆ GAMMA

const real_t example::GAMMA = 1.0

◆ N_EPISODES

const uint_t example::N_EPISODES = 20000

◆ N_ITRS_PER_EPISODE

const uint_t example::N_ITRS_PER_EPISODE = 2000

◆ pos_bins

auto example::pos_bins = std::vector<real_t>({-1.2, -0.95714286, -0.71428571, -0.47142857, -0.22857143, 0.01428571, 0.25714286, 0.5})

◆ TOL

const real_t example::TOL = 1.0e-8

◆ vel_bins

auto example::vel_bins = std::vector<real_t>({-0.07, -0.05, -0.03, -0.01, 0.01, 0.03, 0.05, 0.07})