-
Notifications
You must be signed in to change notification settings - Fork 8
Implementação do ball placement simplificado #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,12 +34,58 @@ void CustomPlayer::update() { | |||||||
| } | ||||||||
|
|
||||||||
| void CustomPlayer::exec() { | ||||||||
| if (!field || !frame || !robot) { | ||||||||
|
|
||||||||
| if (!field || !frame || !robot) | ||||||||
| return; | ||||||||
| if (!frame->has_ball()) | ||||||||
| return; | ||||||||
| auto&& pos_ball = frame->ball(); | ||||||||
|
|
||||||||
| QPointF targetPosition(1000, 4000); | ||||||||
| QPointF initialPosition(2000, 0); | ||||||||
| int tolerance = 150; | ||||||||
|
Comment on lines
+44
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Como essas variáveis são constantes, podem ir pro arquivo |
||||||||
| maxdis = 9000000; | ||||||||
| if ((pos_ball.distTo(targetPosition)) > tolerance) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Colocar nomes descritivos para as condicionais facilita entender o que tá acontecendo:
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esse comentário também se aplica às outras condicionais |
||||||||
|
|
||||||||
| for (const auto& ally : frame->allies()) { | ||||||||
| double distance = ally.distTo(pos_ball); | ||||||||
| if (maxdis > distance) { | ||||||||
| maxdis = distance; | ||||||||
| idrobot = ally.id(); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // TODO: here... | ||||||||
| // emit sendCommand(...); | ||||||||
| if (robot->id() != idrobot) | ||||||||
| return; | ||||||||
|
|
||||||||
| if ((pos_ball - targetPosition).manhattanLength() > tolerance) { | ||||||||
| if (robot->distTo(pos_ball) > 150) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Substituir o 150 por uma constante |
||||||||
| 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::GoToPoint goToPoint(targetPosition, | ||||||||
| (targetPosition - robot->position()).angle(), | ||||||||
| true); | ||||||||
| goToPoint.set_maxVelocity(1); | ||||||||
| auto command = sslNavigation.run(robot.value(), SSLRobotCommand(goToPoint)); | ||||||||
| command.set_dribbler(true); | ||||||||
| command.set_dribblerVelocity(4); | ||||||||
| emit sendCommand(command); | ||||||||
| } | ||||||||
| } else if (robot->id() == idrobot && robot->distTo(initialPosition) > tolerance) { | ||||||||
| SSLMotion::GoToPoint goToInitial(initialPosition, | ||||||||
| (initialPosition - robot->position()).angle(), | ||||||||
| true); | ||||||||
| auto command = sslNavigation.run(robot.value(), SSLRobotCommand(goToInitial)); | ||||||||
| emit sendCommand(command); | ||||||||
| } else { | ||||||||
| idrobot = -1; | ||||||||
| maxdis = 9000000; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| void CustomPlayer::receiveField(const Field& field) { | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,9 @@ | |||||||||
| #include "Modules/Processing/ProcessingUtils/ProcessingUtils.h" | ||||||||||
|
|
||||||||||
| class CustomPlayer : public Processing { | ||||||||||
| int maxdis = 9000000; | ||||||||||
| int idrobot = -1; | ||||||||||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| bool ball_placement = true; | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Essa variável não é usada, então pode ser removida |
||||||||||
| public: | ||||||||||
| CustomPlayer(int index, QThreadPool* threadPool); | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usar um mesmo padrão pra nomes de variáveis. Nesse caso, a variável passaria a ser
posBall