Skip to content
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

Kamran #6

Open
wants to merge 8 commits into
base: master
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified AUTHORS.txt
100644 → 100755
Empty file.
Empty file modified LICENSE.txt
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
KN2C-Program
========

Expand Down Expand Up @@ -38,3 +39,8 @@ Faraz Fallahi ([email protected]) <br />
Milad AbaieRad ([email protected] ) <br />
Mohsen Raoufi ([email protected]) <br />



=======
# MergeTest
>>>>>>> 28ea424bd019bb77bc1ab02977d2f91922110bed
Empty file modified autocompile.sh
100644 → 100755
Empty file.
Empty file modified autorun.sh
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions config/settings.ini
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
; KN2C SSL Configuration File

[Game]
Mode=Real;Simulation;
Mode=Simulation;Real;
[Team]
Color =Yellow;Blue;
Color =Blue;Yellow;
Side =Left;Right;
[Field]
Size = Double;Single;
[Transmitter]
SerialPort = /dev/ttyUSB1
SerialPort = /dev/ttyUSB0

[VisionConfig]
UsingCameras = 7;CAMERA_NONE = 0, CAMERA_0 = 1, CAMERA_1 = 2, CAMERA_2 = 3, CAMERA_3 = 4, CAMERA_BOTH_L = 5,CAMERA_BOTH_R = 6,CAMERA_ALL = 7
Expand All @@ -17,11 +17,11 @@ UsingCameras = 7;CAMERA_NONE = 0, CAMERA_0 = 1, CAMERA_1 = 2, CAMERA_2 = 3, CAME
RefereeBall = 100

[Simulation]
RefIP = 224.5.23.1
RefIP = 224.5.23.1;127.0.0.1;
RefPort = 10001
RefPortNew = 10003
RefUseNew = 1
VisionIP = 224.5.23.6;127.0.0.1;
VisionIP = 127.0.0.1;224.5.23.6;
VisionPort = 10020

[Real]
Expand All @@ -33,7 +33,7 @@ VisionIP = 224.5.23.2
VisionPort = 10006

[grSim]
CommandIP = 224.5.23.6;127.0.0.1;
CommandIP = 127.0.0.1;224.5.23.6;
CommandPort = 20011
BluePort = 30011
YellowPort = 30012
Expand Down
Empty file modified config/vars.ini
100644 → 100755
Empty file.
Empty file modified config/vars_sim.ini
100644 → 100755
Empty file.
Empty file modified old_code/skill/skillkick.cpp
100644 → 100755
Empty file.
Empty file modified old_code/skill/skillkick.h
100644 → 100755
Empty file.
Empty file modified old_code/tactic/tacticblock.cpp
100644 → 100755
Empty file.
Empty file modified old_code/tactic/tacticblock.h
100644 → 100755
Empty file.
Empty file modified old_code/tactic/tacticstop.cpp
100644 → 100755
Empty file.
Empty file modified old_code/tactic/tacticstop.h
100644 → 100755
Empty file.
Empty file modified src/3rdparty/fsa.h
100644 → 100755
Empty file.
Empty file modified src/3rdparty/stlastar.h
100644 → 100755
Empty file.
Empty file modified src/ai/Skills.h
100644 → 100755
Empty file.
12 changes: 12 additions & 0 deletions src/ai/Skills.h.autosave
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SKILLS_H
#define SKILLS_H

#include "skill.h"
#include "skill/skillkick.h"
#include "skill/skilltest.h"
#include "skill/skillonetouch.h"
#include "skill/skillpassreceive.h"
//seyed ali hejazi
#include "skill/shootball.h"

#endif // SKILLS_H
43 changes: 16 additions & 27 deletions src/ai/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Agent::Agent() :
{
wm = 0;
id = -1;

ctrl = new Controller();
}

void Agent::setID(int id)
Expand All @@ -31,33 +29,31 @@ void Agent::SendCommand(RobotCommand rc)
{
if(!wm->ourRobot[id].isValid) return;

if( id == 0 ) wm->debug_pos.clear();
ControllerInput ci = nav.calc(rc);
ControllerResult co = ctrl->calc(ci);

if( !controllerResultIsValid(co) )
if( id == 0 )
{
delete ctrl;
ctrl = new Controller();
wm->debug_pos.append(ci.mid_pos.loc);
wm->debug_pos.append(ci.cur_pos.loc);
}

ControllerResult co = ctrl.calc(ci);

// Real Game Packet
RobotData reRD;
reRD.RID = id;
reRD.Vx_sp = co.rs.VX * 1000;
reRD.Vy_sp = co.rs.VY * 1000;
reRD.Wr_sp = co.rs.VW * 1000;
reRD.Vx = wm->ourRobot[id].vel.loc.x * 1000;
reRD.Vy = wm->ourRobot[id].vel.loc.y * 1000;
reRD.Wr = wm->ourRobot[id].vel.dir * 100;
reRD.alpha = wm->ourRobot[id].pos.dir * 1000;
reRD.KICK = (quint8) rc.kickspeedx;
reRD.CHIP = (quint8) rc.kickspeedz;
reRD.SPIN = 128;//for test
reRD.RID = id;
reRD.M0 = co.msR.M0;
reRD.M1 = co.msR.M1;
reRD.M2 = co.msR.M2;
reRD.M3 = co.msR.M3;
reRD.KCK = (quint8) rc.kickspeedx;
reRD.CHP = (quint8) rc.kickspeedz;

outputBuffer->wpck.AddRobot(reRD);


// grSim Packet
grRobotData grRD;

grRD.rid = id;
grRD.velx = co.rs.VX;
grRD.vely = co.rs.VY;
Expand Down Expand Up @@ -106,14 +102,7 @@ bool Agent::grSimPacketIsValid(grRobotData grRD)
if( !isnan(grRD.velx) && !isnan(grRD.vely) && !isnan(grRD.velw) &&
!isnan(grRD.wheel1) && !isnan(grRD.wheel2) && !isnan(grRD.wheel3) && !isnan(grRD.wheel4) )
return true;

return false;
}

