Versions Compared

Key

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

To create custom functionality, such as new sensors or , functions on the robot, or a new type of data processing such witch 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 inputs 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)

...

At its core, any new component (extending SICComponent) has to implement on_message and/or on_request. on_message allows the component components to be linked to one another, to send and receive and send messages in a data stream. on_request allows it 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 subclass subclasses have been defined for common cases in robotics. For these components you only need to implement the execute() method.

...