Skip to content

Commit

Permalink
Merge pull request RoboCup-SSL#137 from RoboCup-SSL/update-geometry
Browse files Browse the repository at this point in the history
Update field configuration default values and robot formation
  • Loading branch information
mahi97 authored Jan 18, 2021
2 parents 723c5d0 + de1456f commit 6217085
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 56 deletions.
4 changes: 2 additions & 2 deletions include/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class GLWidget : public QGLWidget {
dReal getFPS();
ConfigWidget* cfg;
SSLWorld* ssl;
RobotsFomation* forms[6];
RobotsFomation* forms[4];
QMenu* robpopup,*ballpopup,*mainpopup;
QMenu *blueRobotsMenu,*yellowRobotsMenu;
QMenu *blueRobotsMenu,*yellowRobotsMenu,*allRobotsMenu;
QAction* moveRobotAct;
QAction* selectRobotAct;
QAction* resetRobotAct;
Expand Down
4 changes: 4 additions & 0 deletions include/sslworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
#include "messages_robocup_ssl_robot_status.pb.h"

#define WALL_COUNT 10
#define FORMATION_OUTSIDE 0
#define FORMATION_INSIDE_1 1
#define FORMATION_INSIDE_2 2
#define FORMATION_OUTSIDE_FIELD 3

class RobotsFomation;
class SendingPacket {
Expand Down
20 changes: 10 additions & 10 deletions src/configwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ConfigWidget::ConfigWidget()
ADD_TO_ENUM(Division, "Division A");
ADD_TO_ENUM(Division, "Division B");
END_ENUM(game_vars, Division);
ADD_VALUE(game_vars,Int, Robots_Count, 8, "Robots Count")
ADD_VALUE(game_vars,Int, Robots_Count, 11, "Robots Count")
VarListPtr fields_vars(new VarList("Field"));
VarListPtr div_a_vars(new VarList("Division A"));
VarListPtr div_b_vars(new VarList("Division B"));
Expand All @@ -57,15 +57,15 @@ ConfigWidget::ConfigWidget()
ADD_VALUE(div_a_vars, Double, DivA_Field_Width,9.000,"Width")
ADD_VALUE(div_a_vars, Double, DivA_Field_Rad,0.500,"Radius")
ADD_VALUE(div_a_vars, Double, DivA_Field_Free_Kick,0.700,"Free Kick Distance From Defense Area")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Width,2.40,"Penalty width")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Depth,1.20,"Penalty depth")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Point,1.20,"Penalty point")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Width,3.60,"Penalty width")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Depth,1.80,"Penalty depth")
ADD_VALUE(div_a_vars, Double, DivA_Field_Penalty_Point,8.00,"Penalty point")
ADD_VALUE(div_a_vars, Double, DivA_Field_Margin,0.3,"Margin")
ADD_VALUE(div_a_vars, Double, DivA_Field_Referee_Margin,0.4,"Referee margin")
ADD_VALUE(div_a_vars, Double, DivA_Field_Referee_Margin,0.0,"Referee margin")
ADD_VALUE(div_a_vars, Double, DivA_Wall_Thickness,0.050,"Wall thickness")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Thickness,0.020,"Goal thickness")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Depth,0.200,"Goal depth")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Width,1.200,"Goal width")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Depth,0.18,"Goal depth")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Width,1.8,"Goal width")
ADD_VALUE(div_a_vars, Double, DivA_Goal_Height,0.160,"Goal height")