bool Agent::controllerResultIsValid(ControllerResult co)
{
if( isnan(co.rs.VW) || isnan(co.rs.VX) || isnan(co.rs.VY) )
return false;

return true;
}

2 changes: 1 addition & 1 deletion src/ai/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Agent : public Robot

private:
int id;
Controller *ctrl;
Controller ctrl;
Navigation nav;
OutputBuffer *outputBuffer;
WorldModel *wm;
Expand Down
4 changes: 4 additions & 0 deletions src/ai/ai.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
#include "play/playtest2.h"
#include "play/playlearning.h"
#include "play/playformations.h"
//ali hejazi
#include "play/playhw2_1.h"
#include "play/mantomandefense.h"

AI::AI(WorldModel *worldmodel, QString field_size, OutputBuffer *outputbuffer, QObject *parent) :
QObject(parent),
wm(worldmodel),
outputbuffer(outputbuffer)
{
qDebug() << "AI Initialization...";
qDebug()<<"WTF WTF WTF";
connect(&timer, SIGNAL(timeout()), this, SLOT(timer_timeout()));

Field::setup_consts(field_size);
Expand Down
Empty file modified src/ai/ai.h
100644 → 100755
Empty file.
Empty file modified src/ai/knowledge.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/knowledge.h
100644 → 100755
Empty file.
Empty file modified src/ai/learning/hillclimbing.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/learning/hillclimbing.h
100644 → 100755
Empty file.
Empty file modified src/ai/learning/kick_learning.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/learning/kick_learning.h
100644 → 100755
Empty file.
Empty file modified src/ai/learning/policy.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/learning/policy.h
100644 → 100755
Empty file.
Empty file modified src/ai/learning/policyMem.proto
100644 → 100755
Empty file.
Empty file modified src/ai/man2man.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/man2man.h
100644 → 100755
Empty file.
116 changes: 94 additions & 22 deletions src/ai/mapsearchnode.cpp
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include "mapsearchnode.h"
#include "worldmodel.h"

Expand Down Expand Up @@ -82,37 +83,102 @@ bool MapSearchNode::GetSuccessors(AStarSearch<MapSearchNode> *astarsearch, MapSe
wm->navigation_pos.clear();
//kamin

for(int i=0; i<obs.size(); i++)
for(int i=0; i<obs.size(); i++)//obs.size()//-2// test
{
Circle2D obs_circle=obs.at(i);
int p_count = 6;
double p_dist = obs_circle.radius();//2*ROBOT_RADIUS+BALL_RADIUS; //

for(int j=0; j<p_count; j++)
{
Vector2D v(p_dist, p_dist);
v.rotate(360/p_count * j);
MapSearchNode node = obs[i].center() + v;
//kamin
bool checkNodeInterference = true;

for(int g=0;g<obs.size();g++)
if(i<obs.size()-2){
for(int j=0; j<p_count; j++)
{
if(obs[g].contains(node.vec))
Vector2D v(p_dist, p_dist);
v.rotate(360/p_count * j);
MapSearchNode node = obs[i].center() + v;
//kamin
bool checkNodeInterference = true;

for(int g=0;g<obs.size();g++)
{
checkNodeInterference = false;
if(obs[g].contains(node.vec))
{
checkNodeInterference = false;
}
}
}

if(checkNodeInterference == true)
if(checkNodeInterference == true)
{
wm->navigation_pos.append(node.vec);
//kamout
if(node.vec != parent) astarsearch->AddSuccessor(node);
}
}
}
else{
int goal_p_count=8;
for(int j=0; j<goal_p_count; j++)
{
wm->navigation_pos.append(node.vec);
//kamout
if(node.vec != parent) astarsearch->AddSuccessor(node);
Vector2D v(p_dist, p_dist);
v.rotate(360/goal_p_count * j);
MapSearchNode node = obs[i].center() + v;
//kamin
bool checkNodeInterference = true;

for(int g=0;g<obs.size();g++)
{
if(obs[g].contains(node.vec))
{
checkNodeInterference = false;
}
}

if(checkNodeInterference == true)
{
wm->navigation_pos.append(node.vec);
//kamout
if(node.vec != parent) astarsearch->AddSuccessor(node);
}
}
}
}


//test
// for(int i=obs.size()-2; i<obs.size(); i++)
// {
// Circle2D obs_circle=obs.at(i);
// int p_count = 8;
// double p_dist = obs_circle.radius();//2*ROBOT_RADIUS+BALL_RADIUS; //

// for(int j=0; j<p_count; j++)
// {
// Vector2D v(p_dist, p_dist);
// v.rotate(360/p_count * j);
// MapSearchNode node = obs[i].center() + v;
// //kamin
// bool checkNodeInterference = true;

// for(int g=0;g<obs.size();g++)
// {
// if(obs[g].contains(node.vec))
// {
// checkNodeInterference = false;
// }
// }

// if(checkNodeInterference == true)
// {
// wm->navigation_pos.append(node.vec);
// //kamout
// if(node.vec != parent) astarsearch->AddSuccessor(node);
// }
// }
// }


//test

MapSearchNode goal;
goal.vec = astarsearch->GetSolutionEnd()->vec;
astarsearch->AddSuccessor(goal);
Expand Down Expand Up @@ -146,11 +212,8 @@ float MapSearchNode::GetCost(MapSearchNode &successor)
QList<Circle2D> MapSearchNode::getObsCircle()
{
QList<Circle2D> result;

double b_rad = ROBOT_RADIUS + 2*BALL_RADIUS;
double r_rad = ROBOT_RADIUS * 2;


double b_rad = ROBOT_RADIUS + 2*BALL_RADIUS+50;
double r_rad = ROBOT_RADIUS * 2+50;
if(isBallObs && wm->ball.isValid)
{
Circle2D c(wm->ball.pos.loc, b_rad);
Expand All @@ -164,7 +227,7 @@ QList<Circle2D> MapSearchNode::getObsCircle()
Vector2D bloc = wm->ball.pos.loc;

double bang = (bloc - rpos.loc).dir().radian() - rpos.dir;
if (bang > M_PI) bang -= 2 * M_PI;
if (bang > M_PI) bang -= 2 * M_PI;//
if (bang < -M_PI) bang += 2 * M_PI;

if(fabs(bang) > M_PI_4 * 3 / 4)
Expand Down Expand Up @@ -192,6 +255,15 @@ QList<Circle2D> MapSearchNode::getObsCircle()
result.append(c);
}



Circle2D oppGoal(Field::oppGoalCenter,1000);
Circle2D ourGoal(Field::ourGoalCenter,1000);

result.append(oppGoal);
result.append(ourGoal);


// for(int i=0; i<wm->predict_pos.size(); i++)
// {
// Circle2D c(wm->predict_pos[i], b_rad);
Expand Down
Empty file modified src/ai/mapsearchnode.h
100644 → 100755
Empty file.
Empty file modified src/ai/mwbm.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/mwbm.h
100644 → 100755
Empty file.
Empty file modified src/ai/navigation.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/navigation.h
100644 → 100755
Empty file.
3 changes: 1 addition & 2 deletions src/ai/play.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ Tactic* Play::getTactic(int id)
if(id >= PLAYERS_MAX_NUM || id < 0) return NULL;
return tactics[id];
}

bool Play::conditionChanged()
{
bool out;
bool out = true;
QList<int> activeAgents=wm->kn->ActiveAgents();
if(activeAgents.size() != numberOfPlayers)
{
Expand Down
Empty file modified src/ai/play.h
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions src/ai/play/freeKicks/freeKicks.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "freekick10.h"
#include "freekick11.h"
#include "freekick47.h"

//armin sadreddin
#include "freekicktest1.h"
//armin sadreddin
#include "freekickdirect.h"

//kamran
#include"freekicktest2.h"
//kamran
#endif // FREEKICKS_H
2 changes: 1 addition & 1 deletion src/ai/play/freeKicks/freekick1.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void freeKick1::execute()
activeAgents.removeOne(tAttackerMid->getID());
if(wm->cmgs.ourIndirectKick())
{
// recieverID = tAttackerMid->findBestPlayerForPass();
recieverID = tAttackerMid->findBestPlayerForPass();
if(recieverID != -1)
{
wm->ourRobot[recieverID].Status = AgentStatus::RecievingPass;
Expand Down
Empty file modified src/ai/play/freeKicks/freekick1.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick10.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick10.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick11.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick11.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick2.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick2.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick3.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick3.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick4.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick4.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick47.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick47.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick5.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick5.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick6.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick6.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick7.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick7.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick8.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick8.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick9.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick9.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick_base.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekick_base.h
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekickdirect.cpp
100644 → 100755
Empty file.
Empty file modified src/ai/play/freeKicks/freekickdirect.h
100644 → 100755
Empty file.
Loading