forked from RoboCup-SSL/grSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sslworld.h
106 lines (90 loc) · 2.65 KB
/
sslworld.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
grSim - RoboCup Small Size Soccer Robots Simulator
Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SSLWORLD_H
#define SSLWORLD_H
#include <QGLWidget>
#include <QObject>
#include <QUdpSocket>
#include <QList>
#include "Graphics/graphics.h"
#include "Physics/pworld.h"
#include "Physics/pball.h"
#include "Physics/pground.h"
#include "Physics/pfixedbox.h"
#include "Physics/pray.h"
#include "proto/robocup_ssl_server.h"
#include "robot.h"
#include "configwidget.h"
#define ROBOT_COUNT 5
class RobotsFomation;
class SendingPacket {
public:
SendingPacket(SSL_WrapperPacket* _packet,int _t);
SSL_WrapperPacket* packet;
int t;
};
class SSLWorld : public QObject
{
Q_OBJECT
private:
QGLWidget* m_parent;
int framenum;
dReal last_dt;
QList<SendingPacket*> sendQueue;
char packet[200];
char *in_buffer;
public:
dReal customDT;
bool isGLEnabled;
SSLWorld(QGLWidget* parent,ConfigWidget* _cfg,RobotsFomation *form1,RobotsFomation *form2);
virtual ~SSLWorld();
void glinit();
void step(dReal dt=-1);
SSL_WrapperPacket* generatePacket();
void sendVisionBuffer();
ConfigWidget* cfg;
CGraphics* g;
PWorld* p;
PBall* ball;
PGround* ground;
PRay* ray;
PFixedBox* walls[10];
int selected;
bool show3DCursor;
dReal cursor_x,cursor_y,cursor_z;
dReal cursor_radius;
RoboCupSSLServer *visionServer;
QUdpSocket *commandSocket;
QUdpSocket *blueStatusSocket,*yellowStatusSocket;
bool updatedCursor;
Robot* robots[ROBOT_COUNT*2];
QTime *timer;
public slots:
void recvActions();
signals:
void fpsChanged(int newFPS);
};
class RobotsFomation {
public:
dReal x[ROBOT_COUNT];
dReal y[ROBOT_COUNT];
RobotsFomation(int type);
void setAll(dReal *xx,dReal *yy);
void loadFromFile(const QString& filename);
void resetRobots(Robot** r,int team);
};
dReal fric(dReal f);
int robotIndex(int robot,int team);
#endif // SSLWORLD_H