Next: Adding Services to a Component



In the OpenJAUS SDK, a JAUS component is represented as a class and the desired JAUS services are added to a component via inheritance. When a service is added to a component all the functionality from the parent services are also added.



Base Component Classes


The OpenJAUS SDK provides a few base component classes that provide all the core functionality needed to quickly start communicating between JAUS components and should be used as a starting point for creating your own custom component. These classes are:

  • openjaus::core::EventsBase
  • openjaus::core::Base
  • openjaus::core::Managed



openjaus::core::EventsBase


The EventsBase component class includes the following services from the Core Service Set (AS5710A):

  • urn:jaus:jss:core:Transport
  • urn:jaus:jss:core:Events
  • urn:jaus:jss:core:Discovery
  • urn:jaus:jss:core:Liveness


The Discovery and Liveness services can be enabled or disabled via the OpenJAUS configuration file.


It also includes the following custom OpenJAUS services:

  • urn:openjaus:core:DiscoveryClient
  • urn:openjaus:core:Configuration


urn:openjaus:core:DiscoveryClient: 

  • A Discovery service client that will find other JAUS components on the network. The frequency for running the Discovery process can be controlled via the OpenJAUS configuration file.


urn:openjaus:core:Configuration: 

  • A non-standard, custom service that configure the JAUS ID of the component based on the settings specified in the OpenJAUS configuration file.


openjaus::core::Base


The Base component class includes all the services in the EventsBase component and adds the following services from the Core Service Set (AS5710A):

  • urn:jaus:jss:core:AccessControl
  • urn:jaus:jss:core:Time


The Time service can be enabled or disabled via the OpenJAUS configuration file.



openjaus::core::Managed


The Managed component class includes all the services in the Base component and adds the following services from the Core Service Set (AS5710A):

  • urn:jaus:jss:core:Management




Which Base Component Class should I use?



The base component class that should be used when creating your own component will depend on the inheritance chain for the services you want to add to your component.


Examples:

  • If you are including the PrimitiveDriver service (urn:jaus:jss:mobility:PrimitiveDriver) then you should inherit from the openjaus::core::Managed component class since the PrimitiveDriver service inherits from the Management service.
  • If you are including the GlobalPoseSensor service (urn:jaus:jss:mobility:GlobalPoseSensor) then you should inherit from the openjaus::core::Base component class since GlobalPoseSensor service inherits from the AccessControl service and the Management service is not needed.
  • If you are including both the PrimitiveDriver and GlobalPoseSensor services then you should inherit from the openjaus::core::Managed component class since the PrimitiveDriver service inherits from the Management service which inherits from the AccessControl service which is needed by the GlobalPoseSensor service.


Note:  It is recommended that you avoid adding unnecessary services to your component and should therefore pick the appropriate base component class to start from. You should avoid always starting from the openjaus::core::Managed component class if the Management service is not needed as it could lead to unintended side effects.



Creating a Custom Component


The following code snippets shows how to create a custom component.


Note: Most components will either start from the openjaus::core::Base or openjaus::core::Managed component classes.


.h file

class MyComponent :
    public openjaus::core::Base
{
public:
      MyComponent(std::string name);
      virtual ~MyComponent();

protected:

private:

}


.cpp file

MyComponent::MyComponent(std::string name) :
      openjaus::core::Base(name)
{

}



MyComponent::~MyComponent()
{

}


Note: A component name is required and is used for two things:

  1. It will be published as on the JAUS network to identify the component.
  2. It will be used in the OpenJAUS configuration file to identify component specific configuration parameters.


Note: Use of the openjaus::EventsBase(), openjaus::core::Base(), openjaus::core::Managed() constructors that do not take a name parameter is deprecated and will be removed in the future.


Next: Adding Services to a Component