Skip to content

Commit

Permalink
Merge pull request #19 from hbritto/master
Browse files Browse the repository at this point in the history
Fixes compilation errors caused by VarTypes 0.8 and changes some constants according to new RoboCup SSL rules (2015)
  • Loading branch information
mani-monaj authored Oct 24, 2016
2 parents 312c988 + 5c40498 commit ef7000e
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 61 deletions.
22 changes: 11 additions & 11 deletions src/configwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
#include "configwidget.h"

#define ADD_ENUM(type,name,Defaultvalue,namestring) \
v_##name = shared_ptr<Var##type>(new Var##type(namestring,Defaultvalue));
v_##name = std::tr1::shared_ptr<Var##type>(new Var##type(namestring,Defaultvalue));
#define END_ENUM(parents, name) \
parents->addChild(v_##name);
#define ADD_TO_ENUM(name,str) \
v_##name->addItem(str);


#define ADD_VALUE(parent,type,name,defaultvalue,namestring) \
v_##name = shared_ptr<Var##type>(new Var##type(namestring,defaultvalue)); \
v_##name = std::tr1::shared_ptr<Var##type>(new Var##type(namestring,defaultvalue)); \
parent->addChild(v_##name);

#include<QDir>
Expand All @@ -44,21 +44,21 @@ ConfigWidget::ConfigWidget()

geo_vars->addChild(field_vars);
ADD_VALUE(field_vars,Double,Field_Line_Width,0.010,"Line Thickness")
ADD_VALUE(field_vars,Double,Field_Length,6.000,"Length")
ADD_VALUE(field_vars,Double,Field_Width,4.000,"Width")
ADD_VALUE(field_vars,Double,Field_Length,9.000,"Length")
ADD_VALUE(field_vars,Double,Field_Width,6.000,"Width")
ADD_VALUE(field_vars,Double,Field_Rad,0.500,"Radius")
ADD_VALUE(field_vars,Double,Field_Defense_Rad,0.500,"Defense Radius")
ADD_VALUE(field_vars,Double,Field_Defense_Stretch,0.350,"Defense Stretch")
ADD_VALUE(field_vars,Double,Field_Defense_Rad,1.000,"Defense Radius")
ADD_VALUE(field_vars,Double,Field_Defense_Stretch,0.500,"Defense Stretch")
ADD_VALUE(field_vars,Double,Field_Free_Kick,0.700,"Free Kick Distanse From Defense Area")
ADD_VALUE(field_vars,Double,Field_Penalty_Rad,0.50,"Penalty radius")
ADD_VALUE(field_vars,Double,Field_Penalty_Line,0.350,"Penalty line length")
ADD_VALUE(field_vars,Double,Field_Penalty_Point,0.450,"Penalty point")
ADD_VALUE(field_vars,Double,Field_Penalty_Point,0.950,"Penalty point")
ADD_VALUE(field_vars,Double,Field_Margin,0.250,"Margin")
ADD_VALUE(field_vars,Double,Field_Referee_Margin,0.425,"Referee margin")
ADD_VALUE(field_vars,Double,Field_Referee_Margin,0.455,"Referee margin")
ADD_VALUE(field_vars,Double,Wall_Thickness,0.050,"Wall thickness")
ADD_VALUE(field_vars,Double,Goal_Thickness,0.020,"Goal thickness")
ADD_VALUE(field_vars,Double,Goal_Depth,0.180,"Goal depth")
ADD_VALUE(field_vars,Double,Goal_Width,0.700,"Goal width")
ADD_VALUE(field_vars,Double,Goal_Depth,0.200,"Goal depth")
ADD_VALUE(field_vars,Double,Goal_Width,1.000,"Goal width")
ADD_VALUE(field_vars,Double,Goal_Height,0.160,"Goal height")
ADD_ENUM(StringEnum,YellowTeam,"Parsian","Yellow Team");
END_ENUM(geo_vars,YellowTeam)
Expand All @@ -74,7 +74,7 @@ ConfigWidget::ConfigWidget()
phys_vars->addChild(worldp_vars);
ADD_VALUE(worldp_vars,Double,DesiredFPS,65,"Desired FPS")
ADD_VALUE(worldp_vars,Bool,SyncWithGL,false,"Synchronize ODE with OpenGL")
ADD_VALUE(worldp_vars,Double,DeltaTime,0.015,"ODE time step")
ADD_VALUE(worldp_vars,Double,DeltaTime,0.016,"ODE time step")
ADD_VALUE(worldp_vars,Double,Gravity,9.8,"Gravity")
VarListPtr ballp_vars(new VarList("Ball"));
phys_vars->addChild(ballp_vars);
Expand Down
8 changes: 4 additions & 4 deletions src/configwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
using namespace VarTypes;

#define DEF_VALUE(type,Type,name) \
shared_ptr<VarTypes::Var##Type> v_##name; \
std::tr1::shared_ptr<VarTypes::Var##Type> v_##name; \
inline type name() {return v_##name->get##Type();}

#define DEF_ENUM(type,name) \
shared_ptr<VarTypes::VarStringEnum> v_##name; \
std::tr1::shared_ptr<VarTypes::VarStringEnum> v_##name; \
type name() {if(v_##name!=NULL) return v_##name->getString();return * (new type);}

#define DEF_TREE(name) \
shared_ptr<VarTypes::VarList> name;
std::tr1::shared_ptr<VarTypes::VarList> name;
#define DEF_PTREE(parents, name) \
shared_ptr<VarTypes::VarList> parents##_##name;
std::tr1::shared_ptr<VarTypes::VarList> parents##_##name;



Expand Down
39 changes: 34 additions & 5 deletions src/glwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
#include "logger.h"
#include <QLabel>

#include <iostream>

GLWidget::GLWidget(QWidget *parent,ConfigWidget* _cfg)
: QGLWidget(parent)
{
Expand All @@ -50,10 +52,14 @@ GLWidget::GLWidget(QWidget *parent,ConfigWidget* _cfg)
blueRobotsMenu->addAction(tr("Put all inside with formation 2"));
blueRobotsMenu->addAction(tr("Put all outside"));
blueRobotsMenu->addAction(tr("Put all out of field"));
blueRobotsMenu->addAction(tr("Turn all off"));
blueRobotsMenu->addAction(tr("Turn all on"));
yellowRobotsMenu->addAction(tr("Put all inside with formation 1"));
yellowRobotsMenu->addAction(tr("Put all inside with formation 2"));
yellowRobotsMenu->addAction(tr("Put all outside"));
yellowRobotsMenu->addAction(tr("Put all out of field"));
yellowRobotsMenu->addAction(tr("Turn all off"));
yellowRobotsMenu->addAction(tr("Turn all on"));
robpopup = new QMenu(this);
moveRobotAct = new QAction(tr("&Locate robot"),this);
selectRobotAct = new QAction(tr("&Select robot"),this);
Expand Down Expand Up @@ -426,8 +432,8 @@ void GLWidget::keyPressEvent(QKeyEvent *event)
if (fullScreen) {
if (event->key()==Qt::Key_F2) emit toggleFullScreen(false);
}
const dReal S = 0.30;
const dReal BallForce = 0.2;
const dReal S = 1.00;
const dReal BallForce = 2.0;
int R = robotIndex(Current_robot,Current_team);
switch (cmd) {
case 't': case 'T': ssl->robots[R]->incSpeed(0,-S);ssl->robots[R]->incSpeed(1,S);ssl->robots[R]->incSpeed(2,-S);ssl->robots[R]->incSpeed(3,S);break;
Expand All @@ -438,8 +444,8 @@ void GLWidget::keyPressEvent(QKeyEvent *event)
case 's': case 'S':dBodyAddForce(ssl->ball->body,0,-BallForce,0);break;
case 'd': case 'D':dBodyAddForce(ssl->ball->body, BallForce,0,0);break;
case 'a': case 'A':dBodyAddForce(ssl->ball->body,-BallForce,0,0);break;
case 'k':case 'K': ssl->robots[R]->kicker->kick(4,0);break;
case 'l':case 'L': ssl->robots[R]->kicker->kick(2,2);break;
case 'k':case 'K': ssl->robots[R]->kicker->kick(8,0);break;
case 'l':case 'L': ssl->robots[R]->kicker->kick(3,3);break;
case 'j':case 'J': ssl->robots[R]->kicker->toggleRoller();break;
case 'i':case 'I': dBodySetLinearVel(ssl->ball->body,2.0,0,0);dBodySetAngularVel(ssl->ball->body,0,2.0/cfg->BallRadius(),0);break;
case ';':
Expand Down Expand Up @@ -485,7 +491,30 @@ void GLWidget::reform(int team,const QString& act)
if (act==tr("Put all inside with formation 2")) forms[3]->resetRobots(ssl->robots,team);
if (act==tr("Put all outside") && team==0) forms[0]->resetRobots(ssl->robots,team);
if (act==tr("Put all outside") && team==1) 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 out of field")) forms[4]->resetRobots(ssl->robots,team);

if(act==tr("Turn all off")) {
for(int i=0; i<ROBOT_COUNT; i++) {
int k = robotIndex(i, team);
if(ssl->robots[k]->on==true) {
ssl->robots[k]->on = false;
onOffRobotAct->setText("Turn &on");
emit robotTurnedOnOff(k, false);
}
}
}

if(act==tr("Turn all on")) {
for(int i=0; i<ROBOT_COUNT; i++) {
int k = robotIndex(i, team);
if(ssl->robots[k]->on==false) {
ssl->robots[k]->on = true;
onOffRobotAct->setText("Turn &off");
emit robotTurnedOnOff(k, true);
}
}
}

}

void GLWidget::moveBallHere()
Expand Down
59 changes: 45 additions & 14 deletions src/proto/messages_robocup_ssl_geometry.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
// A 2D float vector.
message Vector2f {
required float x = 1;
required float y = 2;
}

// Represents a field marking as a line segment represented by a start point p1,
// and end point p2, and a line thickness. The start and end points are along
// the center of the line, so the thickness of the line extends by thickness / 2
// on either side of the line.
message SSL_FieldLineSegment {
// Name of this field marking.
required string name = 1;
// Start point of the line segment.
required Vector2f p1 = 2;
// End point of the line segment.
required Vector2f p2 = 3;
// Thickness of the line segment.
required float thickness = 4;
}

// Represents a field marking as a circular arc segment represented by center point, a
// start angle, an end angle, and an arc thickness.
message SSL_FieldCicularArc {
// Name of this field marking.
required string name = 1;
// Center point of the circular arc.
required Vector2f center = 2;
// Radius of the arc.
required float radius = 3;
// Start angle in counter-clockwise order.
required float a1 = 4;
// End angle in counter-clockwise order.
required float a2 = 5;
// Thickness of the arc.
required float thickness = 6;
}

message SSL_GeometryFieldSize {
required int32 line_width = 1;
required int32 field_length = 2;
required int32 field_width = 3;
required int32 boundary_width = 4;
required int32 referee_width = 5;
required int32 goal_width = 6;
required int32 goal_depth = 7;
required int32 goal_wall_width = 8;
required int32 center_circle_radius = 9;
required int32 defense_radius = 10;
required int32 defense_stretch = 11;
required int32 free_kick_from_defense_dist = 12;
required int32 penalty_spot_from_field_line_dist = 13;
required int32 penalty_line_from_spot_dist = 14;
required int32 field_length = 1;
required int32 field_width = 2;
required int32 goal_width = 3;
required int32 goal_depth = 4;
required int32 boundary_width = 5;
repeated SSL_FieldLineSegment field_lines = 6;
repeated SSL_FieldCicularArc field_arcs = 7;
}

message SSL_GeometryCameraCalibration {
Expand Down
Loading

0 comments on commit ef7000e

Please sign in to comment.