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
Choosing a component type for your application (See flowchart below)
Choosing inputs the input datatypes (See SIC standardized pre-defined messages)
Creating a new file following the templates (See https://bitbucket.org/socialroboticshub/framework/src/master/sic_framework/services/templates/)
Implement the appropriate methods.
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 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 | ||
---|---|---|
| ||
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.
...