The walkthrough gives an overview of how to:
programmatically using rapyuta.io Python SDK in your python application.
Beginner
15 minutes
To create the build, follow 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. Please proceed to creation of package once the build is Complete.
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
Firstly, you need to authenticate so as to access rapyuta.io services from within your python application.
# Authentication
from rapyuta_io import Client
client = Client(AUTH_TOKEN, PROJECT_ID)
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_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 later 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_dependent_deployment(talker_cloud_deployment)
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)
# Deploy Talker on cloud
talker = client.get_package(TALKER_ID)
talker_configuration = talker.get_provision_configuration(TALKER_PLAN_ID)
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_dependent_deployment(talker_cloud_deployment)
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: