Page 114 - Designing Autonomous Mobile Robots : Inside the Mindo f an Intellegent Machine
P. 114

Communications and Control

               The template is then requested by the host and the slave assembles the scattered scraps of
               data into a single message block. The efficiency of this messaging system is incred-
               ible, and it is easily implemented.


               Post offices

               In complex systems such as mobile robots, communications patterns shift with the
               nature of the task at hand. Furthermore, communications channels are shared resources
               that many tasks (clients) may need to use. In the case of a base station program,
               communications may be dictated by the number and type of forms that the operator
               has open. It is therefore intolerably inefficient for a particular thread to wait in a
               loop for the channel to become available, and then for the data to arrive.
               In an efficient architecture, a task will request data before it absolutely needs it, and
               while it can still do useful work before the data arrives. To do resource sharing on a
               case by case basis rapidly results in unreadable code. Thus, we come to the general
               concept of a resource manager.
               A resource manager for a communication channel is usually called a post office. A post
               office is a module (or better yet an object) that contains an array of pointers to
               messages and their associated flags, and destination addresses. The elements of this
               array are called post office boxes. At a minimum, a post office will have the following
               methods available for the clients to use:
                   1. Post a request message

                   2. Post a send message
                   3. Provide status of a posted message

                   4. Provide status of the communications resource.
               As a task needs to communicate with other systems, it calls the post office and posts
               its message. The post office puts the message in the next available box, and then re-
               turns a message identification code that the client can use to request the status of its
               message in the future.
               The reason that the post office does not simply return the box number is that boxes
               are reused as time goes on. If a client does not pick up its message information before
               the post office reuses the box, then the data in that box may have nothing to do
               with the client’s request. In some schemes, the message identifier contains the box
               number in its lower bits to make it easy for the post office to locate the message
               when requested to do so by a client.



                                                        97
   109   110   111   112   113   114   115   116   117   118   119