📄 node33.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!--Converted with LaTeX2HTML 2002-2-1 (1.71)original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>Creating and Running Behaviors</TITLE><META NAME="description" CONTENT="Creating and Running Behaviors"><META NAME="keywords" CONTENT="howtorobocop"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="howtorobocop.css"><LINK REL="previous" HREF="node25.html"><LINK REL="up" HREF="node18.html"><LINK REL="next" HREF="node34.html"></HEAD><BODY ><DIV CLASS="navigation"><!--Navigation Panel--><A NAME="tex2html495" HREF="node34.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html491" HREF="node18.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html487" HREF="node32.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html493" HREF="node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="/usr/share/latex2html/icons/contents.png"></A> <BR><B> Next:</B> <A NAME="tex2html496" HREF="node34.html">List of joints</A><B> Up:</B> <A NAME="tex2html492" HREF="node18.html">Behavior</A><B> Previous:</B> <A NAME="tex2html488" HREF="node32.html">Behavior slots</A> <B> <A NAME="tex2html494" HREF="node1.html">Contents</A></B> <BR><BR></DIV><!--End of Navigation Panel--><H2><A NAME="SECTION00653000000000000000">Creating and Running Behaviors</A></H2><P>Now you have defined all your behaviors and set up the hierarchy in your XML configuration file. The last thing to do is to have your agent create the correct behavior tree based on the configuration file and run the behaviors every time step. The first you simply do by loading the configuation file with the <TT>Conf</TT> class and then call the static <TT>Behavior::createBehaviors</TT> method:<P><BR><IMG WIDTH="567" HEIGHT="124" ALIGN="BOTTOM" BORDER="0" SRC="img24.png" ALT="\begin{program}\begin{verbatim}void MyAgent::init(){Conf::initialize(''myconf.xml'');Behavior::createBehaviors();}\end{verbatim}\end{program}"><BR><P>As you can see, your agent's <TT>init</TT> method is a good place to do it. Running your behaviors consists of running the root behavior, which in its turn runs its subbehaviors, et cetera, until the lowest, primitive behaviors are run. Just select your root behavior (we like to call it the 'win' behavior and is the behavior with id 'win') and run it:<P><BR><IMG WIDTH="567" HEIGHT="162" ALIGN="BOTTOM" BORDER="0" SRC="img25.png" ALT="\begin{program}\begin{verbatim}void MyBehavior::think(){rf<Behavior> win =......>setGoal(new Behavior::Goal);win->achieveGoal();}\end{verbatim}\end{program}"><BR><P>After the behavior tree is processed, the primitive behaviors that have actions to send to the server are collected in the list of Action Command Behaviors. You should request these, collect their actions and send them to the Cerbellum:<P><BR><IMG WIDTH="822" HEIGHT="238" ALIGN="BOTTOM" BORDER="0" SRC="img26.png" ALT="\begin{program}\begin{verbatim}void MyBehavior::think(){...Cerebellum& c......ter)->getAction());cer.outputCommands(d_comm);}\end{verbatim}\end{program}"><BR><P><P><DIV CLASS="navigation"><HR><!--Navigation Panel--><A NAME="tex2html495" HREF="node34.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html491" HREF="node18.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html487" HREF="node32.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html493" HREF="node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="/usr/share/latex2html/icons/contents.png"></A> <BR><B> Next:</B> <A NAME="tex2html496" HREF="node34.html">List of joints</A><B> Up:</B> <A NAME="tex2html492" HREF="node18.html">Behavior</A><B> Previous:</B> <A NAME="tex2html488" HREF="node32.html">Behavior slots</A> <B> <A NAME="tex2html494" HREF="node1.html">Contents</A></B> </DIV><!--End of Navigation Panel--><ADDRESS>Bram2007-11-18</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -