Skip to content

Commit 429988b

Browse files
committed
Fix doc CMakeLists.txt
1 parent f51c418 commit 429988b

File tree

3 files changed

+118
-32
lines changed

3 files changed

+118
-32
lines changed

doc/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ IF (NOT DOXYGEN_FOUND)
44
return()
55
ENDIF()
66

7-
8-
SET(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
9-
107
# Configure Doxyfile
118
SET(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
129
SET(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
@@ -15,37 +12,11 @@ SET(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
1512
SET(DOXYGEN_GENERATE_HTML YES)
1613
SET(DOXYGEN_GENERATE_XML NO)
1714

18-
# don't generate documentation from implementation details
19-
#SET(DOXYGEN_EXCLUDE_PATTERNS "*/extern/*")
20-
21-
# print paths relative to include directory
22-
#SET(DOXYGEN_STRIP_FROM_PATH "${PROJECT_SOURCE_DIR}/src/bitrl")
23-
2415
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
2516

26-
2717
add_custom_target(doc
2818
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
2919
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
3020
COMMENT "Generating API documentation with Doxygen..."
3121
VERBATIM
3222
)
33-
34-
# Note: use doxygen_add_docs(doxygen-doc ALL ...) if you want your documentation
35-
# to be created by default each time you build. Without the keyword you need to
36-
# explicitly invoke building of the 'doc' target.
37-
#doxygen_add_docs(doxygen-doc ${PROJECT_SOURCE_DIR}/src/bitrl COMMENT "Generating API documentation with Doxygen")
38-
#
39-
#
40-
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in
41-
# ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
42-
#
43-
#add_custom_target(
44-
# sphinx-doc ALL
45-
# COMMAND ${SPHINX_EXECUTABLE} -b html -c ${CMAKE_CURRENT_BINARY_DIR}
46-
# ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
47-
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
48-
# COMMENT "Generating API documentation with Sphinx"
49-
# VERBATIM)
50-
#
51-
#add_dependencies(sphinx-doc doxygen-doc)

doc/Doxyfile.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#---------------------------------------------------------------------------
22

33
PROJECT_NAME = "@PROJECT_NAME@"
4-
OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIR@"
4+
OUTPUT_DIRECTORY = @PROJECT_SOURCE_DIR@/docs
55
GENERATE_LATEX = NO
66
RECURSIVE = YES
77

88
# Adjust to your source path(s)
9-
INPUT = @PROJECT_SOURCE_DIR@/src/bitrl
9+
INPUT = @PROJECT_SOURCE_DIR@/src/bitrl @PROJECT_SOURCE_DIR@/doc
1010

11-
FILE_PATTERNS = *.h *.hpp *.cpp
11+
FILE_PATTERNS = *.h *.hpp *.cpp *.md
1212

1313
GENERATE_HTML = YES
1414
HTML_OUTPUT = .
15+
# Use a Markdown file as the main page
16+
USE_MDFILE_AS_MAINPAGE = @PROJECT_SOURCE_DIR@/doc/index.md
1517

1618
EXTRACT_ALL = YES
1719
EXCLUDE = @PROJECT_SOURCE_DIR@/src/bitrl/extern

doc/index.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# bitrl
2+
3+
```bitrl``` is an effort to provide implementations and wrappers of environments suitable for training reinforcement learning agents
4+
using C++.
5+
6+
Furthermore, there is some minimal support for working with Arduino UNO boards over USB or WiFi.
7+
See also <a href="https://rlenvscpp.readthedocs.io/en/latest/working_with_webots.html">Working with Webots</a>
8+
for how to integrate ```bitrl``` with <a href="https://cyberbotics.com/doc/guide/installing-webots">Webots</a>.
9+
10+
Various RL algorithms using the environments can be found at <a href="https://github.com/pockerman/cuberl/tree/master">cuberl</a>.
11+
12+
The documentation for the library can be found <a href="https://rlenvscpp.readthedocs.io/en/latest/">here</a>.
13+
The following is an example how to use the
14+
``FrozenLake`` environment from <a href="https://github.com/Farama-Foundation/Gymnasium/tree/main">Gymnasium</a>.
15+
16+
```
17+
18+
#include "bitrl/bitrl_types.h"
19+
#include "bitrl/envs/gymnasium/toy_text/frozen_lake_env.h"
20+
#include "bitrl/envs/api_server/apiserver.h"
21+
22+
#include <iostream>
23+
#include <string>
24+
#include <unordered_map>
25+
#include <any>
26+
27+
namespace example_1{
28+
29+
const std::string SERVER_URL = "http://0.0.0.0:8001/api";
30+
31+
using bitrl::envs::gymnasium::FrozenLake;
32+
using bitrl::envs::gymnasium::Taxi;
33+
using bitrl::envs::gymnasium::BlackJack;
34+
using bitrl::envs::gymnasium::CliffWorld;
35+
using bitrl::envs::RESTApiServerWrapper;
36+
37+
38+
void test_frozen_lake(const RESTApiServerWrapper& server){
39+
40+
FrozenLake<4> env(server);
41+
42+
std::cout<<"Environame URL: "<<env.get_url()<<std::endl;
43+
44+
// make the environment
45+
std::unordered_map<std::string, std::any> options;
46+
options.insert({"is_slippery", false});
47+
env.make("v1", options);
48+
49+
std::cout<<"Is environment created? "<<env.is_created()<<std::endl;
50+
std::cout<<"Is environment alive? "<<env.is_alive()<<std::endl;
51+
std::cout<<"Number of valid actions? "<<env.n_actions()<<std::endl;
52+
std::cout<<"Number of states? "<<env.n_states()<<std::endl;
53+
54+
// reset the environment
55+
auto time_step = env.reset(42, std::unordered_map<std::string, std::any>());
56+
57+
std::cout<<"Reward on reset: "<<time_step.reward()<<std::endl;
58+
std::cout<<"Observation on reset: "<<time_step.observation()<<std::endl;
59+
std::cout<<"Is terminal state: "<<time_step.done()<<std::endl;
60+
61+
//...print the time_step
62+
std::cout<<time_step<<std::endl;
63+
64+
// take an action in the environment
65+
// 2 = RIGHT
66+
auto new_time_step = env.step(2);
67+
68+
std::cout<<new_time_step<<std::endl;
69+
70+
// get the dynamics of the environment for the given state and action
71+
auto state = 0;
72+
auto action = 1;
73+
auto dynamics = env.p(state, action);
74+
75+
std::cout<<"Dynamics for state="<<state<<" and action="<<action<<std::endl;
76+
77+
for(auto item:dynamics){
78+
79+
std::cout<<std::get<0>(item)<<std::endl;
80+
std::cout<<std::get<1>(item)<<std::endl;
81+
std::cout<<std::get<2>(item)<<std::endl;
82+
std::cout<<std::get<3>(item)<<std::endl;
83+
}
84+
85+
action = env.sample_action();
86+
std::cout<<"Action sampled: "<<action<<std::endl;
87+
88+
new_time_step = env.step(action);
89+
std::cout<<new_time_step<<std::endl;
90+
91+
std::cout<<"env cidx: "<<env.cidx()<<std::endl;
92+
93+
// close the environment
94+
env.close();
95+
}
96+
97+
}
98+
99+
100+
int main(){
101+
102+
using namespace example_1;
103+
104+
RESTApiServerWrapper server(SERVER_URL, true);
105+
106+
std::cout<<"Testing FrozenLake..."<<std::endl;
107+
example_1::test_frozen_lake(server);
108+
std::cout<<"===================="<<std::endl;
109+
110+
return 0;
111+
}
112+
113+
```

0 commit comments

Comments
 (0)