Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Feature/remove interface #1204

Draft
wants to merge 41 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3893533
Refactor Playdecider to be less static
rolfvdhulst Feb 15, 2021
1994784
remove IOManager global
rolfvdhulst Feb 22, 2021
3a565bd
Remove interface input visualizations
rolfvdhulst Feb 22, 2021
ab85b4e
Remove ruleset widget
rolfvdhulst Feb 22, 2021
c7046c5
Remove playswidget
rolfvdhulst Feb 22, 2021
0103d93
Remove stp visualization widget
rolfvdhulst Feb 22, 2021
ef01485
Remove robotswidget
rolfvdhulst Feb 22, 2021
9ded68d
Remove toggles and visualization settings
rolfvdhulst Feb 22, 2021
447e051
fix outdated appmanager constructor
rolfvdhulst Feb 22, 2021
cd24d6f
Remove visualization widget
rolfvdhulst Feb 24, 2021
5d262bc
Remove unused statics
rolfvdhulst Feb 24, 2021
97fe252
Remove PID boxes
rolfvdhulst Feb 24, 2021
6e4365b
Remove pid set functions
rolfvdhulst Feb 24, 2021
016ceab
Remove pid set functions
rolfvdhulst Feb 24, 2021
5a562b9
remove menu
rolfvdhulst Mar 7, 2021
a0904fa
remove marker
rolfvdhulst Mar 7, 2021
d7ea936
Remove timeout at top
rolfvdhulst Mar 7, 2021
4cabe2d
Start removing settings global
rolfvdhulst Mar 7, 2021
ac299f0
More changes, refactoring settings
rolfvdhulst Mar 29, 2021
0983749
move more things to the AI
rolfvdhulst Apr 7, 2021
7c34df6
Remove Output
rolfvdhulst Apr 7, 2021
acf8e89
Add initial button declarations
rolfvdhulst Apr 22, 2021
d94525a
Send ai button declarations as well
rolfvdhulst Apr 25, 2021
58ba2a6
Add application settings functions
rolfvdhulst Apr 28, 2021
0f518e8
More error checking
rolfvdhulst Apr 28, 2021
f6fd954
Finalize sending all settings to central server
rolfvdhulst Apr 28, 2021
402e633
Testing, only send declarations
rolfvdhulst Apr 29, 2021
edefc93
Merge branch 'development' into feature/remove_interface
daw1012345 Aug 4, 2021
9aeff23
Fix merge errors and get it to compile
daw1012345 Aug 5, 2021
8250f83
Gut Qt5 out of AI for good
daw1012345 Aug 7, 2021
7694cc9
Lay out basic structure of a more versatile basic interface and begin…
daw1012345 Aug 10, 2021
f932cfc
Implement data structures for the interface
daw1012345 Aug 15, 2021
b3b6a5d
Fix compilation errors and finish basic implementation
daw1012345 Aug 17, 2021
6adfc60
Move shared interface components to roboteam_interface and test json …
daw1012345 Aug 18, 2021
aebe172
Load interface declarations from JSON file
daw1012345 Aug 19, 2021
3c8c919
Add test interface declarations
daw1012345 Aug 30, 2021
626924b
Modify controller to only register changes in declarations since we a…
daw1012345 Sep 13, 2021
9502dec
Only send settings when declarations changed
daw1012345 Sep 13, 2021
f8afb9d
* Remove incorrect error message that was kept after refactoring an i…
daw1012345 Sep 14, 2021
ab32e34
* Fix AI SIGSEGV when roboteam_observer is not running
daw1012345 Sep 15, 2021
59fafbb
* Add basic interface rendeding capability
daw1012345 Dec 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ find_package(Qt5Widgets REQUIRED)
set(UTILS_SOURCES
${PROJECT_SOURCE_DIR}/src/utilities/GameStateManager.cpp
${PROJECT_SOURCE_DIR}/src/utilities/Constants.cpp
${PROJECT_SOURCE_DIR}/src/utilities/Pause.cpp
${PROJECT_SOURCE_DIR}/src/utilities/RefGameState.cpp
${PROJECT_SOURCE_DIR}/src/utilities/Dealer.cpp
${PROJECT_SOURCE_DIR}/src/utilities/IOManager.cpp
${PROJECT_SOURCE_DIR}/src/utilities/Settings.cpp
${PROJECT_SOURCE_DIR}/src/utilities/StrategyManager.cpp
)

