Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

To create custom functionality, such as new sensors or functions on the robot, or a new type of data processing such witch 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 component type for your application (See flowchart below)

  2. Choosing inputs 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 to be linked to one another, and receive and send messages in a data stream. on_request allows it to handle requests and send an explicit reply to the device that requested it.

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 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.

  • No labels