OJ4 Tutorials
| Making a Global Positioning Sensor |
IntroductionThe purpose of this tutorial is to demonstrate how to use the OpenJAUS SDK in the development of a JAUS Global Position Sensor (GPOS). Additionally a client of that sensor will be developed to demonstrate the behavior and capabilities of the GPOS service. JAUS Global Position SensorThe GPOS is a very common service in JAUS systems. Its purpose is to provide the current global position of the platform to other services throughout the platform and various controller like an Operator Control Unit (OCU). The GPOS does this in the global coordinate system using Latitude and Longitude. The message set of the GPOS service is defined in the JAUS Mobility Service Set (AS-6009) and is outlined below:
As can be seen above, the GPOS is a relatively simple service. In terms of its statemachine, the GPOS service is also simple. It inherits from the Access Control service which is part of the JAUS Core Service Set (AS-5710a). GposDemo
The GposDemo is a simple implementation of the GPOS Service. The GposComponent is implemented by extending the skeleton component in openjaus::mobility::GlobalPoseSensor.
Most the above is very straighforward, the data of the ReportGeomagneticProperty and ReportGlobalPose messages is initialized. In a real-world GPOS component a thread or some other run-time mechanism would be created to populate these values with the latest from the GPS sensor or other positioning system. Of particular interest is the highlighted line, #36. On this line the bool publish(Message *message) funtion is used. This function registers the given message with the underlying Events service. This allows the Event service to respond properly to Create Event requests for the ReportGlobalPose message. GposClientDemoThe GposClientDemo is designed to give an example of how to build a component which would be a client to the GPOS component. This simple example shows user how to do common activities within the OpenJAUS framework such as: finding a service by URI value, sending GPOS query messages, creating and stopping a periodic event and taking and releasing control of the GPOS component. These examples are shown below: Finding a GPOS ServiceThe Discovery service automatically exchanges system information with other JAUS components and maintains a SystemTree of components and services. Finding a particular service on the System Tree is easily done using the lookupService(char *) method of the SystemTree class. This returns a vector of JausAddress objects with the JausAddress of each matching service in the SystemTree.Sending a Query MessageSending a query message is also very simple. Create the message to be sent, populate it with the requiste data and send it using the sendMessage function.Subscribing and Unsubscribing to a Periodic EventCreating a periodic event is something done very often in the JAUS architecture. This allows a component to create a standing query to another service's information at a particular update rate. Creation and management of the periodic event is handled by the Event service which is implemented in the OpenJAUS library. Creation is done using the subscribePeriodic(address, message, rateHz) function as shown below. This returns a unique Event Id which is used for futher interaction with the Event service such as unsubscribing to an event using the unsubscribe(id) method.Requesting and Releasing Control of a Service |
0 Comments