LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
coach_command.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_COACH_COMMAND_H
33#define RCSC_COACH_COMMAND_H
34
35#include <rcsc/types.h>
36
37#include <string>
38#include <vector>
39#include <utility>
40#include <iostream>
41
42namespace rcsc {
43
49public:
53 enum Type {
54 INIT,
55 BYE,
56
57 CHECK_BALL,
58 LOOK,
59 TEAM_NAMES,
60
61 EYE,
62
63 CHANGE_PLAYER_TYPE,
64 CHANGE_PLAYER_TYPES,
65
66 CLANG_FREEFORM,
67
68 TEAM_GRAPHIC,
69 COMPRESSION,
70 DONE,
71
72 ILLEGAL
73 };
74
75 /*
76 enum CLangType {
77 CLANG_META,
78 CLANG_FREEFORM,
79 CLANG_INFO,
80 CLANG_ADVICE,
81 CLANG_DEFINE,
82 CLANG_ADVISE,
83 CLANG_ILLEGAL
84 };
85 */
86
87protected:
92 { }
93
94public:
98 virtual
100 { }
101
106 virtual
107 Type type() const = 0;
108
114 virtual
115 std::ostream & toCommandString( std::ostream & to ) const = 0;
116
121 virtual
122 std::string name() const = 0;
123};
124
125
127
141 : public CoachCommand {
142private:
143 std::string M_team_name;
144 double M_version;
145 std::string M_coach_name;
146public:
153 CoachInitCommand( const std::string & team_name,
154 const double & version,
155 const std::string & coach_name = "" );
156
161 Type type() const
162 {
163 return INIT;
164 }
165
171 std::ostream & toCommandString( std::ostream & to ) const;
172
177 std::string name() const
178 {
179 return std::string( "init" );
180 }
181};
182
184
194 : public CoachCommand {
195private:
196
197public:
202 { }
203
208 Type type() const
209 {
210 return BYE;
211 }
212
218 std::ostream & toCommandString( std::ostream & to ) const;
219
224 std::string name() const
225 {
226 return std::string( "bye" );
227 }
228};
229
231
245 : public CoachCommand {
246private:
247
248public:
253 { }
254
259 Type type() const
260 {
261 return CHECK_BALL;
262 }
263
269 std::ostream & toCommandString( std::ostream & to ) const;
270
275 std::string name() const
276 {
277 return std::string( "check_ball" );
278 }
279};
280
282
294 : public CoachCommand {
295private:
296
297public:
302 { }
303
308 Type type() const
309 {
310 return LOOK;
311 }
312
318 std::ostream & toCommandString( std::ostream & to ) const;
319
324 std::string name() const
325 {
326 return std::string( "look" );
327 }
328};
329
331
343 : public CoachCommand {
344private:
345
346public:
351 { }
352
357 Type type() const
358 {
359 return TEAM_NAMES;
360 }
361
367 std::ostream & toCommandString( std::ostream & to ) const;
368
373 std::string name() const
374 {
375 return std::string( "team_names" );
376 }
377};
378
380
392 : public CoachCommand {
393private:
394 bool M_on;
395public:
400 explicit
402 : M_on( on )
403 { }
404
409 Type type() const
410 {
411 return EYE;
412 }
413
419 std::ostream & toCommandString( std::ostream & to ) const;
420
425 std::string name() const
426 {
427 return std::string( "eye" );
428 }
429};
430
432
451 : public CoachCommand {
452private:
453 int M_unum;
454 int M_type;
455public:
462 const int type )
463 : M_unum( unum )
464 , M_type( type )
465 { }
466
471 Type type() const
472 {
473 return CHANGE_PLAYER_TYPE;
474 }
475
481 std::ostream & toCommandString( std::ostream & to ) const;
482
487 std::string name() const
488 {
489 return std::string( "change_player_type" );
490 }
491};
492
493
495
514 : public CoachCommand {
515private:
517 std::vector< std::pair< int, int > > M_types;
518
519public:
526 const int type );
527
532 CoachChangePlayerTypesCommand( const std::vector< std::pair< int, int > > & types );
533
539 void add( const int unum,
540 const int type );
541
546 Type type() const
547 {
548 return CHANGE_PLAYER_TYPES;
549 }
550
556 std::ostream & toCommandString( std::ostream & to ) const;
557
562 std::string name() const
563 {
564 return std::string( "change_player_types" );
565 }
566};
567
569
591 : public CoachCommand {
592private:
594 const double M_version;
596 const std::string & M_message;
597
598 // not used
599 CoachFreeformCommand() = delete;
600 CoachFreeformCommand( const CoachCommand & ) = delete;
601 CoachFreeformCommand & operator=( const CoachCommand & ) = delete;
602public:
607 CoachFreeformCommand( const double & version,
608 const std::string & message )
609 : CoachCommand(),
610 M_version( version ),
611 M_message( message )
612 { }
613
618 Type type() const
619 {
620 return CLANG_FREEFORM;
621 }
622
628 std::ostream & toCommandString( std::ostream & to ) const;
629
634 std::string name() const
635 {
636 return std::string( "freeform" );
637 }
638};
639
641
657 : public CoachCommand {
658private:
659 unsigned int M_x;
660 unsigned int M_y;
661 std::vector< std::string > M_xpm_lines;
662
663public:
670 CoachTeamGraphicCommand( const unsigned int x,
671 const unsigned int y,
672 const std::vector< std::string > & xpm_lines );
673
678 Type type() const
679 {
680 return TEAM_GRAPHIC;
681 }
682
688 std::ostream & toCommandString( std::ostream & to ) const;
689
694 std::string name() const
695 {
696 return std::string( "team_graphic" );
697 }
698};
699
700
702
715 : public CoachCommand {
716private:
717 int M_level;
718public:
722 explicit
723 CoachCompressionCommand( const int level )
724 : M_level( level )
725 { }
726
731 Type type() const
732 {
733 return COMPRESSION;
734 }
735
741 std::ostream & toCommandString( std::ostream & to ) const;
742
747 std::string name() const
748 {
749 return std::string( "compression" );
750 }
751};
752
753
755
765 : public CoachCommand {
766private:
767
768public:
773 { }
774
779 Type type() const
780 {
781 return DONE;
782 }
783
789 std::ostream & toCommandString( std::ostream & to ) const;
790
795 std::string name() const
796 {
797 return std::string( "done" );
798 }
799};
800
801}
802
803/*
804
805Online Coach Initialization Command
806 See rcssserver/src/netif.C : void Stadium::parseOnlineCoachInit
807 rcssserver/src/field.C : OnlineCoach* Stadium::newCoach
808
809if illegal command
810 -> "(error illegal_command_form)"
811----------
812 Coach's default version is 5.0
813
814"(init TEAM_NAME (version VERSION))"
815 if TEAM_NAME and VERSION is illegal
816 -> "(error no_such_team_or_already_have_coach)"
817 else
818 if VERSION >= 6.0
819 -> "(init l ok)" or "(init r ok)"
820 else
821 -> "(init ok)"
822
823 receive parameter info
824 receive changed players info
825 receive each player's clang version
826
827 if VERSION >= 7.0
828 -> "(server_param ...)" "(player_param ...)" "(player_type ...)"x7
829 -> "(change_player_type UNUM ID)" "(change_player_type UNUM)" "(change_player_type TEAM_NAME UNUM ID)"
830 if VERSION >= 8.0
831 -> "(clang (ver PLAYER_SHORT_NAME MIN MAX))"
832----------
833
834----------
835
836----------
837Online Coach Command List
838 See rcssserver/src/netif.C : void Coach::parse_command(const char *command)l
839
840if use illegal character for command string
841 -> "(error illegal_command_form)"
842else if illegal command
843 -> "(error unknown_command)"
844
845----------
846"(check_ball)" : check ball positional state
847 -> (ok check_ball BALL_POS_INFO)
848 BALL_POS_INFO :- "in_field" | "goal_l" | "goal_r" | "out_of_field"
849----------
850"(look)" : get all movable objects' positional information
851 -> "(ok look TIME GOAL_INFO BALL_INFO PLAYER_INFO ...)"
852----------
853"(team_names)" : get team name
854 -> "(ok team_names (team l TEAM_NAME) (team r TEAM_NAME))"
855----------
856"(say MESSAGE)" : say advice message (if version > 7.0, it must be CLang.)
857 if version >= 7.0
858 {
859 if MESSAGE cannot be parsed
860 -> "(error could_not_parse_say)"
861 else
862 {
863 if MESSAGE is MetaType
864 if MetaType has no left
865 -> "(error said_too_many_meta_messages)"
866 else
867 -> "(ok say)"
868 else if MESSAGE is FreeFormType
869 if FreeFormType is enable now
870 if FreeFormType has no left
871 -> "(error said_too_many_freeform_messages)"
872 else
873 -> "(ok say)"
874 else
875 -> "(error cannot_say_freeform_while_playon)"
876 else if MESSAGE is InfoType
877 if InfoType has no left
878 -> "(error said_too_many_info_messages)"
879 else
880 -> "(ok say)"
881 else if MESSAGE is AdviceType
882 if AdviceType has no left
883 -> "(error said_too_many_advice_messages)"
884 else
885 -> "(ok say)"
886 else if MESSAGE is DefineType
887 if DefineType has no left
888 -> "(error said_too_many_define_messages)"
889 else
890 -> "(ok say)"
891 else if MESSAGE is DeleteType
892 if DeleteType has no left
893 -> "(error said_too_many_del_messages)"
894 else
895 -> "(ok say)"
896 else if MESSAGE is RuleType
897 if RuleType has no left
898 -> "(error said_too_many_rule_messages)"
899 else
900 -> "(ok say)"
901 }
902 }
903 else // version < 7.0, CLang is not supported
904 {
905 if playmode is PlayOn
906 -> "(warning cannot_say_while_playon)"
907 else if coach's say has no left
908 -> "(error said_too_many_messages)"
909 else
910 if MESSAGE uses illegal charcter or is NULL string
911 -> "(error illegal_command_form)"
912 else
913 -> "(ok say)"
914 }
915----------
916"(bye)" : close connection
917----------
918"(eye ONOFF)" : turn on/off to get visual info
919 if ONOFF is NULL
920 -> "(error illegal_command_form)"
921 else if ONOFF_MODE == "on"
922 -> "(ok eye on)"
923 else if ONOFF_MODE == "off"
924 -> "(ok eye off)"
925 else
926 -> "(error illegal_command_form)"
927----------
928"(change_player_type UNUM PLAYER_TYPE_ID)" : change hetero player type
929 if playmode is PlayOn
930 -> "(warning cannot_sub_while_playon)"
931 else if coach's side is Unknown
932 -> "(warning no_team_found)"
933 else if team_subs_count == subsMax
934 -> "(warning no_subs_left)"
935 else if UNUM or PLAYER_TYPE_ID has illegal form (eg. NULL string)
936 -> "(error illegal_command_form)"
937 else if PLAYER_TYPE_ID is out of range (ID<0 or PlayerTypes<ID)
938 -> "(error out_of_range_player_type)"
939 else if UNUM is not match
940 -> "(warning no_such_player)"
941 else if player is goalie && PLAYER_TYPE_ID != 0
942 -> "(warning cannot_change_goalie)"
943 else if ID != 0 && ID's player count == ptMax() && player's id != ID
944 -> "(warning max_of_that_type_on_field)"
945 else
946 -> "(ok change_player_type UNUM PLAYER_TYPE_ID)\n
947----------
948"(done)" : thinking end nortification for sync mode
949----------
950"(compression LEVEL)" : set zlib compression level
951 if LEVEL is NULL string
952 -> "(error illegal_command_form)"
953 else if not HAVE_LIBZ
954 -> "(warning compression_unsupported)"
955 else if (LEVEL < 0 || 9 < LEVEL)
956 -> "(error illegal_command_form)"
957 else
958 -> "(ok compression LEVEL)"
959----------
960"(team_graphic (X Y "XPMLINE" ... "XPMLINE"))" : change team graphic on rcssmonitor
961 if playmode is not BeforeKickOff
962 -> "warning only_before_kick_off"
963 else if X or Y is illegal (eg. NULL string)
964 -> "(error illegal_command_form)"
965 else if (X >= 32 || Y = 8)
966 -> "(warning invalid_tile_location)"
967 else if (xpm's width != 8 || xpm's height != 8)
968 -> "(warning invalid_tile_size)"
969 else
970 -> "(ok team_graphic X Y)"
971----------
972*/
973
974
975#endif
command to disconnect
Definition: coach_command.h:194
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
CoachByeCommand()
constructor. nothing to do
Definition: coach_command.h:201
Type type() const
get command type
Definition: coach_command.h:208
std::string name() const
get command name
Definition: coach_command.h:224
command to change player type
Definition: coach_command.h:451
CoachChangePlayerTypeCommand(const int unum, const int type)
construct with target number and type id
Definition: coach_command.h:461
Type type() const
get command type
Definition: coach_command.h:471
std::string name() const
get command name
Definition: coach_command.h:487
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
command to change player type
Definition: coach_command.h:514
void add(const int unum, const int type)
add new change_player_type pair
CoachChangePlayerTypesCommand(const int unum, const int type)
construct with one target player and type id
std::string name() const
get command name
Definition: coach_command.h:562
CoachChangePlayerTypesCommand(const std::vector< std::pair< int, int > > &types)
construct with one target player and type id
Type type() const
get command type
Definition: coach_command.h:546
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
command to require ball status
Definition: coach_command.h:245
CoachCheckBallCommand()
constructor. nothing to do
Definition: coach_command.h:252
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
Type type() const
get command type
Definition: coach_command.h:259
std::string name() const
get command name
Definition: coach_command.h:275
abstract coach command class
Definition: coach_command.h:48
virtual ~CoachCommand()
virtual destructor, but nothing to do
Definition: coach_command.h:99
virtual Type type() const =0
get command type (pure virtual)
virtual std::ostream & toCommandString(std::ostream &to) const =0
put command string to ostream (pure virtual)
Type
online coach command type Id
Definition: coach_command.h:53
CoachCommand()
constructor is protected because this is abstract class.
Definition: coach_command.h:91
virtual std::string name() const =0
get command name (pure virtual)
command to set message compression level
Definition: coach_command.h:715
CoachCompressionCommand(const int level)
construct with compression level
Definition: coach_command.h:723
Type type() const
get command type
Definition: coach_command.h:731
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
std::string name() const
get command name
Definition: coach_command.h:747
command to send done command for (think) message in synch_mode
Definition: coach_command.h:765
CoachDoneCommand()
constructor. nothing to do
Definition: coach_command.h:772
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
Type type() const
get command type
Definition: coach_command.h:779
std::string name() const
get command name
Definition: coach_command.h:795
command to enable/disable coach's eye
Definition: coach_command.h:392
std::string name() const
get command name
Definition: coach_command.h:425
CoachEyeCommand(bool on)
construct with eye mode switch
Definition: coach_command.h:401
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
Type type() const
get command type
Definition: coach_command.h:409
freeform message command
Definition: coach_command.h:591
std::string name() const
get command name
Definition: coach_command.h:634
Type type() const
get command type
Definition: coach_command.h:618
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
CoachFreeformCommand(const double &version, const std::string &message)
construct with message string.
Definition: coach_command.h:607
initial connection command for coach
Definition: coach_command.h:141
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
std::string name() const
get command name
Definition: coach_command.h:177
CoachInitCommand(const std::string &team_name, const double &version, const std::string &coach_name="")
construct with init parameters
Type type() const
get command type
Definition: coach_command.h:161
commad to require field status
Definition: coach_command.h:294
std::string name() const
get command name
Definition: coach_command.h:324
CoachLookCommand()
constructor. nothing to do
Definition: coach_command.h:301
Type type() const
get command type
Definition: coach_command.h:308
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
command to send a tile of xpm team graphic
Definition: coach_command.h:657
CoachTeamGraphicCommand(const unsigned int x, const unsigned int y, const std::vector< std::string > &xpm_lines)
construct with xpm string and its coordinate.
std::string name() const
get command name
Definition: coach_command.h:694
Type type() const
get command type
Definition: coach_command.h:678
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
command to require team names
Definition: coach_command.h:343
std::string name() const
get command name
Definition: coach_command.h:373
CoachTeamNamesCommand()
constructor. nothing to do
Definition: coach_command.h:350
std::ostream & toCommandString(std::ostream &to) const
put command string to ostream
Type type() const
get command type
Definition: coach_command.h:357
the type definition set for the RCSSServer2D
const char * version()
get the package version number string.