ADD_VALUE(div_b_vars, Double, DivB_Field_Line_Width,0.010,"Line Thickness")
Expand All @@ -75,12 +75,12 @@ ConfigWidget::ConfigWidget()
ADD_VALUE(div_b_vars, Double, DivB_Field_Free_Kick,0.700,"Free Kick Distance From Defense Area")
ADD_VALUE(div_b_vars, Double, DivB_Field_Penalty_Width,2.00,"Penalty width")
ADD_VALUE(div_b_vars, Double, DivB_Field_Penalty_Depth,1.0,"Penalty depth")
ADD_VALUE(div_b_vars, Double, DivB_Field_Penalty_Point,1.00,"Penalty point")
ADD_VALUE(div_b_vars, Double, DivB_Field_Penalty_Point,6.00,"Penalty point")
ADD_VALUE(div_b_vars, Double, DivB_Field_Margin,0.30,"Margin")
ADD_VALUE(div_b_vars, Double, DivB_Field_Referee_Margin,0.4,"Referee margin")
ADD_VALUE(div_b_vars, Double, DivB_Field_Referee_Margin,0.0,"Referee margin")
ADD_VALUE(div_b_vars, Double, DivB_Wall_Thickness,0.050,"Wall thickness")
ADD_VALUE(div_b_vars, Double, DivB_Goal_Thickness,0.020,"Goal thickness")
ADD_VALUE(div_b_vars, Double, DivB_Goal_Depth,0.200,"Goal depth")
ADD_VALUE(div_b_vars, Double, DivB_Goal_Depth,0.18,"Goal depth")
ADD_VALUE(div_b_vars, Double, DivB_Goal_Width,1.000,"Goal width")
ADD_VALUE(div_b_vars, Double, DivB_Goal_Height,0.160,"Goal height")

Expand Down
30 changes: 20 additions & 10 deletions src/glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ GLWidget::GLWidget(QWidget *parent, ConfigWidget* _cfg)
first_time = true;
cfg = _cfg;

forms[1] = new RobotsFomation(-1, cfg); //outside yellow
forms[2] = new RobotsFomation(1, cfg); //inside type 1
forms[3] = new RobotsFomation(2, cfg); //inside type 2
forms[4] = new RobotsFomation(3, cfg); //inside type 1
//forms[5] = new RobotsFomation(4); //inside type 2
forms[FORMATION_OUTSIDE] = new RobotsFomation(FORMATION_OUTSIDE, cfg);
forms[FORMATION_INSIDE_1] = new RobotsFomation(FORMATION_INSIDE_1, cfg);
forms[FORMATION_INSIDE_2] = new RobotsFomation(FORMATION_INSIDE_2, cfg);
forms[FORMATION_OUTSIDE_FIELD] = new RobotsFomation(FORMATION_OUTSIDE_FIELD, cfg);

ssl = new SSLWorld(this,cfg,forms[2],forms[2]);
ssl = new SSLWorld(this,cfg,forms[FORMATION_INSIDE_1],forms[FORMATION_INSIDE_1]);
Current_robot = 0;
Current_team = 0;
cammode = CameraMode::BIRDS_EYE_FROM_TOUCH_LINE;
setMouseTracking(true);

blueRobotsMenu = new QMenu("&Blue Robots");
yellowRobotsMenu = new QMenu("&Yellow Robots");
allRobotsMenu = new QMenu("&All Robots");
blueRobotsMenu->addAction(tr("Put all inside with formation 1"));
blueRobotsMenu->addAction(tr("Put all inside with formation 2"));
blueRobotsMenu->addAction(tr("Put all outside"));
Expand All @@ -61,6 +61,12 @@ GLWidget::GLWidget(QWidget *parent, ConfigWidget* _cfg)
yellowRobotsMenu->addAction(tr("Put all out of field"));
yellowRobotsMenu->addAction(tr("Turn all off"));
yellowRobotsMenu->addAction(tr("Turn all on"));
allRobotsMenu->addAction(tr("Put all inside with formation 1"));
allRobotsMenu->addAction(tr("Put all inside with formation 2"));
allRobotsMenu->addAction(tr("Put all outside"));
allRobotsMenu->addAction(tr("Put all out of field"));
allRobotsMenu->addAction(tr("Turn all off"));
allRobotsMenu->addAction(tr("Turn all on"));
robpopup = new QMenu(this);
moveRobotAct = new QAction(tr("&Locate robot"),this);
selectRobotAct = new QAction(tr("&Select robot"),this);
Expand All @@ -73,6 +79,7 @@ GLWidget::GLWidget(QWidget *parent, ConfigWidget* _cfg)
robpopup->addAction(lockToRobotAct);
robpopup->addMenu(blueRobotsMenu);
robpopup->addMenu(yellowRobotsMenu);
robpopup->addMenu(allRobotsMenu);

moveBallAct = new QAction(tr("&Locate ball"),this);
lockToBallAct = new QAction(tr("Loc&k camera to ball"),this);
Expand All @@ -95,6 +102,7 @@ GLWidget::GLWidget(QWidget *parent, ConfigWidget* _cfg)
mainpopup->addMenu(cameraMenu);
mainpopup->addMenu(blueRobotsMenu);
mainpopup->addMenu(yellowRobotsMenu);
mainpopup->addMenu(allRobotsMenu);


connect(moveRobotAct, SIGNAL(triggered()), this, SLOT(moveRobot()));
Expand All @@ -104,6 +112,8 @@ GLWidget::GLWidget(QWidget *parent, ConfigWidget* _cfg)
connect(onOffRobotAct, SIGNAL(triggered()), this, SLOT(switchRobotOnOff()));
connect(yellowRobotsMenu,SIGNAL(triggered(QAction*)),this,SLOT(yellowRobotsMenuTriggered(QAction*)));
connect(blueRobotsMenu,SIGNAL(triggered(QAction*)),this,SLOT(blueRobotsMenuTriggered(QAction*)));
connect(allRobotsMenu,SIGNAL(triggered(QAction*)),this,SLOT(yellowRobotsMenuTriggered(QAction*)));
connect(allRobotsMenu,SIGNAL(triggered(QAction*)),this,SLOT(blueRobotsMenuTriggered(QAction*)));
connect(moveBallHereAct, SIGNAL(triggered()),this , SLOT(moveBallHere()));
connect(moveRobotHereAct, SIGNAL(triggered()),this , SLOT(moveRobotHere()));
connect(lockToRobotAct, SIGNAL(triggered()), this, SLOT(lockCameraToRobot()));
Expand Down Expand Up @@ -507,10 +517,10 @@ void GLWidget::yellowRobotsMenuTriggered(QAction *act)

