Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/role assignment #138

Merged
merged 32 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
788116f
Send soccer state.
lordhippo Jul 16, 2024
71f1414
Add soccer menu.
lordhippo Jul 16, 2024
0bc78ce
Add basic role map to the soccer menu.
lordhippo Jul 16, 2024
7ff3251
Open soccer db in gui.
lordhippo Jul 16, 2024
dfd6f80
Improve soccer menu.
lordhippo Jul 16, 2024
ad3582c
Skip robots with no roles in gui.
lordhippo Jul 16, 2024
8ae0ecc
Improve soccer menu layout.
lordhippo Jul 16, 2024
9291466
Implement role assignment.
lordhippo Jul 17, 2024
c02e311
Merge branch 'main' into dev/role-assignment
lordhippo Jul 17, 2024
b6af464
Update common.
lordhippo Jul 17, 2024
7ea4616
Don't add assignment nodes that don't need processing to the graph.
lordhippo Jul 17, 2024
7f3efce
Merge branch 'main' into dev/role-assignment
lordhippo Jul 17, 2024
2ad1eb9
Implement cost functions.
lordhippo Jul 17, 2024
5b4f195
Finish role switch and use it in stop.
lordhippo Jul 17, 2024
163be83
Use int as cost type.
lordhippo Jul 17, 2024
5243434
Add assignment to more plays.
lordhippo Jul 17, 2024
28315d4
Fix attack cost.
lordhippo Jul 18, 2024
72597eb
Merge branch 'main' into dev/role-assignment
lordhippo Jul 18, 2024
0a85d1c
Rename marks to mids.
lordhippo Jul 18, 2024
2718715
Take shoot and chip into account for static assignments.
lordhippo Jul 18, 2024
712a197
Use the old id mapping in strategy.
lordhippo Jul 18, 2024
7b1b21b
Disable chip head for one touch.
lordhippo Jul 18, 2024
fe0f29c
Fix mark cost.
lordhippo Jul 18, 2024
51451fe
Don't navigate robots twice during their ball placement.
lordhippo Jul 18, 2024
08fbc5a
Change the defensive clearing.
lordhippo Jul 18, 2024
635525c
Disable 3d ball estimator.
lordhippo Jul 18, 2024
67191bc
Only try to pass if a mid is ready.
lordhippo Jul 18, 2024
060529c
Set robot caps.
lordhippo Jul 18, 2024
9c285a0
Prioritize mid assignments.
lordhippo Jul 18, 2024
01cd7a3
Tune the attacker cost.
lordhippo Jul 18, 2024
6e65237
Disable role assignment during our ball placement.
lordhippo Jul 18, 2024
7c3424e
Fix sign mismatch warning.
lordhippo Jul 18, 2024
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
24 changes: 12 additions & 12 deletions data/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ one_touch_shoot_k = 4000.0
is_3D_printed = false

[[soccer.robot_physical_status]]
has_chip_kick = false
has_chip_kick = true
has_direct_kick = true
has_dribbler = false
id = 2
Expand All @@ -86,15 +86,15 @@ one_touch_shoot_k = 4000.0
is_3D_printed = true

[[soccer.robot_physical_status]]
has_chip_kick = false
has_direct_kick = false
has_chip_kick = true
has_direct_kick = true
has_dribbler = false
id = 5
is_3D_printed = true

[[soccer.robot_physical_status]]
has_chip_kick = false
has_direct_kick = false
has_chip_kick = true
has_direct_kick = true
has_dribbler = false
id = 6
is_3D_printed = true
Expand All @@ -108,24 +108,24 @@ one_touch_shoot_k = 4000.0

[[soccer.robot_physical_status]]
has_chip_kick = false
has_direct_kick = true
has_direct_kick = false
has_dribbler = false
id = 8
is_3D_printed = true

[[soccer.robot_physical_status]]
has_chip_kick = true
has_direct_kick = true
has_chip_kick = false
has_direct_kick = false
has_dribbler = false
id = 9
is_3D_printed = false

