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

Add Tracy Profiler #1407

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ target_include_directories(roboteam_ai_skills
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai_skills
PRIVATE Tracy::TracyClient
PRIVATE roboteam_networking
PRIVATE roboteam_utils
PRIVATE Qt5::Widgets
Expand Down Expand Up @@ -93,6 +94,7 @@ target_include_directories(roboteam_ai_tactics
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai_tactics
PRIVATE Tracy::TracyClient
PRIVATE roboteam_utils
PRIVATE roboteam_networking
PRIVATE Qt5::Widgets
Expand Down Expand Up @@ -177,6 +179,7 @@ target_include_directories(roboteam_ai_plays
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai_plays
PRIVATE Tracy::TracyClient
PUBLIC roboteam_interface_utils_lib
PRIVATE roboteam_networking
PRIVATE roboteam_utils
Expand Down Expand Up @@ -290,6 +293,7 @@ target_include_directories(roboteam_ai_control
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai_control
PRIVATE Tracy::TracyClient
PRIVATE roboteam_networking
PRIVATE roboteam_utils
PRIVATE Qt5::Widgets
Expand Down Expand Up @@ -364,6 +368,7 @@ target_include_directories(roboteam_ai_world
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai_world
PRIVATE Tracy::TracyClient
PRIVATE roboteam_networking
PRIVATE roboteam_utils
PRIVATE Qt5::Widgets
Expand All @@ -379,6 +384,7 @@ target_include_directories(roboteam_ai
PRIVATE include/roboteam_ai
)
target_link_libraries(roboteam_ai
PRIVATE Tracy::TracyClient
PRIVATE roboteam_utils
PRIVATE Qt5::Widgets
PRIVATE roboteam_networking
Expand Down
10 changes: 4 additions & 6 deletions src/STPManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stp/plays/referee_specific/TimeOut.h>
#include <utilities/normalize.h>

#include "tracy/Tracy.hpp"

#include <chrono>

#include "control/ControlModule.h"
Expand Down Expand Up @@ -100,13 +102,8 @@ void STPManager::start() {
roboteam_utils::Timer stpTimer;
stpTimer.loop(
[&]() {
// uncomment the 4 lines of code below to time and display the duration of each loop of the AI
// std::chrono::steady_clock::time_point tStart = std::chrono::steady_clock::now();
ZoneScopedN("STP Loop");
runOneLoopCycle();
// std::chrono::steady_clock::time_point tStop = std::chrono::steady_clock::now();

// auto loopcycleDuration = std::chrono::duration_cast<std::chrono::milliseconds>((tStop - tStart)).count();
// RTT_DEBUG("Loop cycle duration = ", loopcycleDuration);
amountOfCycles++;

// update the measured FPS, but limit this function call to only run 5 times/s at most
Expand Down Expand Up @@ -179,6 +176,7 @@ void STPManager::runOneLoopCycle() {
}

void STPManager::decidePlay(world::World *_world) {
ZoneScopedN("Decide Play");
ai::stp::PlayEvaluator::clearGlobalScores(); // reset all evaluations
ai::stp::ComputationManager::clearStoredComputations();

Expand Down
2 changes: 2 additions & 0 deletions src/control/positionControl/BBTrajectories/WorldObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
#include "control/positionControl/BBTrajectories/WorldObjects.h"

#include "tracy/Tracy.hpp"
#include <algorithm>

#include "world/World.hpp"
Expand All @@ -14,6 +15,7 @@ WorldObjects::WorldObjects() = default;

std::optional<CollisionData> WorldObjects::getFirstCollision(const rtt::world::World *world, const rtt::world::Field &field, const Trajectory2D &Trajectory,
const std::unordered_map<int, std::vector<Vector2>> &computedPaths, int robotId, ai::stp::AvoidObjects avoidObjects) {
ZoneScopedN("Get First Collision");
gameState = rtt::ai::GameStateManager::getCurrentGameState();
ruleset = gameState.getRuleSet();
// TODO: return the kind of collision
Expand Down
3 changes: 2 additions & 1 deletion src/control/positionControl/PositionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "control/positionControl/BBTrajectories/BBTrajectory2D.h"
#include "roboteam_utils/Print.h"

#include "tracy/Tracy.hpp"
namespace rtt::ai::control {
RobotCommand PositionControl::computeAndTrackPath(const rtt::world::Field &field, int robotId, const Vector2 &currentPosition, const Vector2 &currentVelocity,
Vector2 &targetPosition, stp::PIDType pidType) {
Expand Down Expand Up @@ -41,6 +41,7 @@ void PositionControl::setRobotPositions(std::vector<Vector2> &robotPositions) {
rtt::BB::CommandCollision PositionControl::computeAndTrackTrajectory(const rtt::world::World *world, const rtt::world::Field &field, int robotId, Vector2 currentPosition,
Vector2 currentVelocity, Vector2 targetPosition, double maxRobotVelocity, stp::PIDType pidType,
stp::AvoidObjects avoidObjects) {
ZoneScopedN("ComputeAndTrackTrajectory");
double timeStep = 0.1;

std::optional<BB::CollisionData> firstCollision;
Expand Down
2 changes: 2 additions & 0 deletions src/stp/Play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "control/ControlUtils.h"
#include "interface/widgets/MainControlsWidget.h"
#include "tracy/Tracy.hpp"

namespace rtt::ai::stp {

Expand All @@ -30,6 +31,7 @@ void Play::setWorld(world::World *world) noexcept { this->world = world; }
void Play::updateField(world::Field field) noexcept { this->field = field; }

void Play::update() noexcept {
ZoneScopedN("Play Update");
// clear roleStatuses so it only contains the current tick's statuses
roleStatuses.clear();
// RTT_INFO("Play executing: ", getName())
Expand Down
2 changes: 2 additions & 0 deletions src/stp/Skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "control/ControlModule.h"
#include "world/World.hpp"
#include "tracy/Tracy.hpp"

namespace rtt::ai::stp {

Expand All @@ -28,6 +29,7 @@ void Skill::refreshRobotCommand() noexcept {
void Skill::terminate() noexcept {}

Status Skill::update(StpInfo const& info) noexcept {
ZoneScopedN("Skill Update");
robot = info.getRobot();
auto result = onUpdate(info);
currentStatus = result;
Expand Down
2 changes: 2 additions & 0 deletions src/stp/Tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "stp/Tactic.h"

#include <roboteam_utils/Print.h>
#include "tracy/Tracy.hpp"

namespace rtt::ai::stp {

Expand All @@ -15,6 +16,7 @@ void Tactic::initialize() noexcept {
}

Status Tactic::update(StpInfo const &info) noexcept {
ZoneScopedN("Tactic Update");
// Update skill info
auto skill_info = calculateInfoForSkill(info);

Expand Down
2 changes: 2 additions & 0 deletions src/world/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include "world/World.hpp"
#include "tracy/Tracy.hpp"

namespace rtt::world {
WorldData const &World::setWorld(WorldData &newWorld) noexcept {
Expand Down Expand Up @@ -91,6 +92,7 @@ void World::updateTickTime() noexcept {
}

void World::updatePositionControl() {
ZoneScopedN("Update Position Control");
std::vector<Vector2> robotPositions(getWorld()->getRobotsNonOwning().size());
std::transform(getWorld()->getRobotsNonOwning().begin(), getWorld()->getRobotsNonOwning().end(), robotPositions.begin(),
[](const auto &robot) -> Vector2 { return (robot->getPos()); });
Expand Down