...
TODO: follow flowchart to pick service typeTo 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.
At its core, any new component (exteding 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.
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 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:
...
There are pre-defined messages, see XFollow X to create your own service