[[soccer.robot_physical_status]]
has_chip_kick = true
has_direct_kick = true
has_chip_kick = false
has_direct_kick = false
has_dribbler = false
id = 10
is_3D_printed = false
is_3D_printed = true

[[soccer.robot_physical_status]]
has_chip_kick = false
Expand Down Expand Up @@ -177,4 +177,4 @@ max_robot_frame_not_seen = 120
merge_distance = 70.0
use_camera = [ false, true, false, false, false, false, false, false ]
use_new_ball_kalman = true
vision_frame_rate = 60.0
vision_frame_rate = 70.0
2 changes: 2 additions & 0 deletions source/cli/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ bool Application::initialize()
m_dumper->addEntry(Common::config().network.raw_world_state_url, Common::config().network.raw_world_state_db);
m_dumper->addEntry(Common::config().network.world_state_url, Common::config().network.world_state_db);
m_dumper->addEntry(Common::config().network.debug_url, Common::config().network.debug_db);
m_dumper->addEntry(Common::config().network.referee_state_url, Common::config().network.referee_db);
m_dumper->addEntry(Common::config().network.soccer_state_url, Common::config().network.soccer_db);

Common::logInfo(" Now it is time, lets rock...");
return true;
Expand Down
2 changes: 2 additions & 0 deletions source/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(HEADER_FILES
menu/filter.h
menu/log.h
menu/plot.h
menu/soccer.h
menu/status_bar.h

renderer/renderer.h
Expand All @@ -31,6 +32,7 @@ set(SOURCE_FILES
menu/filter.cpp
menu/log.cpp
menu/plot.cpp
menu/soccer.cpp
menu/status_bar.cpp

renderer/ball.cpp
Expand Down
60 changes: 34 additions & 26 deletions source/gui/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ bool Application::initialize(const int t_width, const int t_height)
m_dumper->addEntry(Common::config().network.world_state_url, Common::config().network.world_state_db);
m_dumper->addEntry(Common::config().network.debug_url, Common::config().network.debug_db);
m_dumper->addEntry(Common::config().network.referee_state_url, Common::config().network.referee_db);
m_dumper->addEntry(Common::config().network.soccer_state_url, Common::config().network.soccer_db);

m_world_client = std::make_unique<Common::NngClient>(Common::config().network.world_state_url);
m_raw_client = std::make_unique<Common::NngClient>(Common::config().network.raw_world_state_url);
m_debug_client = std::make_unique<Common::NngClient>(Common::config().network.debug_url);
m_referee_client = std::make_unique<Common::NngClient>(Common::config().network.referee_state_url);
m_soccer_client = std::make_unique<Common::NngClient>(Common::config().network.soccer_state_url);

SetTraceLogCallback(logCallback);

Expand All @@ -113,6 +115,7 @@ bool Application::initialize(const int t_width, const int t_height)
ImGuiTheme::ApplyTheme(ImGuiTheme::ImGuiTheme_SoDark_AccentRed);

m_renderer = std::make_unique<Renderer>();
m_soccer_menu = std::make_unique<SoccerMenu>();
m_config_menu = std::make_unique<ConfigMenu>();
m_controller_menu = std::make_unique<ControllerMenu>();
m_demo_menu = std::make_unique<DemoMenu>();
Expand Down Expand Up @@ -165,6 +168,7 @@ void Application::update()
receiveWorldStates();
receiveDebug();
receiveRefereeState();
receiveSoccerState();

BeginDrawing();
ClearBackground(DARKGRAY);
Expand Down Expand Up @@ -204,6 +208,12 @@ void Application::update()
}
ImGui::End();

if (ImGui::Begin("Soccer"))
{
m_soccer_menu->draw(soccerState());
}
ImGui::End();

if (ImGui::Begin("Config"))
{
m_config_menu->draw();
Expand Down Expand Up @@ -247,29 +257,10 @@ void Application::update()

m_renderer->draw(Common::field());

// TODO(mhmd): add an option for this
if (m_demo_menu->getState() == LogState::Live)
{
m_renderer->draw(m_referee_state, Common::field());
if (true)
m_renderer->draw(m_world_state);
else
m_renderer->draw(m_raw_world_state);
}
else
{
m_renderer->draw(m_demo_menu->worldState());
m_renderer->draw(m_demo_menu->refereeState(), Common::field());
}
m_renderer->draw(refereeState(), Common::field());
m_renderer->draw(worldState());

if (m_demo_menu->getState() == LogState::Live)
{
m_renderer->draw(m_debug_wrapper, m_filter_menu->map());
}
else
{
m_renderer->draw(static_cast<Common::Debug::Wrapper>(m_demo_menu->debugWrapper()), m_filter_menu->map());
}
m_renderer->draw(debugWrapper(), m_filter_menu->map());

m_renderer->end();
}
Expand Down Expand Up @@ -312,6 +303,7 @@ void Application::resetLayout()

ImGui::DockBuilderDockWindow("Field", dockspace_main);

ImGui::DockBuilderDockWindow("Soccer", dockspace_left);
ImGui::DockBuilderDockWindow("Config", dockspace_left);
ImGui::DockBuilderDockWindow("Debug Filter", dockspace_left);

Expand Down Expand Up @@ -342,9 +334,16 @@ void Application::receiveWorldStates()

void Application::receiveRefereeState()
{
Protos::Immortals::Referee::State pb_raw_state;
if (m_referee_client->receive(&pb_raw_state, nullptr, true))
m_referee_state = Common::Referee::State(pb_raw_state);
Protos::Immortals::Referee::State pb_state;
if (m_referee_client->receive(&pb_state, nullptr, true))
m_referee_state = Common::Referee::State(pb_state);
}

void Application::receiveSoccerState()
{
Protos::Immortals::Soccer::State pb_state;
if (m_soccer_client->receive(&pb_state, nullptr, true))
m_soccer_state = Common::Soccer::State(pb_state);
}

void Application::receiveDebug()
Expand Down Expand Up @@ -428,7 +427,16 @@ void Application::aiEntry() const
duration_timer.start();

m_ai->process();
m_ai->publishCommands();

if (!m_ai->publishCommands())
{
Common::logWarning("Failed to publish commands");
}

if (!m_ai->publishState())
{
Common::logWarning("Failed to publish state");
}

Common::Debug::ExecutionTime execution_time;
execution_time.duration = duration_timer.time();
Expand Down
21 changes: 17 additions & 4 deletions source/gui/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "menu/filter.h"
#include "menu/log.h"
#include "menu/plot.h"
#include "menu/soccer.h"
#include "menu/status_bar.h"

namespace Tyr::Gui
Expand All @@ -30,6 +31,7 @@ class Application

std::unique_ptr<Renderer> m_renderer;

std::unique_ptr<SoccerMenu> m_soccer_menu;
std::unique_ptr<ConfigMenu> m_config_menu;
std::unique_ptr<ControllerMenu> m_controller_menu;
std::unique_ptr<DemoMenu> m_demo_menu;
Expand Down Expand Up @@ -61,19 +63,20 @@ class Application
std::unique_ptr<Common::NngClient> m_raw_client;
std::unique_ptr<Common::NngClient> m_debug_client;
std::unique_ptr<Common::NngClient> m_referee_client;
std::unique_ptr<Common::NngClient> m_soccer_client;

Common::WorldState m_world_state;
Common::RawWorldState m_raw_world_state;

Common::WorldState m_world_state;
Common::RawWorldState m_raw_world_state;
Common::Debug::Wrapper m_debug_wrapper;

Common::Referee::State m_referee_state;
Common::Soccer::State m_soccer_state;

void resetLayout();

void receiveWorldStates();
void receiveDebug();
void receiveRefereeState();
void receiveSoccerState();

void visionRawEntry() const;
void visionFilteredEntry() const;
Expand All @@ -98,5 +101,15 @@ class Application
{
return live() ? m_debug_wrapper : m_demo_menu->debugWrapper();
}

const Common::Referee::State &refereeState() const
{
return live() ? m_referee_state : m_demo_menu->refereeState();
}

const Common::Soccer::State &soccerState() const
{
return live() ? m_soccer_state : m_demo_menu->soccerState();
}
};
} // namespace Tyr::Gui
13 changes: 9 additions & 4 deletions source/gui/menu/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ DemoMenu::DemoMenu()
m_debug_storage.open(Common::config().network.debug_db);
m_world_filtered_storage.open(Common::config().network.world_state_db);
m_referee_storage.open(Common::config().network.referee_db);
m_soccer_storage.open(Common::config().network.soccer_db);
}