void GLWidget::reform(int team,const QString& act)
{
if (act==tr("Put all inside with formation 1")) forms[2]->resetRobots(ssl->robots,team);
if (act==tr("Put all inside with formation 2")) forms[3]->resetRobots(ssl->robots,team);
if (act==tr("Put all outside")) forms[1]->resetRobots(ssl->robots,team);
if (act==tr("Put all out of field")) forms[4]->resetRobots(ssl->robots,team);
if (act==tr("Put all inside with formation 1")) forms[FORMATION_INSIDE_1]->resetRobots(ssl->robots, team);
if (act==tr("Put all inside with formation 2")) forms[FORMATION_INSIDE_2]->resetRobots(ssl->robots,team);
if (act==tr("Put all outside")) forms[FORMATION_OUTSIDE]->resetRobots(ssl->robots,team);
if (act==tr("Put all out of field")) forms[FORMATION_OUTSIDE_FIELD]->resetRobots(ssl->robots,team);

if(act==tr("Turn all off")) {
for(int i=0; i<cfg->Robots_Count(); i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ MainWindow::MainWindow(QWidget *parent)

robotMenu->addMenu(glwidget->blueRobotsMenu);
robotMenu->addMenu(glwidget->yellowRobotsMenu);
robotMenu->addMenu(glwidget->allRobotsMenu);

fullScreenAct = new QAction(tr("&Full screen"),simulatorMenu);
fullScreenAct->setShortcut(QKeySequence("F2"));
Expand Down Expand Up @@ -417,7 +418,7 @@ void MainWindow::changeBallDamping()
void MainWindow::restartSimulator()
{
delete glwidget->ssl;
glwidget->ssl = new SSLWorld(glwidget,glwidget->cfg,glwidget->forms[2],glwidget->forms[2]);
glwidget->ssl = new SSLWorld(glwidget,glwidget->cfg,glwidget->forms[FORMATION_INSIDE_1],glwidget->forms[FORMATION_INSIDE_1]);
glwidget->ssl->glinit();
glwidget->ssl->visionServer = visionServer;
glwidget->ssl->commandSocket = commandSocket;
Expand Down
43 changes: 10 additions & 33 deletions src/sslworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,17 +957,16 @@ void RobotsFomation::setAll(dReal* xx,dReal *yy)
RobotsFomation::RobotsFomation(int type, ConfigWidget* _cfg):
cfg(_cfg)
{
if (type==0)
if (type==FORMATION_OUTSIDE)
{
dReal teamPosX[MAX_ROBOT_COUNT] = { 2.20, 1.00, 1.00, 1.00, 0.33, 1.22,
3.00, 3.20, 3.40, 3.60, 3.80, 4.00,
double yv = -(_cfg->Field_Width() / 2 + _cfg->Field_Margin() / 2);
dReal teamPosX[MAX_ROBOT_COUNT] = { 0.40, 0.80, 1.20, 1.60, 2.00, 2.40,
2.80, 3.20, 3.60, 4.00, 4.40, 4.80,
0.40, 0.80, 1.20, 1.60};
dReal teamPosY[MAX_ROBOT_COUNT] = { 0.00, -0.75, 0.00, 0.75, 0.25, 0.00,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
-3.50, -3.50, -3.50, -3.50};
dReal teamPosY[MAX_ROBOT_COUNT] = {yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv};
setAll(teamPosX,teamPosY);
}
if (type==1) // formation 1
if (type==FORMATION_INSIDE_1)
{
dReal teamPosX[MAX_ROBOT_COUNT] = { 1.50, 1.50, 1.50, 0.55, 2.50, 3.60,
3.20, 3.20, 3.20, 3.20, 3.20, 3.20,
Expand All @@ -977,7 +976,7 @@ cfg(_cfg)
-3.50, -3.50, -3.50, -3.50};
setAll(teamPosX,teamPosY);
}
if (type==2) // formation 2
if (type==FORMATION_INSIDE_2)
{
dReal teamPosX[MAX_ROBOT_COUNT] = { 4.20, 3.40, 3.40, 0.70, 0.70, 0.70,
2.00, 2.00, 2.00, 2.00, 2.00, 2.00,
Expand All @@ -987,37 +986,15 @@ cfg(_cfg)
-3.50, -3.50, -3.50, -3.50};
setAll(teamPosX,teamPosY);
}
if (type==3) // outside field
if (type==FORMATION_OUTSIDE_FIELD)
{
double yv = -(_cfg->Field_Width() / 2 + _cfg->Field_Margin() + _cfg->Field_Referee_Margin() + 0.5);
dReal teamPosX[MAX_ROBOT_COUNT] = { 0.40, 0.80, 1.20, 1.60, 2.00, 2.40,
2.80, 3.20, 3.60, 4.00, 4.40, 4.80,
0.40, 0.80, 1.20, 1.60};
dReal teamPosY[MAX_ROBOT_COUNT] = {-4.00, -4.00, -4.00, -4.00, -4.00, -4.00,
-4.00, -4.00, -4.00, -4.00, -4.00, -4.00,
-4.40, -4.40, -4.40, -4.40};
setAll(teamPosX,teamPosY);
}
if (type==4)
{
dReal teamPosX[MAX_ROBOT_COUNT] = { 2.80, 2.50, 2.50, 0.80, 0.80, 1.10,
3.00, 3.20, 3.40, 3.60, 3.80, 4.00,
0.40, 0.80, 1.20, 1.60};
dReal teamPosY[MAX_ROBOT_COUNT] = { 5.00, 4.70, 5.30, 5.00, 6.50, 5.50,
1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
-3.50, -3.50, -3.50, -3.50};
dReal teamPosY[MAX_ROBOT_COUNT] = {yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv, yv};
setAll(teamPosX,teamPosY);
}
if (type==-1) // outside
{
dReal teamPosX[MAX_ROBOT_COUNT] = { 0.40, 0.80, 1.20, 1.60, 2.00, 2.40,
2.80, 3.20, 3.60, 4.00, 4.40, 4.80,
0.40, 0.80, 1.20, 1.60};
dReal teamPosY[MAX_ROBOT_COUNT] = {-3.40, -3.40, -3.40, -3.40, -3.40, -3.40,
-3.40, -3.40, -3.40, -3.40, -3.40, -3.40,
-3.20, -3.20, -3.20, -3.20};
setAll(teamPosX,teamPosY);
}

}

void RobotsFomation::loadFromFile(const QString& filename)
Expand Down

0 comments on commit 6217085

Please sign in to comment.