soccertypes_8c-source.html

来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 627 行 · 第 1/5 页

HTML
627
字号
00587 <a name="l00592"></a><a class="code" href="classSoccerCommand.html#a5">00592</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#a5">SoccerCommand::isIllegal</a>( )00593 {00594   <font class="keywordflow">return</font> <a class="code" href="classSoccerCommand.html#m1">commandType</a> == <a class="code" href="SoccerTypes_8h.html#a247a180">CMD_ILLEGAL</a>;00595 }00596 <a name="l00604"></a><a class="code" href="classSoccerCommand.html#a7">00604</a> <font class="keywordtype">char</font>*  <a class="code" href="classSoccerCommand.html#a7">SoccerCommand::getCommandString</a>( <font class="keywordtype">char</font> *str, <a class="code" href="classServerSettings.html">ServerSettings</a> *ss )00605 {00606   <a class="code" href="classSoccerCommand.html#o0">SS</a> = ss;00607   <font class="keywordtype">bool</font> b = <font class="keyword">false</font>;00608   <font class="keywordflow">switch</font>( commandType )00609   {00610     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a181">CMD_DASH</a>:        b = <a class="code" href="classSoccerCommand.html#c2">makeDashCommand</a>(         <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00611     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a182">CMD_TURN</a>:        b = <a class="code" href="classSoccerCommand.html#c7">makeTurnCommand</a>(         <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00612     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a183">CMD_TURNNECK</a>:    b = <a class="code" href="classSoccerCommand.html#c8">makeTurnNeckCommand</a>(     <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00613     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a184">CMD_CHANGEVIEW</a>:  b = <a class="code" href="classSoccerCommand.html#c1">makeChangeViewCommand</a>(   <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00614     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a185">CMD_CATCH</a>:       b = <a class="code" href="classSoccerCommand.html#c0">makeCatchCommand</a>(        <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00615     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a186">CMD_KICK</a>:        b = <a class="code" href="classSoccerCommand.html#c3">makeKickCommand</a>(         <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00616     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a187">CMD_MOVE</a>:        b = <a class="code" href="classSoccerCommand.html#c4">makeMoveCommand</a>(         <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00617     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a188">CMD_SENSEBODY</a>:   b = <a class="code" href="classSoccerCommand.html#c6">makeSenseBodyCommand</a>(    <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00618     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a189">CMD_SAY</a>:         b = <a class="code" href="classSoccerCommand.html#c5">makeSayCommand</a>(          <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00619     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a190">CMD_CHANGEPLAYER</a>:b = <a class="code" href="classSoccerCommand.html#c9">makeChangePlayerCommand</a>( <a class="code" href="classSoccerCommand.html#m8">str</a> ); <font class="keywordflow">break</font>;00620     <font class="keywordflow">case</font> <a class="code" href="SoccerTypes_8h.html#a247a180">CMD_ILLEGAL</a>:    <a class="code" href="classSoccerCommand.html#m8">str</a>[0] = <font class="charliteral">'\0'</font>;                       <font class="keywordflow">break</font>;00621     <font class="keywordflow">default</font>:00622       cerr &lt;&lt; <font class="stringliteral">"(ActHandler::makeCommandString) Unkown command!"</font>&lt;&lt;endl;00623 00624     <font class="keywordflow">if</font>( b == <font class="keyword">false</font> )                       <font class="comment">// if string could not be created</font>00625     {00626       <a class="code" href="classSoccerCommand.html#m1">commandType</a> = <a class="code" href="SoccerTypes_8h.html#a247a180">CMD_ILLEGAL</a>;00627       <a class="code" href="classSoccerCommand.html#m8">str</a>[0] = <font class="charliteral">'\0'</font>;                       <font class="comment">// create the empty string</font>00628     }00629   }00630   <font class="keywordflow">return</font> <a class="code" href="classSoccerCommand.html#m8">str</a>;00631 }00632 <a name="l00639"></a><a class="code" href="classSoccerCommand.html#c0">00639</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c0">SoccerCommand::makeCatchCommand</a>( <font class="keywordtype">char</font> *str  )00640 {00641   <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a100">getMinMoment</a>( ) &lt;= <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &amp;&amp; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;= <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a98">getMaxMoment</a>( ) )00642     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>, <font class="stringliteral">"(catch %d)"</font>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m2">dAngle</a> );00643   <font class="keywordflow">else</font>00644   {00645     printf(<font class="stringliteral">"(SoccerCommand::makeCatchCommand) angle %f out of bounds\n"</font>,<a class="code" href="classSoccerCommand.html#m2">dAngle</a>);00646     <font class="keywordflow">return</font> <font class="keyword">false</font>;00647   }00648   <font class="keywordflow">return</font> <font class="keyword">true</font>;00649 }00650 <a name="l00657"></a><a class="code" href="classSoccerCommand.html#c1">00657</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c1">SoccerCommand::makeChangeViewCommand</a>( <font class="keywordtype">char</font> *str  )00658 {00659   <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#m5">va</a> != <a class="code" href="SoccerTypes_8h.html#a244a173">VA_ILLEGAL</a> &amp;&amp; <a class="code" href="classSoccerCommand.html#m4">vq</a> != <a class="code" href="SoccerTypes_8h.html#a245a176">VQ_ILLEGAL</a> )00660     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>,<font class="stringliteral">"(change_view %s %s)"</font>, <a class="code" href="classSoccerTypes.html#d24">SoccerTypes::getViewAngleStr</a>  ( <a class="code" href="classSoccerCommand.html#m5">va</a> ),00661                                         <a class="code" href="classSoccerTypes.html#d27">SoccerTypes::getViewQualityStr</a>( <a class="code" href="classSoccerCommand.html#m4">vq</a> ) );00662   <font class="keywordflow">else</font>00663   {00664     printf( <font class="stringliteral">"(SoccerCommand::makeChangeViewCommand) wrong arguments %s %s\n"</font>,00665                              <a class="code" href="classSoccerTypes.html#d24">SoccerTypes::getViewAngleStr</a>  ( <a class="code" href="classSoccerCommand.html#m5">va</a> ),00666                              <a class="code" href="classSoccerTypes.html#d27">SoccerTypes::getViewQualityStr</a>( <a class="code" href="classSoccerCommand.html#m4">vq</a> )  );00667     <font class="keywordflow">return</font> <font class="keyword">false</font>;00668   }00669   <font class="keywordflow">return</font> <font class="keyword">true</font>;00670 }00671 <a name="l00678"></a><a class="code" href="classSoccerCommand.html#c2">00678</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c2">SoccerCommand::makeDashCommand</a>( <font class="keywordtype">char</font> *str  )00679 {00680   <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a96">getMinPower</a>() &lt;= <a class="code" href="classSoccerCommand.html#m3">dPower</a> &amp;&amp; <a class="code" href="classSoccerCommand.html#m3">dPower</a> &lt;= <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a94">getMaxPower</a>() )00681     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>,<font class="stringliteral">"(dash %d)"</font>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m3">dPower</a> );00682   <font class="keywordflow">else</font>00683   {00684     printf( <font class="stringliteral">"(SoccerCommand::makeDashCommand) power %d out of bounds (%d,%d)\n"</font>,00685         (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m3">dPower</a>, <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a96">getMinPower</a>(), <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a94">getMaxPower</a>() );00686     <a class="code" href="classSoccerCommand.html#m3">dPower</a> = 0.0;00687     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>, <font class="stringliteral">"(dash 0)"</font> );00688     <font class="keywordflow">return</font> <font class="keyword">false</font>;00689   }00690   <font class="keywordflow">return</font> <font class="keyword">true</font>;00691 }00692 <a name="l00699"></a><a class="code" href="classSoccerCommand.html#c3">00699</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c3">SoccerCommand::makeKickCommand</a>( <font class="keywordtype">char</font> *str  )00700 {00701   <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a96">getMinPower</a>( )  &lt;= <a class="code" href="classSoccerCommand.html#m3">dPower</a> &amp;&amp; <a class="code" href="classSoccerCommand.html#m3">dPower</a> &lt;= <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a94">getMaxPower</a>( ) &amp;&amp;00702       <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a100">getMinMoment</a>( ) &lt;= <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &amp;&amp; <a class="code" href="classSoccerCommand.html#m2">dAngle</a> &lt;= <a class="code" href="classSoccerCommand.html#o0">SS</a>-&gt;<a class="code" href="classServerSettings.html#a98">getMaxMoment</a>( ) )00703     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>,<font class="stringliteral">"(kick %d %d)"</font>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m3">dPower</a>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m2">dAngle</a> );00704   <font class="keywordflow">else</font>00705   {00706     printf(<font class="stringliteral">"(SoccerCommand::makeKickCommand) one argument %d or %d is wrong\n"</font>,00707                     (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m3">dPower</a>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m2">dAngle</a> );00708     <font class="keywordflow">return</font> <font class="keyword">false</font>;00709   }00710   <font class="keywordflow">return</font> <font class="keyword">true</font>;00711 }00712 <a name="l00719"></a><a class="code" href="classSoccerCommand.html#c4">00719</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c4">SoccerCommand::makeMoveCommand</a>( <font class="keywordtype">char</font> *str  )00720 {00721   <font class="keywordflow">if</font>( -<a class="code" href="SoccerTypes_8h.html#a13">PITCH_LENGTH</a>/2 - <a class="code" href="SoccerTypes_8h.html#a15">PITCH_MARGIN</a> &lt;= <a class="code" href="classSoccerCommand.html#m6">dX</a> &amp;&amp;00722        <a class="code" href="SoccerTypes_8h.html#a13">PITCH_LENGTH</a>/2 + <a class="code" href="SoccerTypes_8h.html#a15">PITCH_MARGIN</a> &gt;= <a class="code" href="classSoccerCommand.html#m6">dX</a> &amp;&amp;00723       -<a class="code" href="SoccerTypes_8h.html#a14">PITCH_WIDTH</a>/2  - <a class="code" href="SoccerTypes_8h.html#a15">PITCH_MARGIN</a> &lt;= <a class="code" href="classSoccerCommand.html#m7">dY</a> &amp;&amp;00724        <a class="code" href="SoccerTypes_8h.html#a14">PITCH_WIDTH</a>/2  + <a class="code" href="SoccerTypes_8h.html#a15">PITCH_MARGIN</a> &gt;= <a class="code" href="classSoccerCommand.html#m7">dY</a>   )00725     sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>,<font class="stringliteral">"(move %d %d)"</font>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m6">dX</a>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m7">dY</a>);00726   <font class="keywordflow">else</font>00727   {00728     printf( <font class="stringliteral">"(SoccerCommand::makeMoveCommand) one argument %d or %d is wrong\n"</font>,00729                   (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m6">dX</a>, (<font class="keywordtype">int</font>)<a class="code" href="classSoccerCommand.html#m7">dY</a>);00730     <font class="keywordflow">return</font> <font class="keyword">false</font>;00731   }00732   <font class="keywordflow">return</font> <font class="keyword">true</font>;00733 }00734 <a name="l00741"></a><a class="code" href="classSoccerCommand.html#c5">00741</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c5">SoccerCommand::makeSayCommand</a>( <font class="keywordtype">char</font> *str_com  )00742 {00743   <font class="keywordflow">if</font>( <a class="code" href="classSoccerCommand.html#m8">str</a> != NULL &amp;&amp; <a class="code" href="classSoccerCommand.html#m8">str</a>[0] != <font class="charliteral">'\0'</font> )00744     sprintf( str_com, <font class="stringliteral">"(say %s)"</font>, <a class="code" href="classSoccerCommand.html#m8">str</a> );00745   <font class="keywordflow">else</font>00746   {00747     printf( <font class="stringliteral">"(SoccerCommand::makeSayCommand) no string filled in\n"</font> );00748     <font class="keywordflow">return</font> <font class="keyword">false</font>;00749   }00750   <font class="keywordflow">return</font> <font class="keyword">true</font>;00751 }00752 <a name="l00758"></a><a class="code" href="classSoccerCommand.html#c6">00758</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c6">SoccerCommand::makeSenseBodyCommand</a>( <font class="keywordtype">char</font> *str  )00759 {00760   sprintf( <a class="code" href="classSoccerCommand.html#m8">str</a>,<font class="stringliteral">"(sense_body)"</font> );00761   <font class="keywordflow">return</font> <font class="keyword">true</font>;00762 }00763 <a name="l00770"></a><a class="code" href="classSoccerCommand.html#c7">00770</a> <font class="keywordtype">bool</font> <a class="code" href="classSoccerCommand.html#c7">SoccerCommand::makeTurnCommand</a>( <font class="keywordtype">char</font> *str  )

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?