DemoMenu::~DemoMenu()
{
m_debug_storage.close();
m_referee_storage.close();
m_world_filtered_storage.close();
m_referee_storage.close();
m_soccer_storage.close();
}

void DemoMenu::draw()
Expand Down Expand Up @@ -159,14 +161,17 @@ void DemoMenu::update()
Protos::Immortals::WorldState pb_world_state;
Protos::Immortals::Debug::Wrapper pb_debug;
Protos::Immortals::Referee::State pb_referee;
Protos::Immortals::Soccer::State pb_soccer;

m_world_filtered_storage.get(playback_point.microseconds(), &pb_world_state);
m_debug_storage.get(playback_point.microseconds(), &pb_debug);
m_referee_storage.get(playback_point.microseconds(), &pb_referee);
m_soccer_storage.get(playback_point.microseconds(), &pb_soccer);

m_world_state = static_cast<Common::WorldState>(pb_world_state);
m_debug = static_cast<Common::Debug::Wrapper>(pb_debug);
m_referee = static_cast<Common::Referee::State>(pb_referee);
m_world_state = static_cast<Common::WorldState>(pb_world_state);
m_debug = static_cast<Common::Debug::Wrapper>(pb_debug);
m_referee_state = static_cast<Common::Referee::State>(pb_referee);
m_soccer_state = static_cast<Common::Soccer::State>(pb_soccer);
}

