Skip to content

Commit d6ba714

Browse files
committed
Add parameters gui
1 parent 8240f1e commit d6ba714

File tree

14 files changed

+128
-28
lines changed

14 files changed

+128
-28
lines changed
File renamed without changes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The project depends on [SFML](https://github.com/SFML/SFML), [Dear ImGui](https:
2525

2626
## TODO
2727

28-
### Search-based planners
28+
### Graph-based planners
2929
- [x] BFS
3030
- [x] DFS
3131
- [x] DIJKSTRA

figures/img0.png

44.2 KB
Loading

include/States/Algorithms/GraphBased/BFS/BFS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class BFS : public GraphBased {
2424

2525
// override render functions
2626
virtual void renderNodes() override;
27+
virtual void renderParametersGui() override;
2728

2829
// BFS algorithm function
2930
virtual void solveConcurrently(

include/States/Algorithms/GraphBased/GraphBased.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class GraphBased : public State {
3333
void render() override;
3434

3535
// virtual functions
36+
virtual void clearObstacles();
3637
virtual void renderGui();
38+
// render planner specific parameters
39+
virtual void renderParametersGui() = 0;
3740
virtual void renderNodes() = 0;
3841
virtual void updateNodes() = 0;
3942
virtual void initAlgorithm() = 0;

include/States/Algorithms/SamplingBased/RRT/RRT.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ class RRT : public SamplingBased {
1919
// override initialization functions
2020
virtual void initialize() override;
2121
virtual void initPlanner() override;
22+
virtual void initParameters() override;
2223

2324
// override render functions
2425
virtual void renderPlannerData() override;
26+
virtual void renderParametersGui() override;
2527

2628
// override algorithm function
2729
virtual void solveConcurrently(
@@ -88,7 +90,7 @@ class RRT : public SamplingBased {
8890
/**
8991
* @brief Maximum distance allowed between two vertices
9092
*/
91-
double max_distance_;
93+
double range_;
9294

9395
/**
9496
* @brief Distance between vertex and goal

include/States/Algorithms/SamplingBased/RRT_STAR/RRT_STAR.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ class RRT_STAR : public RRT {
1616
// Destructor
1717
virtual ~RRT_STAR();
1818

19+
virtual void renderParametersGui() override;
20+
1921
// override initialization functions
2022
virtual void initialize() override;
2123
virtual void initPlanner() override;
24+
virtual void initParameters() override;
2225

2326
// override algorithm function
2427
virtual void solveConcurrently(

include/States/Algorithms/SamplingBased/SamplingBased.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SamplingBased : public State {
4646

4747
void updateUserInput();
4848
void renderObstacles();
49+
void clearObstacles();
4950
void initVariables();
5051
void updateKeyTime(const float &dt);
5152
const bool getKeyTime();
@@ -58,6 +59,9 @@ class SamplingBased : public State {
5859
// rendering function for algorithm specific
5960
virtual void renderPlannerData() = 0;
6061

62+
// render planner specific parameters
63+
virtual void renderParametersGui() = 0;
64+
6165
// initialization function
6266
// this function runs at start of the program & when user presses RESET
6367
// buttons
@@ -67,6 +71,8 @@ class SamplingBased : public State {
6771
// this function runs when user presses RUN buttons
6872
virtual void initPlanner() = 0;
6973

74+
virtual void initParameters() = 0;
75+
7076
// main algorithm function (runs in separate thread)
7177
virtual void solveConcurrently(
7278
std::shared_ptr<Vertex> start_point, std::shared_ptr<Vertex> goal_point,
@@ -99,7 +105,7 @@ class SamplingBased : public State {
99105
/**
100106
* @brief Maximum number of iterations to run the algorithm
101107
*/
102-
unsigned int max_iterations_;
108+
int max_iterations_;
103109

104110
// MessageQueue Object
105111
std::shared_ptr<MessageQueue<bool>> message_queue_;

src/Game.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void Game::render() {
8686
ImGui::End();
8787
}
8888

89-
ImGui::SFML::Render(*window_);
89+
ImGui::SFML::Render(* window_);
9090
window_->display();
9191
}
9292

@@ -95,16 +95,17 @@ void Game::initGuiTheme() {
9595

9696
style->FramePadding = ImVec2(8.f, 8.f);
9797

98-
style->Colors[ImGuiCol_Text] = ImColor(78, 95, 131, 255);
99-
style->Colors[ImGuiCol_WindowBg] = ImColor(246, 229, 245, 255);
100-
101-
style->Colors[ImGuiCol_FrameBg] = ImColor(251, 244, 249, 255);
102-
style->Colors[ImGuiCol_PopupBg] = ImColor(251, 244, 249, 255);
103-
style->Colors[ImGuiCol_Button] = ImColor(251, 244, 249, 255);
104-
style->Colors[ImGuiCol_ButtonHovered] =
105-
style->Colors[ImGuiCol_FrameBgHovered];
106-
style->Colors[ImGuiCol_ButtonActive] = style->Colors[ImGuiCol_FrameBgActive];
107-
style->Colors[ImGuiCol_SliderGrab] = ImColor(78, 95, 131, 255);
98+
// style->Colors[ImGuiCol_Text] = ImColor(78, 95, 131, 255);
99+
// style->Colors[ImGuiCol_WindowBg] = ImColor(246, 229, 245, 255);
100+
101+
// style->Colors[ImGuiCol_FrameBg] = ImColor(251, 244, 249, 255);
102+
// style->Colors[ImGuiCol_PopupBg] = ImColor(251, 244, 249, 255);
103+
// style->Colors[ImGuiCol_Button] = ImColor(251, 244, 249, 255);
104+
// style->Colors[ImGuiCol_ButtonHovered] =
105+
// style->Colors[ImGuiCol_FrameBgHovered];
106+
// style->Colors[ImGuiCol_ButtonActive] =
107+
// style->Colors[ImGuiCol_FrameBgActive]; style->Colors[ImGuiCol_SliderGrab] =
108+
// ImColor(78, 95, 131, 255);
108109
}
109110

110111
void Game::setPlanner(const int id) {

src/States/Algorithms/GraphBased/BFS/BFS.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ void BFS::renderNodes() {
106106
}
107107
}
108108

109+
void BFS::renderParametersGui() {}
110+
109111
void BFS::solveConcurrently(std::shared_ptr<Node> nodeStart,
110112
std::shared_ptr<Node> nodeEnd,
111113
std::shared_ptr<MessageQueue<bool>> message_queue) {

0 commit comments

Comments
 (0)