Expand Down Expand Up @@ -203,35 +201,11 @@ set(TEST_SOURCES

set(INTERFACE_SOURCES
${PROJECT_SOURCE_DIR}/src/interface/widgets/mainWindow.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/widget.cpp
${PROJECT_SOURCE_DIR}/src/interface/api/Input.cpp
${PROJECT_SOURCE_DIR}/src/interface/api/Output.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/STPVisualizerWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/RobotsWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/PidBox.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/PidsWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/MainControlsWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/VisualizationSettingsWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/api/Toggles.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/RuleSetWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/GraphWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/SettingsWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/ManualControlWidget.cpp
${PROJECT_SOURCE_DIR}/src/interface/widgets/PlaysWidget.cpp

#QT wants to know about these headers
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/PidBox.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/PidsWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/MainControlsWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/mainWindow.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/RobotsWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/RuleSetWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/STPVisualizerWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/VisualizationSettingsWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/widget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/SettingsWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/ManualControlWidget.h
${PROJECT_SOURCE_DIR}/include/roboteam_ai/interface/widgets/PlaysWidget.hpp
)

set(WORLD_SOURCES
Expand All @@ -249,6 +223,7 @@ set(WORLD_SOURCES
# Putting it all together so we can use it in both the main executable and the test executable
set(AI_SOURCES
${PROJECT_SOURCE_DIR}/src/ApplicationManager.cpp
src/AI.cpp
${UTILS_SOURCES}
${SKILLS_SOURCES}
${TACTICS_SOURCES}
Expand All @@ -259,6 +234,8 @@ set(AI_SOURCES
${INTERFACE_SOURCES}
${WORLD_SOURCES}
${MANUAL_SOURCES}
src/AISettings.cpp
src/AppSettings.cpp
)

set(AI_LIBS
Expand Down
56 changes: 56 additions & 0 deletions include/roboteam_ai/AI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Created by rolf on 15-02-21.
//

#ifndef RTT_ROBOTEAM_AI_SRC_AI_H_
#define RTT_ROBOTEAM_AI_SRC_AI_H_

#include "stp/PlayChecker.hpp"
#include "stp/PlayDecider.hpp"
#include "AISettings.h"
#include "world/World.hpp"
#include <roboteam_proto/State.pb.h>
#include <roboteam_proto/AICommand.pb.h>
#include "control/ControlModule.h"

namespace rtt {
class AI {
public:
explicit AI(int id);

void updateState(const proto::State& state);
proto::AICommand decidePlay();
[[nodiscard]] proto::Handshake getButtonDeclarations() const;
[[nodiscard]] proto::Handshake getSettingValues() const;
void updateSettings(const proto::UiValues& values);
private:
//updates referee-related information to the game state manager, and makes sure things such as rotation, color etc. are correct
void updateSettingsReferee(const proto::State& state);

void onSideOrColorChanged();
std::unique_ptr<world::World> world = nullptr;
/**
* Current best play as picked by checker + decider
*/
rtt::ai::stp::Play *currentPlay{nullptr};

/**
* Checks which plays are valid out of all the plays
*/
rtt::ai::stp::PlayChecker playChecker;
/**
* Checks, out of the valid plays, which play is the best to choose
*/
rtt::ai::stp::PlayDecider playDecider;

/**
* The vector that contains all plays
*/
std::vector<std::unique_ptr<rtt::ai::stp::Play>> plays;

AISettings settings;

//std::unique_ptr<ai::control::ControlModule> control_module; TODO: fix staticness
};
}
#endif //RTT_ROBOTEAM_AI_SRC_AI_H_
45 changes: 45 additions & 0 deletions include/roboteam_ai/AISettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Created by rolf on 07-03-21.
//

#ifndef RTT_ROBOTEAM_AI_SRC_AISETTINGS_H_
#define RTT_ROBOTEAM_AI_SRC_AISETTINGS_H_

#include <string>
#include <roboteam_proto/Handshake.pb.h>
namespace rtt {
class AISettings {
public:
explicit AISettings(int id);


[[nodiscard]] int getId() const;

[[nodiscard]] bool isYellow() const;
void setYellow(bool isYellow);

[[nodiscard]] bool isLeft() const;
void setLeft(bool left);

[[nodiscard]] bool isPaused() const;
void setPause(bool paused);

[[nodiscard]] bool getListenToReferee() const;
void setListenToReferee(bool listen);

[[nodiscard]] proto::Handshake getButtonDeclarations() const;
[[nodiscard]] proto::Handshake getValues() const;
void updateValuesFromInterface(const proto::UiValues& values);
private:
[[nodiscard]] std::string name() const;

const int id;
bool is_yellow;
bool is_left;

bool is_paused;
bool listenToReferee;

};
}
#endif //RTT_ROBOTEAM_AI_SRC_AISETTINGS_H_
52 changes: 52 additions & 0 deletions include/roboteam_ai/AppSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Created by rolf on 07-03-21.
//

#ifndef RTT_ROBOTEAM_AI_SRC_APPSETTINGS_H_
#define RTT_ROBOTEAM_AI_SRC_APPSETTINGS_H_
#include <string>
#include <roboteam_proto/Setting.pb.h>
#include <roboteam_proto/ObserverSettings.pb.h>
#include <roboteam_proto/RobotHubSettings.pb.h>
#include <roboteam_proto/Handshake.pb.h>
enum class SerialMode{
GRSIM = 0,
SERIAL = 1
};

static std::string serialModeName(SerialMode type);
class AppSettings {
public:
AppSettings();
[[nodiscard]] const std::string& getRefereeIp() const;
void setRefereeIp(const std::string& refereeIp);

[[nodiscard]] int getRefereePort() const;
void setRefereePort(int port);

[[nodiscard]] const std::string& getVisionIp() const;
void setVisionIp(const std::string& vision_ip);

[[nodiscard]] int getVisionPort() const;
void setVisionPort(int port);

[[nodiscard]] proto::Handshake getButtonDeclarations() const;
[[nodiscard]] proto::Handshake getValues() const;
void updateValuesFromInterface(const proto::UiValues& values);

[[nodiscard]] proto::Setting toMessage() const;
[[nodiscard]] proto::ObserverSettings obsMessage() const;
[[nodiscard]] proto::RobotHubSettings rhMessage() const;
private:
std::string referee_ip;
int referee_port;

std::string vision_ip;
int vision_port;

std::string robothub_ip;
int robothub_port;
SerialMode mode;
};

#endif //RTT_ROBOTEAM_AI_SRC_APPSETTINGS_H_
40 changes: 9 additions & 31 deletions include/roboteam_ai/ApplicationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,29 @@
#include <gtest/gtest_prod.h>

#include "interface/widgets/mainWindow.h"
#include "stp/PlayChecker.hpp"
#include "stp/PlayDecider.hpp"
#include "AI.h"
#include "utilities/IOManager.h"
#include "AppSettings.h"

namespace rtt {

class ApplicationManager {
public:
explicit ApplicationManager(ai::interface::MainWindow* mainWindow);

private:
FRIEND_TEST(ApplicationManagerTest, it_handles_ROS_data);

void runOneLoopCycle();
bool fieldInitialized = false;
bool robotsInitialized = false;
ai::interface::MainWindow* mainWindow;

/**
* Current best play as picked by checker + decider
*/
ai::stp::Play* currentPlay{nullptr};

/**
* Checks which plays are valid out of all the plays
*/
rtt::ai::stp::PlayChecker playChecker;
/**
* Checks, out of the valid plays, which play is the best to choose
*/
rtt::ai::stp::PlayDecider playDecider;
/**
* Function that decides whether to change plays given a world and field.
* @param _world the current world state
* @param field the current field state
*/
void decidePlay(world::World* _world);

public:
void start();
AppSettings settings;
std::unique_ptr<AI> ai;
std::unique_ptr<rtt::ai::io::IOManager> io;

/**
* The vector that contains all plays
*/
static inline std::vector<std::unique_ptr<rtt::ai::stp::Play>> plays;

public:
void start(int ai_id);
ApplicationManager() = default;
ApplicationManager(ApplicationManager const&) = delete;
ApplicationManager& operator=(ApplicationManager const&) = delete;
};
Expand Down
4 changes: 3 additions & 1 deletion include/roboteam_ai/control/ControlModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "stp/StpInfo.h"
#include "world/views/RobotView.hpp"
#include "utilities/IOManager.h"
#include <AISettings.h>

namespace rtt::ai::control {

Expand Down Expand Up @@ -54,7 +56,7 @@ namespace rtt::ai::control {
/**
*
*/
static void sendAllCommands();
static std::vector<proto::RobotCommand> sendAllCommands(const AISettings& settings);
};
} // namespace rtt::ai::control

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define RTT_PIDTRACKING_H

#include "control/positionControl/PositionControlUtils.h"
#include "interface/api/Output.h"
#include "roboteam_utils/Position.h"
#include "roboteam_utils/Vector2.h"
#include "roboteam_utils/pid.h"
Expand Down
64 changes: 0 additions & 64 deletions include/roboteam_ai/interface/api/Input.h

This file was deleted.

Loading