void DemoMenu::analyzeDatabase()
Expand Down
11 changes: 9 additions & 2 deletions source/gui/menu/demo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

namespace Tyr::Gui

Check failure on line 3 in source/gui/menu/demo.h

View workflow job for this annotation

GitHub Actions / check

source/gui/menu/demo.h:3:1 [clang-diagnostic-error]

unknown type name 'namespace'

Check failure on line 3 in source/gui/menu/demo.h

View workflow job for this annotation

GitHub Actions / check

source/gui/menu/demo.h:3:14 [clang-diagnostic-error]

expected ';' after top level declarator

Check failure on line 3 in source/gui/menu/demo.h

View workflow job for this annotation

GitHub Actions / check

source/gui/menu/demo.h:3:15 [clang-diagnostic-error]

expected identifier or '('
{
enum class LogState
{
Expand Down Expand Up @@ -34,7 +34,12 @@

const Common::Referee::State &refereeState() const
{
return m_referee;
return m_referee_state;
}

const Common::Soccer::State &soccerState() const
{
return m_soccer_state;
}

private:
Expand Down Expand Up @@ -81,10 +86,12 @@
Common::Storage m_debug_storage;
Common::Storage m_world_filtered_storage;
Common::Storage m_referee_storage;
Common::Storage m_soccer_storage;

Common::Debug::Wrapper m_debug;
Common::WorldState m_world_state;
Common::Referee::State m_referee;
Common::Referee::State m_referee_state;
Common::Soccer::State m_soccer_state;
};

} // namespace Tyr::Gui
Loading
Loading