Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

TODO: follow flowchart to pick service type

There are pre-defined messages, see X

Follow X to create your own serviceTo create custom functionality, such as new sensors, functions on the robot, or a new type of data processing such as a custom object detection system, you will need to create your own component. This component can then be used in your SIC programs.

Creating a component requires the following steps

  1. Choosing a component type for your application (See flowchart below)

  2. Choosing the input datatypes (See SIC standardized pre-defined messages)

  3. Creating a new file following the templates (See https://bitbucket.org/socialroboticshub/framework/src/master/sic_framework/services/templates/)

  4. Implement the appropriate methods.

  5. Start the component (python your_file.py)

Also see: https://youtu.be/C_y42blplhs

At its core, any new component (extending SICComponent) has to implement on_message and/or on_request. on_message allows components to be linked to one another, to send and receive messages in a data stream. on_request allows a component to handle requests and send an explicit reply to the device that requested it.

Code Block
languagepy
class MyComponent(SICComponent):
    
    ... [other methods, see sic_framework/services/templates/]

    def on_request(self, request):
        # Do something
        
        reply = # Return a SICMessage response
        return reply

    def on_message(self, message):
        # Do something
        
        # Optional:
        output = # A SICMessage output of this service
        self.output_message(output) 

Three helpful subclasses have been defined for common cases in robotics. For these components you only need to implement the execute() method.

  • Sensor - A sensor is a component that has no inputs, but simply outputs the physical sensor values as often as it can. This forms the starting point of a data stream.

  • Service - A service is a component that is built to combine multiple streams at once, and process them in a synchronized way. For example, a service that has both bounding boxes of detected faces and and an image containing these faces, needs to align the right bounding box message to the right image. A Service will provide these aligned inputs to the execute method.

  • Actuator - An actuator is mostly used for performing physical actions with a robot. For example, requesting the robot to raise its arm. It might be usefull to know when this action is completed, and an Actuator sends back a message whenever it has completed a request.

Use this flowchart to help you determine which type of component class your component should extend:

...

Make sure to use predifined messages where possible to ensure interoperability between your component and others. See SIC standardized pre-defined messages for an overview.