LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
audio_sensor.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_PLAYER_AUDIO_SENSOR_H
33#define RCSC_PLAYER_AUDIO_SENSOR_H
34
39
40#include <rcsc/game_time.h>
41#include <rcsc/types.h>
42#include <rcsc/geom/vector_2d.h>
43
44#include <string>
45#include <unordered_map>
46#include <list>
47#include <vector>
48
49namespace rcsc {
50
51/*-------------------------------------------------------------------*/
57private:
58
60 typedef std::unordered_map< char, SayMessageParser::Ptr > ParserMap;
61 typedef std::unordered_map< std::string, FreeformMessageParser::Ptr > FreeformParserMap;
62
64 ParserMap M_say_message_parsers;
65
67 FreeformParserMap M_freeform_parsers;
68
70 GameTime M_teammate_message_time;
71
73 std::list< HearMessage > M_teammate_messages;
74
76 GameTime M_opponent_message_time;
77
79 std::list< HearMessage > M_opponent_messages;
80
82 GameTime M_freeform_message_time;
83
85 std::string M_freeform_message;
86
88 GameTime M_trainer_message_time;
89
91 std::string M_trainer_message;
92
94 GameTime M_clang_time;
95
97 std::string M_clang_message;
98
100 CLangParser M_clang_parser;
101
102public:
107
113
118 void removeSayMessageParser( const char header );
119
125
130 void removeFreeformMessageParser( const std::string & type );
131
137 void parsePlayerMessage( const char * msg,
138 const GameTime & current );
139
145 void parseCoachMessage( const char * msg,
146 const GameTime & current );
147
153 void parseTrainerMessage( const char * msg,
154 const GameTime & current );
155
161 {
162 return M_teammate_message_time;
163 }
164
169 const std::list< HearMessage > & teammateMessages() const
170 {
171 return M_teammate_messages;
172 }
173
179 {
180 return M_opponent_message_time;
181 }
182
187 const std::list< HearMessage > & opponentMessages() const
188 {
189 return M_opponent_messages;
190 }
191
196 const
198 {
199 return M_freeform_message_time;
200 }
201
206 const std::string & freeformMessage() const
207 {
208 return M_freeform_message;
209 }
210
216 {
217 return M_trainer_message_time;
218 }
219
224 const std::string & trainerMessage() const
225 {
226 return M_trainer_message;
227 }
228
233 const GameTime & clangTime() const
234 {
235 return M_clang_time;
236
237 }
238
243 const std::string & clangMessage() const
244 {
245 return M_clang_message;
246 }
247
252 const CLangParser & clangParser() const
253 {
254 return M_clang_parser;
255 }
256
257private:
258 /*
259 \brief analyze message from teammate
260 \param message message object from teammate
261 */
262 void parseTeammateMessage( const HearMessage & message );
263
268 void buildFreeformMessage( const char * msg );
269
274 bool parseFreeformMessage();
275
276
281 void buildCLangMessage( const char * msg );
282
287 bool parseCLangMessage();
288
289};
290
291}
292
293#endif
abstract audio message parser Header File
clang parser class Header File
processor for players' communication
Definition: audio_sensor.h:56
void parseCoachMessage(const char *msg, const GameTime &current)
analyze message from online coach
void parseTrainerMessage(const char *msg, const GameTime &current)
analyze trainer's audio message
const GameTime & freeformMessageTime() const
get the time when last freeform message is received
Definition: audio_sensor.h:197
void removeSayMessageParser(const char header)
remove registered parser object
const CLangParser & clangParser() const
get the clang parser object
Definition: audio_sensor.h:252
const std::list< HearMessage > & opponentMessages() const
get the last received opponent messages
Definition: audio_sensor.h:187
const GameTime & opponentMessageTime() const
get time when opponent message is received
Definition: audio_sensor.h:178
void removeFreeformMessageParser(const std::string &type)
remove registerd freeform parser object
void addSayMessageParser(SayMessageParser::Ptr parser)
add new player message parer.
const GameTime & teammateMessageTime() const
get time when teammate message is received
Definition: audio_sensor.h:160
void parsePlayerMessage(const char *msg, const GameTime &current)
analyze other player's audio message
const GameTime & trainerMessageTime() const
get the time when last freeform message is received
Definition: audio_sensor.h:215
AudioSensor()
init member variables by default value
const std::string & freeformMessage() const
get the last received freeform message
Definition: audio_sensor.h:206
const std::string & trainerMessage() const
get the last received trainer message info
Definition: audio_sensor.h:224
void addFreeformMessageParser(FreeformMessageParser::Ptr parser)
set new freeform message parer.
const std::list< HearMessage > & teammateMessages() const
get the last received teammate messages
Definition: audio_sensor.h:169
const std::string & clangMessage() const
get the last clang message
Definition: audio_sensor.h:243
const GameTime & clangTime() const
get the time when last clang is received.
Definition: audio_sensor.h:233
clang message parser
Definition: clang_parser.h:46
std::shared_ptr< FreeformMessageParser > Ptr
pointer type
Definition: freeform_message_parser.h:48
game time object
Definition: game_time.h:43
std::shared_ptr< SayMessageParser > Ptr
pointer type alias
Definition: say_message_parser.h:54
coach's freeform message parser Header File
game time depending on RCSSServer2D Header File
player's say message parser Header File
player message instance
Definition: audio_message.h:48
the type definition set for the RCSSServer2D
2d vector class Header File.