⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deep-shallow-api.sgml

📁 机器人开源项目orocos的源代码
💻 SGML
📖 第 1 页 / 共 2 页
字号:
make them load binary code that provides new, or updates existing,functionalities and behaviours.The data that is communicated within the system in order to achievethis (re)configuration is given the generic name of configurationflow. Configuration is typically not realtime, but requires someexecution flow messages to bring the components to a&ldquo;configuration state&rdquo;, where functionality can be unloadedand loaded in a safe way.</para><para>Configuration flow methods typically <emphasis role="strong">apply to a whole application</emphasis>,<emphasis>i.e.</emphasis> a set of cooperating components.</para></listitem></itemizedlist>The APIs for each of the three above-mentioned functionalities are verydifferent, and these <emphasis role="strong">APIs should not be mixed</emphasis>. This isin accordance with the ideas behind <link linkend="deep-shallow">small and shallow interfaces</link>:an application that provides data flow, execution flow as well asconfiguration flow functionality should <emphasis>compose</emphasis>its End User API from the separate data, execution and configurationflow APIs.</para><para>Note that <link linkend="data-execution-configuration">Executionflow and Configuration flow</link> methods are natural for<ulink url="components-doc.html">components</ulink>, but exceptionalfor class libraries. In addition, the different types of componentseach have their own specific API methods. (See the above-mentioneddocument for more details.)</para></section><section id="multiple-dispatching"><title>Multiple dispatching</title><para>Multiple dispatching is a programming technique that fits very wellwith (but is not a necessary nor sufficient condition for) shallowAPIs: its benefit is that it offers <emphasis>polymorphism</emphasis>not only on the member function call, but also on the call's<emphasis>arguments</emphasis>, but it comes with runtime overhead.(<ulink url="http://jamesthornton.com/eckel/TIPatterns/html/Chapter12.html">This</ulink>is one of the links with some more information.) For example,multiple dispatching allows a generic motion call like<programlisting> Move ( MyDevice, MyMotionGenerator, MyReferencePoint, MyController);</programlisting>where all of the arguments are specific implementation versions of thegeneral concepts of a device, a motion generator, a reference pointfor which the motion is specified, and a controller with which toexecute the motion. Note that for all these arguments, also thedimension of the motion (1D, 2D, 3D) need not be specified explicitly,but can be checked at compile time.</para><para>Of course, there <emphasis>is</emphasis> overhead connected tomultiple dispatching, caused by the<emphasis>run-time object inspection</emphasis> required to find out the actual type of the arguments and to select thecorresponding implementation. Hence, this technique is <emphasis role="strong">not very well suited</emphasis> for:<itemizedlist><listitem><para><emphasis>Real-time algorithms</emphasis>, because of thetype-checking overhead.</para></listitem><listitem><para><emphasis>Frequent calls on distributed objects</emphasis>, becausethe &ldquo;inspection&rdquo; must travel back on forth over thenetwork for each argument of the method call, <emphasis>and</emphasis>repeating the check for each of a series of identical calls is a wasteof time.</para></listitem></itemizedlist><note><title>Orocos API choice</title><para>Because of the run-time overhead, and the lack of support in manyprogramming languages, multiple dispatching will remain an exceptionfor most of the Orocos class libraries and components. It can be usedfor non-realtime commands that users give to an<emphasis>application</emphasis>.</para><para>One of the concrete consequences is that the same conceptualfunctionality for 1D, 2D and 3D objects will be provided in separatelibraries, with extremely similar but nevertheless not completelyidentical APIs.</para></note></para></section><section id="interface-implementation"><title>Interface semantics&mdash;Application families</title><para>&orocos; has the ambitious goal to provide reusable softwarecomponents for <emphasis>all</emphasis> possible feedback controlapplications. Reusability is facilitated a lot by consistency andminimalism of the component APIs. One big step to achieve consistencyand minimalism is<ulink url="decoupling.html">semantic decoupling</ulink>: applicationsare put in <emphasis>families</emphasis>, such that: (i) all members in a family have the <emphasis role="strong">same interface semantics</emphasis>, and (ii)members within a family are distinguished by the specific values of anumber of <emphasis role="strong">family properties</emphasis> (forexample, the geometrical and physical parameters of their mechanicalcomponents). The <ulink url="kindyn-doc.html#SERIAL321">Serial321</ulink>robots are an example of such an application family: they only differin their link lengths, their artificially defined zero positions, andtheir base and end-effector frame positions.</para><para>&ldquo;Same interface semantics&rdquo; means that each member ofa family has exactly the same set of methods in its API, with the same<emphasis>method name</emphasis>, the same<emphasis>structure</emphasis> of arguments in the method prototype,and the same <emphasis>argument names</emphasis>. In addition, the<emphasis>effect</emphasis> of the method is the same for all membersin the family.</para><para>The concepts of <emphasis>interface semantics</emphasis> and<emphasis>application family</emphasis> are straightforward togeneralize to one more level of abstraction: application families arecollected in &ldquo;meta-families&rdquo; in which each member-familyhas <emphasis>formally</emphasis> the same API as all othermember-families, but (some of) the <emphasis>types</emphasis> of thearguments in the method calls are different. These argument typedifferences come from differences in:<itemizedlist><listitem><para>the <emphasis role="strong">dimension of the device space.</emphasis>For example, all <emphasis>Serial</emphasis> robots form ameta-family of devices with the same API, but different argumenttypes, <emphasis>i.c.</emphasis> the number of joints in theirkinematic chain.</para></listitem><listitem><para>the <emphasis role="strong">dimension of the task space.</emphasis>For example, all <emphasis>constrained motion applications</emphasis> form a meta-family, where the different dimensions of the constrainedand free subspaces of the task space are reflected in some of themethod call arguments.</para></listitem></itemizedlist></para><para>Non-realtime components can use<link linkend="multiple-dispatching">multiple dispatching</link>to provide exactly the same API for a whole meta-family.Realtime components must use alternative solutions:<orderedlist><listitem><para><emphasis role="strong">Virtual interfaces</emphasis>, withapplication-specific implementation through interface inheritance.</para></listitem><listitem><para><emphasis role="strong"> <ulink url="components-doc.html#SESSION-STATE">Session state</ulink></emphasis>: the arguments areof the &ldquo;union&rdquo; type (in the sense of the C programminglanguage), and the session state indicates which interpretation of theunion is currently selected. (The session state is set via a method inthe <link linkend="data-execution-configuration">Execution flow</link>API.)</para></listitem></orderedlist><note><title>Orocos API choice</title><para> A multiple dispatching API is appropriate for<emphasis>non-realtime components with low communication costs</emphasis>.</para><para> The virtual interface API is the method of choice for<emphasis>class libraries</emphasis>.</para><para>The session state-based API is only available to<emphasis>components that have a session state</emphasis>.</para></note></para></section></article>

⌨️ 快捷键说明

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