#include "../include/imgui/imgui.h"
#include "../include/imgui/backends/imgui_impl_glfw.h"
#include "../include/imgui/backends/imgui_impl_opengl3.h"
#include <GLFW/glfw3.h>
#include "Pose2D.hpp"
#include "Node.hpp"
#include "Pillar.hpp"
#include "Hole.hpp"
#include "Field.hpp"
#include <vector>
#include <netinet/in.h>
#include <chrono>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <fstream>
#include <iostream>
#include <thread>
#include <queue>
#include <condition_variable>
#include <atomic>
#include <sstream>
Go to the source code of this file.
|
| std::atomic< bool > | stopClient (false) |
| |
| void | addToQueue (const std::string &message) |
| |
| void | sendAngleToQueue (int16_t angle) |
| |
| void | sendDistanceToQueue (uint16_t distance) |
| |
| void | pathToRoutine (std::vector< Pose2D > path, std::vector< Move > &routine) |
| |
| std::string | parsePathIntoRoutine (const std::vector< Pose2D > &path) |
| |
| void | readAndLog (int socket, std::mutex &fieldMutex, Field &field, std::vector< Pose2D > &path) |
| |
| void | connectTCP (Field &field, std::mutex &fieldMutex, std::vector< Pose2D > &path) |
| |
| void | setupImGui (GLFWwindow *window) |
| |
| void | DrawCircle (ImDrawList *drawList, const ImVec2 ¢er, float radius, ImU32 color) |
| |
| Pose2D | ScreenToCoords (ImVec2 coords, ImVec2 offset, ImVec2 scaling) |
| |
| ImVec2 | coordsToScreen (ImVec2 offset, ImVec2 scaling, double x, double y) |
| |
| ImVec2 | coordsToScreen (ImVec2 offset, ImVec2 scaling, const Pose2D &position) |
| |
| void | ShowPillarOnWindow (ImDrawList *drawList, Pillar pillar, ImU32 color, ImVec2 offset, ImVec2 scaling) |
| |
| void | drawBotPose (ImDrawList *drawList, const Pose2D &botPose, ImVec2 offset, ImVec2 scaling) |
| |
| void | drawRectangle (ImDrawList *drawList, ImVec2 offset, ImVec2 scaling, const Pose2D &p1, const Pose2D &p2) |
| |
| void | ShowFieldWindow (std::mutex *pillarsMutex, std::vector< Pose2D > &path, Field &field, std::atomic< bool > &showNodes, std::atomic< bool > &showEdges) |
| |
| int | main () |
| |
◆ ADDRESS
| #define ADDRESS "127.0.0.1" |
◆ BOT_CONNECT
◆ PORT
◆ MovementType
| Enumerator |
|---|
| MOVE_FORWARD | |
| MOVE_BACKWARDS | |
| MOVE_FORWARD_SMART | |
| TURN_TO_ANGLE | |
| SCAN | |
Definition at line 33 of file main.cpp.
◆ addToQueue()
| void addToQueue |
( |
const std::string & | message | ) |
|
Add a given string to the thread safe queue, accessed with mutexes
- Parameters
-
| message | the message to add |
Definition at line 56 of file main.cpp.
◆ connectTCP()
| void connectTCP |
( |
Field & | field, |
|
|
std::mutex & | fieldMutex, |
|
|
std::vector< Pose2D > & | path ) |
connect to Roomba TCP server or the mock server depending on the configuration
- Parameters
-
| field | reference to the field object |
| fieldMutex | the mutex for the field |
| path | reference to a generated path |
Definition at line 291 of file main.cpp.
◆ coordsToScreen() [1/2]
| ImVec2 coordsToScreen |
( |
ImVec2 | offset, |
|
|
ImVec2 | scaling, |
|
|
const Pose2D & | position ) |
Computes screen coordinates from Field coordinates
- Parameters
-
| offset | the offset the window measuring on is at |
| scaling | the amount to scale by |
| position | the position be transformed |
- Returns
- the new screen coordinates
Definition at line 396 of file main.cpp.
◆ coordsToScreen() [2/2]
| ImVec2 coordsToScreen |
( |
ImVec2 | offset, |
|
|
ImVec2 | scaling, |
|
|
double | x, |
|
|
double | y ) |
Computes screen coordinates from Field coordinates
- Parameters
-
| offset | the offset the window measuring on is at |
| scaling | the amount to scale by |
| x | the x component of the pose 2d |
| y | the y component of the pose 2d |
- Returns
- the new screen coordinates
Definition at line 383 of file main.cpp.
◆ drawBotPose()
| void drawBotPose |
( |
ImDrawList * | drawList, |
|
|
const Pose2D & | botPose, |
|
|
ImVec2 | offset, |
|
|
ImVec2 | scaling ) |
Draws a triangle on the bot position facing in the direction that the bot is. The color of the triangle will be lime green.
- Parameters
-
| drawList | the draw list for the window |
| botPose | the position of the bot |
| offset | the offset of the screen for cartesian coordinates |
Definition at line 423 of file main.cpp.
◆ DrawCircle()
| void DrawCircle |
( |
ImDrawList * | drawList, |
|
|
const ImVec2 & | center, |
|
|
float | radius, |
|
|
ImU32 | color ) |
Draw a circle on the window
- Parameters
-
| drawList | the drawlist for a given window |
| center | the center position of the circle |
| radius | the radus of the circle |
| color | the color of the circle on the screen |
Definition at line 357 of file main.cpp.
◆ drawRectangle()
| void drawRectangle |
( |
ImDrawList * | drawList, |
|
|
ImVec2 | offset, |
|
|
ImVec2 | scaling, |
|
|
const Pose2D & | p1, |
|
|
const Pose2D & | p2 ) |
Draw a rectangle on the field given by the critical points p1 and p2
- Parameters
-
| drawList | the draw list for the window to draw on |
| offset | the offset of the window |
| scaling | the size scaling |
| p1 | point one |
| p2 | point two (opposite corner) |
Definition at line 450 of file main.cpp.
◆ main()
The main function where the program starts
- Returns
- status code of how the program executed
Definition at line 572 of file main.cpp.
◆ parsePathIntoRoutine()
| std::string parsePathIntoRoutine |
( |
const std::vector< Pose2D > & | path | ) |
|
parse a path into a routine
- Parameters
-
- Returns
- the routine from the path
Definition at line 114 of file main.cpp.
◆ pathToRoutine()
| void pathToRoutine |
( |
std::vector< Pose2D > | path, |
|
|
std::vector< Move > & | routine ) |
generate a routine from a path
- Parameters
-
| path | the path to generate a routine from |
| routine | the routine to store into |
Definition at line 90 of file main.cpp.
◆ readAndLog()
| void readAndLog |
( |
int | socket, |
|
|
std::mutex & | fieldMutex, |
|
|
Field & | field, |
|
|
std::vector< Pose2D > & | path ) |
Read and log data that gets sent over the TCP socket
- Parameters
-
| socket | the socket to listen on |
| fieldMutex | the mutex for the field object |
| field | reference to the field object |
| path | the path to generate |
Definition at line 142 of file main.cpp.
◆ ScreenToCoords()
| Pose2D ScreenToCoords |
( |
ImVec2 | coords, |
|
|
ImVec2 | offset, |
|
|
ImVec2 | scaling ) |
Computes a Pose2D from given screen coordinates
- Parameters
-
| coords | the coordinates on the window |
| offset | the offset of the position of the window on the screen |
| scaling | the scaling factor for the window size |
- Returns
Definition at line 368 of file main.cpp.
◆ sendAngleToQueue()
| void sendAngleToQueue |
( |
int16_t | angle | ) |
|
- Parameters
-
Definition at line 68 of file main.cpp.
◆ sendDistanceToQueue()
| void sendDistanceToQueue |
( |
uint16_t | distance | ) |
|
Adds an distance to a queue to be sent to the bot
- Parameters
-
| distance | the distance to send |
Definition at line 79 of file main.cpp.
◆ setupImGui()
| void setupImGui |
( |
GLFWwindow * | window | ) |
|
Simple function to set up OpenGL and ImGui context
- Parameters
-
| window | pointer to the GLFW window |
Definition at line 341 of file main.cpp.
◆ ShowFieldWindow()
| void ShowFieldWindow |
( |
std::mutex * | pillarsMutex, |
|
|
std::vector< Pose2D > & | path, |
|
|
Field & | field, |
|
|
std::atomic< bool > & | showNodes, |
|
|
std::atomic< bool > & | showEdges ) |
Show the field window on a new window
- Parameters
-
| pillarsMutex | the mutex for pillars |
| path | the path to display |
| field | the field object |
| showNodes | whether to show nodes or not (atomic reference) |
| showEdges | whether to show edges of the graph or not (atmoic reference) |
Definition at line 479 of file main.cpp.
◆ ShowPillarOnWindow()
| void ShowPillarOnWindow |
( |
ImDrawList * | drawList, |
|
|
Pillar | pillar, |
|
|
ImU32 | color, |
|
|
ImVec2 | offset, |
|
|
ImVec2 | scaling ) |
Show a given pillar on the window.
- Parameters
-
| drawList | the window to draw a pillar (circle) on |
| pillar | the pillar which stores the given position and radius |
| color | the color to draw it as |
| offset | the offset of the window |
| scaling | the sizing ration for the window |
Definition at line 408 of file main.cpp.
◆ stopClient()
| std::atomic< bool > stopClient |
( |
false | | ) |
|
◆ queueMutex
◆ sendCondition
| std::condition_variable sendCondition |
◆ sendQueue
| std::queue<std::string> sendQueue |