com.webos.service.rosbridge

API Summary

Allows an app on a webOS device to communicate with a service running on a ROS 2 device.

ROS2_Bridge.png

Supported Functionality:  

  • webOS web app can subscribe/publish topic to ROS 2.
  • webOS web app can call service in ROS 2. 
  • Currently, only client-specific APIs are supported.

Note: 

  • ROS (Robot Operating System) is a popular robot platform that provides services to build robot applications.
  • Currently, this service is compatible with only ROS 2 supported devices. 

Overview of the API

(click to expand)

NA 


Open All


publish

Description

Publishes topic message from LS2 (webOS luna bus) to ROS 2.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of ROS 2 message.

typeRequiredString

ROS 2 type name.

messageRequiredObject

ROS 2 message.

The JSON schema depends on the ROS 2 message structure.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorText" field for details.
errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

// console
# luna-send -i -f luna://com.webos.service.rosbridge/subscribe '{ "name":"topic_test", "type":"std_msgs/msg/String", "subscribe":true }'
{
    "subscribed": true
}
{
    "data": "hello"
}

// another console
luna-send -n 1 -f luna://com.webos.service.rosbridge/publish '{ "name":"topic_test", "type":"std_msgs/msg/String", "message":"hello" }'
{
    "returnValue": true
}


subscribe

Description

Subscribe topic message from ROS 2 world.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of ROS 2 message.

typeRequiredString

ROS 2 type name.

subscribeRequiredBoolean

Subscribe for notifications. This should always to be to true. 

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorText" field for details.
subscribedRequiredBoolean

Indicates if subscribed to get notified. This will always be true.

errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

// console
# luna-send -i -f luna://com.webos.service.rosbridge/subscribe '{ "name":"topic_test", "type":"std_msgs/msg/String", "subscribe":true }'
{
    "subscribed": true
}
{
    "data": "hello"
}

// another console
luna-send -n 1 -f luna://com.webos.service.rosbridge/publish '{ "name":"topic_test", "type":"std_msgs/msg/String", "message":"hello" }'
{
    "returnValue": true
}


call

Description

Calls service in ROS 2 world.

Parameters

Name

Required

Type

Description

nameRequiredString

Name of ROS 2 message.

typeRequiredString

ROS 2 type name.

messageRequiredObject

ROS 2 message.

The JSON schema depends on ROS 2 message structure.

Call Returns

Name

Required

Type

Description

returnValueRequiredBoolean

Indicates the status of operation. Possible values are:

  • true - Indicates that the operation was successful.
  • false - Indicates that the operation failed. Check the "errorText" field for details.
errorTextOptionalString

Indicates the reason for the failure of the operation. See the "API Error Codes Reference" section for details.

Example

// run test service
$ ros2 run demo_nodes_cpp add_two_ints_server

// call service by rosbridge
$ luna-send -n 1 -f luna://com.webos.service.rosbridge/call '{ "name":"add_two_ints", "type":"example_interfaces/srv/AddTwoInts", "message": { "a": 100, "b": 200} }'
{
    "sum": 300
}


ERROR REFERENCES

Error Code

Error Text

Error Description

NoneInvalid JSON format

Invalid JSON format

None'subscribe' should be 'true'

Subscribe API only supports subscription call.

If there is no subscribe parameter, this errorText will be returned.

None'type' is required parameter

If there is no 'type' parameter in request payload.

None'name' is required parameter

If there is no 'name' parameter in request payload.

None'message' is required parameter

If there is no 'message' parameter in request payload.

NoneCannot create ros client

ROS world error.


Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.