components-doc.sgml
来自「机器人开源项目orocos的源代码」· SGML 代码 · 共 301 行
SGML
301 行
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN" "docbook/dtd/4.1/docbook.dtd" [<!ENTITY orocos "<acronym>Orocos</acronym>">]><article><articleinfo> <title>Components </title> <author> <firstname>Herman</firstname> <surname>Bruyninckx</surname> <affiliation> <address> Herman.Bruyninckx(at)mech.kuleuven.ac.be </address> </affiliation> </author> <copyright> <year>2004</year> <holder>Herman Bruyninckx —Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU General Public License(<ulink url="http://www.fsf.org/copyleft/gpl.html">http://www.fsf.org/copyleft/gpl.html</ulink>), where the <emphasis>source code</emphasis> of the document is the <ulink url="components-doc.xml">XML file</ulink>.</holder> </copyright> <revhistory> <revision> <revnumber>0.01</revnumber> <date>16 April, 2004</date> <authorinitials>HB</authorinitials> <revremark>Initial version.</revremark> </revision> </revhistory> <abstract> <para> <emphasis role="strong">Abstract</emphasis> </para> <para>This document discusses the meaning of the term“component” in the Orocos project. </para> </abstract></articleinfo> <section id="component-based-control"><title>Component-based feedback control</title><para>&orocos; is a software framework for feedback control applications,and has the ambition to profit optimally from its competitiveadvantages: <itemizedlist><listitem><para>Its <emphasis role="strong">Free Software</emphasis> property offersunparallelled opportunities for code and design reuse. This means that&orocos; components will be as small-grained as possible. The lowerlimit of this granularity is imposed by the principle of<ulink url="decoupling.html">decoupling</ulink>: functionality istaken together in a component as long as one part of theimplementation <emphasis>has</emphasis> to be aware of the internalworkings and structure of the other parts, at least if one cares aboutefficiency of the code. </para><para>This decoupling property makes it initially a bit more hard to designand implement controllers, but the long-term pay-off is expected to belarge: much better reuse, components with small interfaces that areeasy to understand, better maintainability, opportunities foroptimization of an application, etc.</para></listitem><listitem><para>Its has <emphasis role="strong">no legacy</emphasis> customers to carefor. That means that it can start from scratch with the new softwareengineering that underlies &orocos;. We call it the <emphasis>Software Pattern for feedback control</emphasis>. One of itsmajor advantages is the strict separation of <ulink url="deep-shallow-api.html#DATA-EXECUTION-CONFIGURATION">dataflow, execution flow and configuration flow</ulink>, which givescleaner interfaces, smaller class libraries, more opportunities tosynchronize realtime execution of control functionality, etc.This approach is quite different from most existing industrial controlapplications, where the PLC(<emphasis>Programmable Logic Controller</emphasis>) devices take acentral role, although they lead in practice to a very high level ofcoupling between different software modules: they are used for suchdiverse things as making decisions, running execution logic statemachines of functionality that partially runs elsewhere, interfacinghardware, running control loops, etc.</para></listitem></itemizedlist></para><para>“Component-based” programming means</para></section><section id="class-component"><title>Class vs. Component </title><para>This Section gives a brief overview of the differencesbetween <emphasis>class-based</emphasis> and<emphasis>component-based</emphasis> programming:<itemizedlist><listitem><para><emphasis role="strong">Class-based.</emphasis>The “lowest level” of functionality in every softwaresystem is implemented in (object-oriented) libraries. These librariestypically have a large number of classes (and corresponding methodcalls with argument lists), to cover all the different types offunctionality in the system. For example, the kinematics and dynamicsfor a set of kinematic families, or various motion generationalgorithms, in both 2D and 3D, etc. Each particular functionality isimplemented in a class method call with a <emphasis>uniquename</emphasis> and a <emphasis>precise list of arguments</emphasis>.</para><para>Typically, class-based programming has a<emphasis role="strong">fine-grained</emphasis> API: onecombination of “method” and “argument list”for one particular functionality of an object from the class, and<emphasis>all information</emphasis> necessary to execute the desiredfunctionality comes from two sources: (i) it is passed as arguments tothe method, and (ii) it is derived from the<emphasis role="strong">functional state</emphasis> of the object.Part of this state is <emphasis>visible</emphasis> to the caller,part is <emphasis>hidden</emphasis>.</para></listitem><listitem><para><emphasis role="strong">Component-based</emphasis> programming is muchmore <emphasis role="strong">coarse-grained</emphasis>: each componentprovides multiple “services” to multiple“clients”, and at each particular moment, the result ofthe requested service is not only determined by theinformation in the service request call and the functional state of theclasses in the component, but (possibly to a very large extent) alsoby the <emphasis role="strong">session state</emphasis> of theprovided service. That is, the state information that the servicingcomponent stores not about itself, but about its <emphasis role="strong">interaction with the client</emphasis>.</para><para>Component-based programming is also more coarse-grained, because“client” and “server” have a lower numberof interactions (<emphasis>i.e.</emphasis> service request calls)than interacting objects, and data is exchanged in larger datastructures. The reason is that components are often distributed over anetwork, and hence each interaction induces a communication overheadcost.</para></listitem></itemizedlist></para></section><section id="corba-ccm"><title>CORBA Component Model (CCM)</title><para>The<ulink url="http://www.omg.org/technology/documents/formal/components.htm">CORBA3.0</ulink>specification of the <emphasis>CORBA Component Model</emphasis> (CCM)standardizes four categories of components, featuring different usageof functional and external state:<itemizedlist><listitem><para>A <emphasis role="strong">Service component</emphasis> is nothing morethan a wrapper around class-based functionality. The component keeps<emphasis role="strong">no state</emphasis> of itself(“functional state”) or of its client interactions<anchor id="session-state">(“<emphasis role="strong">session state</emphasis>”), andit has <emphasis role="strong">no identity</emphasis> with which itcan be identified by clients. So, a service component is useful for <ulink url="deep-shallow-api.html#DATA-EXECUTION-CONFIGURATION">data flow</ulink> servicerequests, that have no duration beyond the lifetime of a single clientinteraction. All the data needed in the service is contained in themethod call of the service.</para><para>In Orocos, a possible Service component could be: a<ulink url="motion-api.html">motion generator</ulink> that one can askto calculate a path from point <emphasis>A</emphasis> to point<emphasis>B</emphasis>, whose coordinates are given as arguments inthe service request.</para></listitem><listitem><para>A <emphasis role="strong">Session component</emphasis>is useful for things like “iterators”, which require thestorage of the session state of the client, for the <emphasis>lifetime of one interaction</emphasis> with that client. Thecomponent does not need persistent storage for the<emphasis>whole lifetime</emphasis> of the client.(“Persistent” means: recoverable also after shutdown andreboot of the system.) The component also doesn't need to export tothe client <emphasis>identity information</emphasis>(<emphasis>i.e.</emphasis> session state) about the serviceit provides: knowing the state of the client interaction is enough,and it doesn't have to reserve one particular, identifiable thread ofexecution to the client.</para><para>In summary, a Session component has a<emphasis role="strong">non-persistent session state</emphasis>, and a<emphasis role="strong">non-persistent identity</emphasis>.</para><para>In Orocos, a possible Session component could be: a “DynamicsServer” that one can ask to calculate the dynamic equationsduring a whole task of a robot.</para></listitem><listitem><para><emphasis role="strong">Entity component.</emphasis>An Entity component is useful for managing all the information about aclient, <emphasis role="strong">during the whole lifetime</emphasis>of the client, <emphasis>i.e.</emphasis> it has to keep thisinformation also between successive shutdowns and reboots of thesystem. So, it has a<emphasis role="strong">persistent state</emphasis> and a<emphasis role="strong">persistent identity</emphasis>, which are bothvisible to its clients.</para><para>In Orocos, a possible Entity component could be: a “RobotServer” that manages the data of one particular robot systemover its whole lifetime: kinematic parameters; control gains; currentconfiguration; loaded and available task programs; total amount ofoperational hours; failure and repair logs; etc.</para></listitem><listitem><para><emphasis role="strong">Process component.</emphasis>The Process component is intended to model objects that represent<emphasis>business processes</emphasis> (e.g., applying for a loan,creating an order, etc.) rather than entities (e.g., customers,accounts, etc.). A Process component has a<emphasis role="strong">persistent state</emphasis> (which is notvisible to the client), and a<emphasis role="strong">persistent identity</emphasis> (which<emphasis>can</emphasis> be made visible to the client).</para><para>The major difference between Process and Entity components is that theProcess component does not expose its persistent identity to theclient (except through user-defined operations).</para><para>In Orocos, a possible Process component could be: the manager of aproduction cell, that delivers certain services to the clients,without providing them with the exact information about which robotsor machine tools are used in the process, and how exactly they aredelivering the service.</para></listitem></itemizedlist></para></section></article>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?