📄 applications-doc.sgml
字号:
access to any of these data objects. This is reasonable forsmall-scale, centralized control systems, because it makes their<link linkend="interaction">interaction</link> a lotsimpler and efficient. The most typical case is where the Generator,Sensor, Estimator and Servo can be brought together in one singlefunction block.</para></listitem><listitem><para>Every feedback control application needs some sort of deterministicand periodic task execution. Traditionally, control system programmersdirectly use RTOS primitives such as periodic threads with staticscheduling priorities. However, the Kernel decouples the<emphasis>specification</emphasis> of a <emphasis role="strong">real-time behaviour</emphasis> from its<emphasis>implementation</emphasis> on a real-time operating system.So, Application Builders configure each of the Component functions tohave one of the following real-time modes offered by the Kernel:<anchor id="rt-modes"> <itemizedlist> <listitem> <para> <anchor id="behaviour-non-interruptable"> <emphasis role="strong">Non-Interruptable.</emphasis>Functions with this real-time mode have the highest priority in theKernel, and run with hardware interrupts disabled. Hence, functionsshould only use this real-time mode in very few, extremelytime-critical cases. </para> </listitem> <listitem> <para> <anchor id="behaviour-non-pre-emptible"> <emphasis role="strong">Non-Pre-Emptible</emphasis>These functions run with the same highest priority, but after the<emphasis>Non-Interruptable</emphasis> functions, and with thehardware interrupts enabled. </para> </listitem> <listitem> <para> <anchor id="behaviour-pre-emptible"> <emphasis role="strong">Pre-Emptible</emphasis> functions run withthe second highest priority: the execution of these functions can bepre-empted by the <emphasis>Non-Interruptable</emphasis> and<emphasis>Non-Pre-Emptible</emphasis> functions. </para> </listitem> <listitem> <para> <anchor id="behaviour-soft-real-time"> <emphasis role="strong">Soft-Real-Time</emphasis> functions run atlower priorities. </para> </listitem> </itemizedlist>In most implementations of the Kernel, the above-mentioned real-timemodes map quite straigthforwardly to real-time threads in the RTOS: <itemizedlist> <listitem> <para>The <emphasis>Non-Interruptable</emphasis> and<emphasis>Non-Pre-Emptible</emphasis> functions run in a thread thatgets the highest scheduling priority of all application threads. Thisthread is called “zero-time thread” in the referenceOrocos implementation, because it executes those functions that haveto finish in zero time, i.e., without any possible interruption fromelsewhere. </para> <para>Within this zero-time thread, the<emphasis>Non-Interruptable</emphasis> functions run with interruptsdisabled. </para> </listitem> <listitem> <para>The <emphasis>Pre-Emptible</emphasis> functions run in alower-priority thread,called the “zero-latency thread”, because it shouldexecute those functions that have to finish before a given deadline,i.e., with the minimum possible latency on that deadline. </para> </listitem> </itemizedlist><para>Note that the Application Builders assign real-time modes to<emphasis>functions</emphasis>, and that they do not come in directcontact with <emphasis>threads</emphasis>. The reason is thatparticular implementations of the Kernel can opt to provide thedesired real-time behaviour by other means than byusing threads. For example, timers or tasklets; without usinga real-time operating system at all, executing everything in one loop,with the highest-priority functions first; or executing theabove-mentioned real-time modes in, respectively, Interrupt ServiceRoutines, Deferred Service Routines and Asynchronous Service Routines.</para></listitem><listitem><para>The above-mentioned decoupling between the specification of thereal-time <emphasis>behaviour</emphasis> on the one hand, and the<emphasis>sample frequencies</emphasis> on the other hand, incombination with the fact that both pieces of information are<emphasis role="strong">configured at run-time</emphasis>, forceApplication and Component Builders<emphasis role="strong">not to use direct knowledge</emphasis> of thesample frequency and the real-time behaviour in their code. (With theexception of <emphasis>Non-Interruptable</emphasis> functions, becausethese can typically only use a very limited subset of the Kernel API.)The Builders should use a configuration<emphasis role="strong">property</emphasis> instead.</para></listitem><listitem><para>Multiple instances of the generic Kernel structure are combined inmore complex <anchor id="multi-level"><emphasis role="strong">architectures</emphasis>. Themost common architecture at the real-time control level is<emphasis role="strong">hierarchical</emphasis>, as depicted in<xref linkend="fig-two-level-control-pattern"> and<xref linkend="fig-two-level-control-pattern-component">.</para><para><anchor id="real-time-interaction">The arrows running from right to left between both levels of thesearchitectures denote “asynchronous” data access betweenpriority levels. The difference between<xref linkend="fig-two-level-control-pattern"> and<xref linkend="fig-two-level-control-pattern-component"> is thatthe former architecture applies to applications in which both levelsrequire <emphasis role="strong">real-time interaction</emphasis>: aComponent in the highest level needs information from one particularComponent in the lowest level. In the latter case, an<emphasis>image</emphasis> of the whole low level is passed to thehigh level via the Reporter Component of the lowest level, which is bydefault a non-real-time Component. This approach is more suitable fornetworked distribution; the former is appropriate for implementationof the controller on one single computing node.</para><para>The advantage of the real-time architecture is tightersynchronization between lower and higher level; the disadvantage isthat the lowest level cannot run in its most efficient implementation,because the data access from the higher level is typically<link linkend="applications-kernel-inter-exchange">asynchronously</link>.However, if the frequency of the inner loop is an integer multiple ofthe frequency of the outer loops that require asynchronous dataaccess, the implementation <emphasis>can</emphasis> be done withoutlocking; it is even possible to run both levels in the same thread.</para></listitem></itemizedlist></para><para><figure id="fig-two-level-control-pattern" float="1" pgwide="0"><title>Application of the control Kernel concept in a two-level hierarchicalarchitecture, with <emphasis>real-time</emphasis> data exchangebetween both levels.</title><mediaobject><imageobject><imagedata fileref="../pictures/two-level-control-pattern.png" format="PNG"></imageobject><imageobject><imagedata fileref="../pictures/two-level-control-pattern.eps" format="EPS"></imageobject></mediaobject></figure></para><para><figure id="fig-two-level-control-pattern-component" float="1" pgwide="0"><title>Application of the control Kernel concept in a two-level hierarchicalarchitecture, with <emphasis>non-real-time</emphasis> data exchange.</title><mediaobject><imageobject><imagedata fileref="../pictures/two-level-control-pattern-component.png" format="PNG"></imageobject><imageobject><imagedata fileref="../pictures/two-level-control-pattern-component.eps" format="EPS"></imageobject></mediaobject></figure></para></section><section id="kernel-application"><title>Kernel applications: generic control systems</title><para>Talking about “Kernel applications” seems to be acontradiction, since previous sections suggested to consider the Kernel as an“empty” placeholder that accepts application-dependentfunctionality. However, there is already a lot of useful things thatone can implement in the Kernel, and that is completely independent ofany particular application: PID servos for SISO and MIMO systems; gainscheduling; digital signal processing algorithms; one-dimensionalsetpoint interpolation, and synchronized N-dimensional setpointinterpolation; etc.Roughly speaking, the difference with real Applications is that atthis Kernel level, the signals have no physical dimensions, and havejust generic names such as “X”.</para></section></section><section id="applications-kernel-applications"><title>Applications</title><para>This Section gives an overview of the Application Builders' task inspecifying an application; the following Sections give concreteapplication examples.</para><section id="applications-tasks"><title>Tasks of the Application Builders</title><para>Application Builders do not <emphasis>implement</emphasis> anapplication, but <emphasis>specify</emphasis> and<emphasis>integrate</emphasis> it. (Compare this job to that ofcomputer motherboard manufacturers.) That means the ApplicationBuilders take decisions for all of the following:<orderedlist><listitem><para>The <emphasis role="strong">architecture</emphasis> of theapplication, <emphasis>i.e.</emphasis> deciding about the data flow inthe system. </para><para>If the architecture is <link linkend="multi-level">multi-level</link>, the ApplicationBuilders have (i) to decide which higher levels need real-time accessto data objects from lower levels (because this influences the dataflow in the application), and(ii) to choose distinct names for the same Components inthe various instantations of the Kernel structure(<emphasis>i.e.</emphasis> the <emphasis>Generator</emphasis> nameshould be used only once; so,<xref linkend="fig-two-level-control-pattern"> gives a misleadingpicture).</para></listitem><listitem><para>The <emphasis role="strong">objects</emphasis> to be stored inthe Data Objects of the Kernel, or, in other words, the<link linkend="ports">Ports</link> of all Components.</para></listitem><listitem><para>The <emphasis role="strong">events</emphasis> that Components generateand/or react to.</para></listitem><listitem><para>The <emphasis role="strong">functions</emphasis> (and function blocks) that must run in each Component.</para></listitem><listitem><para>The execution <emphasis role="strong">behaviour</emphasis> of allComponent functions. The Application Builders decide(i) how many threads to use (<emphasis>if</emphasis> threads areused…),(ii) at what frequencies they run; and(iii) which Component functions are run with what<link linkend="rt-modes">real-time mode</link>.</para><para>The Kernel takes care of the concrete details of real-timeexecution and scheduling, while the application concentrates on thefunctionality.The “price” to pay for this convenience is that theApplication Builders must strictly follow the structure imposed by the Kernel. This structure consists of only using thepredefined Components, and their standard interfaces. These interfacesbasically consist of <parameter>Set_…</parameter> and <parameter>Get_…</parameter> methods on the Data Objects.</para></listitem></orderedlist>So, after having taken all these decisions, all that is left to do isto fill in concrete implementations of all functions. This is theComponent Builders' job, which is not within the scope of thisdocument.</para></section><section id="applications-families"><title>Application families</title><para>The &orocos; project is all about providing <emphasis>genericinfrastructure</emphasis>, so re-use of developments at any levelshould be aimed at. Hence, also the Application and Component Buildersmust try to keep their work as general as possible, withoutcompromising on efficiency and intuitivity for their users. One of themost practical (and easy) steps is to avoid all use of “magicnumbers” in the application code; these are numbers that haveonly meaning for the particular application that the Builders areworking at. Instead, the Builders should try to come up with a<emphasis role="strong">family</emphasis> of Applications and/orComponents (kinematics, servo algorithms, generators, estimators,…). A family is determined by a set of algorithms that can begiven acommon <emphasis role="strong">property file</emphasis>, and the wholefamily is uniquely defined by varying the property parameters. Inother words, a family can be given executable code that can bereconfigured for any member of the family without recompilation, justby setting the properties.</para><para>The borders of where we take stuff together to put it into a familyare defined by the “simplicity” of the property file. Ofcourse, this is not a deterministic statement, so discussion willremain about what exactly constitutes a family. Anyway, hierarchiesof families exist: a family deeper in the hierarchy has more efficientimplementations, but less members.</para></section></section><section id="applications-actuated-axis"><title>ActuatedAxis</title><para>A very common application in the domain of motion control is thatof one single actuated axis. <emphasis>i.e.</emphasis> a revolute orprismatic joint with a transmission and a motor. The joint axis hasmechanical limits, software and hardware end switches at one end or atboth ends, position or velocity sensors (encoders, resolvers,potentiometers, laser distance sensors, …), force, current orpressure sensors, etc.</para><para>Actuated axes come in different types: position control, velocitycontrol, force control, pressure control, current control.</para><section id="actuated-axis-architecture"><title>Architecture</title><para>The typical architecture for an ActuatedAxis is a<link linkend="multi-level">multi-level hierarchy</link>, withso-called <emphasis>cascaded control loops</emphasis>: the inner loopperforms current control, the loop around that does force or velocitycontrol, and the outer loop provides position control. (In manysystems, the two inner loops are done in the hardware of the motordrive units.) It is appropriate to choose sample times for theouter loops that are integer multiples of the inner loop, such thatvery efficient (because lock-less) “asynchronous” dataexchange can be provided.</para><para>The <link linkend="fig-two-level-control-pattern">Components</link>in the Application are as follows. The (data flow) Command is adesired 1D position, velocity, force, current or pressure, and theGenerator performs simple interpolation between the incoming Commandsand the real-time Setpoints. The Controller is most often somevariation of the PID algorithm. The Estimator is usually empty, orprovides quite straightforward transformations, such as positions intovelocities (mind the discretization effects!), or pressures orcurrents into forces.</para></section><section id="actuated-axis-commands"><title>Commands</title><para><para>The previous section described the architecture with which to perform<emphasis>steady state</emphasis> data flow (<emphasis>i.e.</emphasis>the Command is a setpoint for the Generator), but the ActuatedAxisapplication also has <emphasis>control flow</emphasis> properties. Thecorresponding Commands are documented below; the exact syntax of theCommands depends on the application.<itemizedlist><listitem><para><emphasis role="strong">Component configuration</emphasis>: anActuatedAxis application can provide several algorithms for theGenerator, Servo, and Estimator, and provides Commands to the user tomake this selection. </para><para>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -