Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
spl.h
1
2
/***************************************************************************
3
* spl.h - Fawkes SPL refbox repeater
4
*
5
* Created: Tue Jul 08 13:46:19 2008
6
* Copyright 2008 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef __TOOLS_REFBOXREP_SPL_H_
24
#define __TOOLS_REFBOXREP_SPL_H_
25
26
#include "refbox_state_sender.h"
27
#include <cstdlib>
28
#include <stdint.h>
29
#include <map>
30
31
namespace
fawkes {
32
class
DatagramSocket;
33
}
34
35
#define GCHS 4
36
#define MAX_NUM_PLAYERS 11
37
#pragma pack(push,4)
38
/** SPL RefBox protocol robot info struct. */
39
typedef
struct
{
40
uint16_t penalty;
/**< penalty state of the player */
41
uint16_t secs_till_unpenalized;
/**< estimate of time till unpenalised */
42
}
spl_robotinfo_t
;
43
44
/** SPL RefBox protocol team info struct. */
45
typedef
struct
{
46
uint8_t team_number;
/**< unique team number */
47
uint8_t team_color;
/**< colour of the team */
48
uint16_t
score
;
/**< team's score */
49
spl_robotinfo_t
players[MAX_NUM_PLAYERS];
/**< the team's players */
50
}
spl_teaminfo_t
;
51
52
/** SPL RefBox protocol game control struct. */
53
typedef
struct
{
54
char
header[GCHS];
/**< header to identify the structure */
55
uint32_t version;
/**< version of the data structure */
56
uint8_t players_per_team;
/**< The number of players on a team */
57
uint8_t state;
/**< state of the game (STATE_READY, STATE_PLAYING, etc) */
58
uint8_t first_half;
/**< 1 = game in first half, 0 otherwise */
59
uint8_t kick_off_team;
/**< the next team to kick off */
60
uint8_t secondary_state;
/**< Extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc) */
61
uint8_t drop_in_team;
/**< team that caused last drop in */
62
uint16_t
drop_on_time
;
/**< number of seconds passed since the last drop in. -1 before first dropin */
63
uint32_t secs_remaining;
/**< estimate of number of seconds remaining in the half */
64
spl_teaminfo_t
teams[2];
/**< Info about the teams */
65
}
spl_gamecontrol_t
;
66
#pragma pack(pop)
67
68
class
SplRefBoxRepeater
69
{
70
public
:
71
SplRefBoxRepeater
(
RefBoxStateSender
&rss,
72
const
char
*broadcast_ip,
unsigned
short
int
broadcast_port,
73
fawkes::worldinfo_gamestate_team_t
our_team,
74
fawkes::worldinfo_gamestate_goalcolor_t
our_goal);
75
~SplRefBoxRepeater
();
76
77
void
run
();
78
79
private
:
80
81
82
void
process_struct(
spl_gamecontrol_t
*msg);
83
84
private
:
85
RefBoxStateSender
&__rss;
86
fawkes::DatagramSocket
*__s;
87
88
bool
__quit;
89
std::map<unsigned int, unsigned int> __penalties;
90
91
fawkes::worldinfo_gamestate_team_t
__our_team;
92
fawkes::worldinfo_gamestate_goalcolor_t
__our_goal;
93
};
94
95
#endif
src
tools
refboxrep
spl.h
Generated by
1.8.1.1