All rapyuta.io docs are open source. See something that's wrong or unclear? Submit a pull request.
Make a contributionA ROS publisher is part of a ROS package. It is a public git repository, which is built into a running docker container on the fly when the package is being deployed. A ROS subscriber is also a part of the same ROS package. It is downloaded on a device and is launched when the package is deployed.
The walkthrough gives an overview of how to:
programmatically using rapyuta.io Python SDK in your python application.
25 minutes
To create the build, follow the below steps. Skip the following steps if you have already created an io-tutorials build earlier.
io-tutorials
https://github.com/rapyuta/io_tutorials
and select Build Recipe as Catkin.The build takes about two to five minutes to build the source code in the io_tutorials repository into a running docker container. You may analyze the corresponding build logs, which helps in debugging failed builds. After you create the build, create the Talker and Listener package.
Talker
.ROS Publisher
.TALKER
.talker_executable
.roslaunch talker talker.launch
/telemetry
.
To add a ROS topic, click Add ROS topic. In the Name box,
type in the ROS topic. Select Maximum as the value for QoS.Listener
.ROS Subscriber
.LISTENER
.listener_executable
.roslaunch listener listener.launch
A routed network allows you to establish ROS communication between different ROS package deployments. Binding a routed network resource to your deployment will enable other deployments on the same routed network to consume ROS topics/services/actions as defined in the package. If you have already created a routed network, you can skip this procedure.
Use the following code to create a routed network
routed_network = client.create_cloud_routed_network("CLOUD_ROUTED_NETWORK", ROSDistro.MELODIC, True)
routed_network.poll_routed_network_till_ready()
Firstly, you need to authenticate to access rapyuta.io services from within your python application.
# Authentication
from rapyuta_io import Client
from rapyuta_io.clients.package import ROSDistro
client = Client(AUTH_TOKEN, PROJECT_ID)
# Create a Routed Network
routed_network = client.create_cloud_routed_network("CLOUD_ROUTED_NETWORK", ROSDistro.MELODIC, True)
routed_network.poll_routed_network_till_ready()
Retrieve the Talker package by its package ID, and then deploy it on the cloud. The resulting deployment is called ROS PUBLISHER.
# Deploy Talker package on cloud
talker = client.get_package(TALKER_ID)
talker_configuration = talker.get_provision_configuration(TALKER_PLAN_ID)
talker_configuration.add_routed_network(routed_network)
talker_cloud_deployment = talker.provision(deployment_name="ROS PUBLISHER", provision_configuration=talker_configuration)
talker_cloud_deployment.poll_deployment_till_ready()
Similarly, deploy Listener package on the cloud. Since the resulting ROS SUBSCRIBER deployment depends on ROS PUBLISHER deployment, add the latter as a dependent deployment of the former.
# Deploy Listener package on device
listener = client.get_package(LISTENER_ID)
listener_configuration = listener.get_provision_configuration(LISTENER_PLAN_ID)
device = client.get_device(DEVICE_ID)
listener_configuration.add_device("LISTENER", device)
listener_configuration.add_routed_network(routed_network)
listener_device_deployment = listener.provision(deployment_name="ROS SUBSCRIBER", provision_configuration=listener_configuration)
listener_device_deployment.poll_deployment_till_ready()
Put the above code snippets together in a file, talker-listener.py, save the program and close the file.
# talker-listener.py
from rapyuta_io import Client
# Authentication
client = Client(AUTH_TOKEN, PROJECT_ID)
# Create a Routed Network
routed_network = client.create_cloud_routed_network("CLOUD_ROUTED_NETWORK", ROSDistro.MELODIC, True)
routed_network.poll_routed_network_till_ready()
# Deploy Talker on cloud
talker = client.get_package(TALKER_ID)
talker_configuration = talker.get_provision_configuration(TALKER_PLAN_ID)
talker_configuration.add_routed_network(routed_network)
talker_cloud_deployment = talker.provision(deployment_name="ROS PUBLISHER", provision_configuration=talker_configuration)
talker_cloud_deployment.poll_deployment_till_ready()
# Deploy Listener on device
listener = client.get_package(LISTENER_ID)
listener_configuration = listener.get_provision_configuration(LISTENER_PLAN_ID)
device = client.get_device(DEVICE_ID)
listener_configuration.add_device("LISTENER", device)
listener_configuration.add_routed_network(routed_network)
listener_device_deployment = listener.provision(deployment_name="ROS SUBSCRIBER", provision_configuration=listener_configuration)
listener_device_deployment.poll_deployment_till_ready()
# Get status of ROS SUBSCRIBER deployment
print subscriber_deployment.get_status()
At the terminal prompt, run the program using the command:
$ python talker-listener.py
The output is an object of the class DeploymentStatus, which contains values such as:
The final deployment is running successfully if the value of the deployment status is Running.
To verify if the program has executed correctly, click on the Historical Logs tab of ROS SUBSCRIBER deployment to view the output as shown: