Skip to content
Open
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
38 changes: 36 additions & 2 deletions src/Modules/Processing/CustomPlayer/CustomPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "CustomPlayer.h"
#include "Packages/SSLRobotCommand/SSLRobotCommand.h"

CustomPlayer::CustomPlayer(int index, QThreadPool* threadPool) : Processing(index, threadPool) {
}
Expand Down Expand Up @@ -37,9 +38,42 @@ void CustomPlayer::exec() {
if (!field || !frame || !robot) {
return;
}
if(!frame->has_ball()) return;
auto&& pos_ball = frame->ball();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padronizar o nome das variáveis. Nesse caso, o nome devera ser posBall.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em C++ costumamos usar o padrão camelCase

if(field->enemyPenaltyAreaContains(pos_ball)) return;
if(robot->distTo(pos_ball)>150)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colocar nomes de variáveis descritivas para facilitar o entendimento:

Suggested change
if(robot->distTo(pos_ball)>150)
bool isRobotFarFromBall = robot->distTo(pos_ball)>150;
if(isRobotFarFromBall)

{
SSLMotion::GoToPoint goToPoint(pos_ball,
(pos_ball - robot->position()).angle(),
true);
auto command = sslNavigation.run(robot.value(), SSLRobotCommand(goToPoint));
command.set_dribbler(true);
command.set_dribblerVelocity(4);
emit sendCommand(command);
}else {
SSLMotion::RotateOnSelf Rotate((field->enemyGoalInsideCenter() -robot->position()).angle());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manter o padrão dos nomes dos estados

Suggested change
SSLMotion::RotateOnSelf Rotate((field->enemyGoalInsideCenter() -robot->position()).angle());
SSLMotion::RotateOnSelf rotate((field->enemyGoalInsideCenter() - robot->position()).angle());

auto command = sslNavigation.run(robot.value(), SSLRobotCommand(Rotate));
command.set_dribbler(true);
command.set_dribblerVelocity(4);
emit sendCommand(command);
if(abs(robot->angleTo(field->enemyGoalInsideCenter()))<0.1)
{
SSLMotion::GoToPoint goToPoint(pos_ball,
(pos_ball - robot->position()).angle(),
true);
auto irparapos = sslNavigation.run(robot.value(), SSLRobotCommand(goToPoint));
irparapos.set_front(true);
irparapos.set_kickSpeed(2);
Comment on lines +64 to +66

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pode ser um nome mais descritivo

Suggested change
auto irparapos = sslNavigation.run(robot.value(), SSLRobotCommand(goToPoint));
irparapos.set_front(true);
irparapos.set_kickSpeed(2);
auto command = sslNavigation.run(robot.value(), SSLRobotCommand(goToPoint));
command.set_front(true);
command.set_kickSpeed(2);


if(robot->distTo(field->enemyGoalInsideCenter())<4000)
{
irparapos.set_kickSpeed(6);
}
emit sendCommand(irparapos);
Comment on lines +70 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trocar aqui também

Suggested change
irparapos.set_kickSpeed(6);
}
emit sendCommand(irparapos);
command.set_kickSpeed(6);
}
emit sendCommand(command);

}

}

// TODO: here...
// emit sendCommand(...);
}

void CustomPlayer::receiveField(const Field& field) {
Expand Down