Rosbag module¶
A ROS bag is a file format in ROS for storing ROS message data. The rapyuta.io platform allows you to record the ROS messages (ROS topics) for ROS enabled components deployed on the cloud.
Client Module¶
- class Client(auth_token, project=None)¶
Client class provides access to device, package, volume and deployment classes.
- __init__(auth_token, project=None)¶
Get new client object
- Parameters
auth_token (string) – Authentication token
project (string) – project_guid of the user
- create_rosbag_job(rosbag_job)¶
Create a ROSBag Job
- Parameters
rosbag_job (
ROSBagJob
) – ROSBag object- Raises
BadRequestError
: Rosbag Upload Options are required in case of Device jobs- Returns
Instance of
ROSBagJob
class
Following example demonstrates how to create a ROSBag Job.
>>> from rapyuta_io import Client >>> from rapyuta_io.clients.rosbag import ROSBagJob, ROSBagOptions >>> client = Client(auth_token='auth_token', project='project_guid') >>> deployment = client.get_deployment('deployment_id') >>> component_instance_id = deployment.get_component_instance_id('comp-name') >>> rosbag_options = ROSBagOptions(all_topics=True) >>> rosbag_job = ROSBagJob(deployment_id=deployment.deploymentId, ... component_instance_id=component_instance_id, ... rosbag_options=rosbag_options, name='name') >>> rosbag_job = client.create_rosbag_job(rosbag_job)
- delete_rosbag_blob(guid)¶
Delete the rosbag bag file
- Parameters
guid (str) – blob guid
Following example demonstrates how to delete ROSBag Blob
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.delete_rosbag_blob('blob-id')
- download_rosbag_blob(guid, filename=None, download_dir=None)¶
Download rosbag bag file
Following example demonstrates how to download ROSBag Blob
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.download_rosbag_blob('blob-id', 'filename.bag')
- list_rosbag_blobs(guids=None, deployment_ids=None, component_instance_ids=None, job_ids=None, statuses=None, device_ids=None)¶
Get rosbag blobs based on the passed query params
- Parameters
- Returns
list(
ROSBagBlob
)
- Following example demonstrates how to stop ROSBag Blobs
- List specific ROSBagBlobs
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(guids=['blob-id'])
- List all ROSBagBlobs of a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(deployment_ids=['dep-id'])
- List ROSBagBlobs of a deployment’s component instance
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(component_instance_ids=['dep-id'])
- List all ROSBagBlobs of a job
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(job_ids=['job-id'])
- List ROSBagBlobs with statuses
>>> from rapyuta_io import Client >>> from rapyuta_io.clients.rosbag import ROSBagBlobStatus >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(statuses=[ROSBagBlobStatus.UPLOADED])
- List ROSBagBlobs of a device
>>> from rapyuta_io import Client >>> from rapyuta_io.clients.rosbag import ROSBagBlobStatus >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(device_ids=['device-id'])
- list_rosbag_jobs(deployment_id, component_instance_ids=None, guids=None, statuses=None)¶
Get rosbag jobs based on the passed query params
- Parameters
- Returns
list(
ROSBagJob
)
- Following example demonstrates how to get ROSBag Jobs
- List all ROSBagJobs of a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs(deployment_id)
- List ROSBagJobs of a deployment’s component instance
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs(deployment_id, ... component_instance_ids=['comp-inst-id'])
- List specific ROSBagJobs of a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs(deployment_id, guids=['job-id'])
- List ROSBagJobs with statuses of a deployment
>>> from rapyuta_io import Client >>> from rapyuta_io.clients.rosbag import ROSBagJobStatus >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs(deployment_id, ... statuses=[ROSBagJobStatus.RUNNING])
- list_rosbag_jobs_in_project(device_ids)¶
Lists rosbag jobs based on device ids
- Following example demonstrates how to list rosbag jobs in a project based on device ids:
- List all ROSBagJobs based on device ids
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs_in_project(['device-id'])
- stop_rosbag_jobs(deployment_id, component_instance_ids=None, guids=None)¶
Stop ROSBag Job based on the passed query params
- Parameters
- Following example demonstrates how to stop ROSBag Jobs
- Stop all ROSBagJobs of a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.stop_rosbag_jobs(deployment_id)
- Stop ROSBagJobs of a deployment’s component instance
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.stop_rosbag_jobs(deployment_id, component_instance_ids=['comp-inst-id'])
- Stop specific ROSBagJobs of a deployment
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> client.stop_rosbag_jobs(deployment_id, guids=['job-id'])
Rosbag Module¶
- class ComponentType(value)¶
Enumeration variables for the ComponentType for ROSBag Job.
ComponentType.CLOUD
ComponentType.DEVICE
- class MessageType¶
Message Type
- class OverrideOptions¶
Override Options
- Variables
topic_override_info (
TopicOverrideInfo
) – List of topics to override with override specsexclude_topics (list(str)) – Topics to exclude from being recorded
- class ROSBagBlob¶
ROSBag file class
- Variables
guid (str) – bag id
filename (str) – filename of bag file
job_id (str) – job id
job (
ROSBagJob
) – related job informationblob_ref_id (int) – blob id
status (
ROSBagBlobStatus
) – upload status of bag fileinfo (
ROSBagInfo
) – info about the bag filecreator (str) – user id
project (str) – project id
component_type (
ComponentType
) – component typedevice_id (str) – device id
error_message (str) – reason for upload failure
- delete()¶
Delete the rosbag blob using the rosbag blob object.
Following example demonstrates how to delete a rosbag blob using rosbag blob object:
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_blobs = client.list_rosbag_blobs(deployment_ids=['dep-id']) >>> blob = rosbag_blobs[0] >>> blob.delete()
- refresh()¶
Fetches the updated resource from the server, and adds/updates object attributes based on it.
- Raises
APIError
: If the api returns an error, the status code is anything other than 200/201
- retry_upload()¶
Retry upload for a Device ROSBagBlob with Error status.
Following example demonstrates how to retry upload for a ROSBagBlob, and then wait for it to go to Uploaded/Error:
>>> from rapyuta_io import Client >>> client = Client(auth_token='auth_token', project='project_guid') >>> blobs = client.list_rosbag_blobs(statuses=[ROSBagBlobStatus.ERROR]) >>> blobs[0].retry_upload() >>> blobs[0].poll_till_ready()
- class ROSBagBlobStatus(value)¶
Enumeration variables for the Supported ROSBag Blob Status. File Status may be ‘Starting’, ‘Uploading’, ‘Uploaded’, or ‘Error’
ROSBagBlobStatus.STARTING
ROSBagBlobStatus.UPLOADING
ROSBagBlobStatus.UPLOADED
ROSBagBlobStatus.ERROR
- class ROSBagCompression(value)¶
Enumeration variables for the Supported ROSBag Compression. Compression may be ‘LZ4’, or ‘BZ2’
ROSBagCompression.LZ4
ROSBagCompression.BZ2
- class ROSBagInfo¶
ROSBag file related information
- Variables
bag_version (str) – version of bag file
duration (float) – total record time
start_time (float) – record start time
end_time (float) – record end time
size (int) – size of bag file
message_count (int) – number of messages
compression (str,) – compression used
uncompressed_size (int) – size of bag file without compression
compressed_size (int) – size of bag file with compression
message_types (list(
MessageType
)) – instance of MessageTypetopics (list(
TopicInfo
)) – instance of TopicInfo
- class ROSBagJob(name, rosbag_options, deployment_id=None, component_instance_id=None, upload_options=None, override_options=None)¶
ROSBag Job
- Variables
guid (str) – guid of the job
deployment_id (str) – deployment id
component_instance_id (str) – component instance id
name (str) – name of the job
package_id (str) – package id
status (
ROSBagJobStatus
) – status of the jobcomponent_id (str) – component id
component_type (
ComponentType
) – component typedevice_id (str) – device id
creator (str) – user id
project (str) – id
rosbag_options (
ROSBagOptions
) – rosbag optionsupload_options (
UploadOptions
) – Rosbag Upload Options, required in case of Device jobs
- Parameters
name (str) – name of the job
rosbag_options (
ROSBagOptions
) – rosbag optionsdeployment_id (str) – deployment id
component_instance_id (str) – component instance id
upload_options (
UploadOptions
) – Rosbag Upload Options, required in case of Device ROSBagJob
- patch(upload_type=None, on_demand_options=None)¶
Patches the rosbag job
- Parameters
upload_type –
ROSBagUploadTypes
on_demand_options –
ROSBagOnDemandUploadOptions
- Raises
APIError
: If the api returns an error, the status code is anything other than 200
Following example demonstrates how to patch a ROSBag Job.
>>> from rapyuta_io import Client >>> from rapyuta_io.clients.rosbag import ROSBagUploadTypes, ROSBagOnDemandUploadOptions, ROSBagTimeRange >>> client = Client(auth_token='auth_token', project='project_guid') >>> rosbag_jobs = client.list_rosbag_jobs('deployment-id', guids=['job-guid']) >>> on_demand_opts = ROSBagOnDemandUploadOptions( ... ROSBagTimeRange(from_time=0, to_time=0) ... ) >>> rosbag_jobs[0].patch(ROSBagUploadTypes.ON_STOP, on_demand_opts)
- class ROSBagJobStatus(value)¶
Enumeration variables for the Supported ROSBag Job Status. Job Status may be ‘Starting’, ‘Running’, ‘Error’, ‘Stopping’, or ‘Stopped’
ROSBagJobStatus.STARTING
ROSBagJobStatus.RUNNING
ROSBagJobStatus.ERROR
ROSBagJobStatus.STOPPING
ROSBagJobStatus.STOPPED
- class ROSBagOnDemandUploadOptions(time_range: rapyuta_io.clients.rosbag.ROSBagTimeRange)¶
ROSBagOnDemandUploadOptions represents the options for a rosbag job with an upload type of OnDemand
- Variables
time_range (
ROSBagTimeRange
) – The time range within which all the rosbags recorded are uploaded
- class ROSBagOptions(all_topics=None, topics=None, topic_include_regex=None, topic_exclude_regex=None, max_message_count=None, node=None, compression=None, max_splits=None, max_split_size=None, chunk_size=None, max_split_duration=None)¶
ROSBag options
- Variables
all_topics (bool) – Record all topics
topics (list(str)) – Record a bag file with the contents of the specified topics
topic_include_regex (list(str)) – Match topics using regular expressions
topic_exclude_regex (str) – Exclude topics matching the given regular expression
max_message_count (int) – Only record NUM messages on each topic
node (str) – Record all topics subscribed to by a specific node
compression (
ROSBagCompression
) – Compression can be LZ4 or BZ2max_splits (int) – Split bag at most MAX_SPLITS times
max_split_size (int) – Record a bag of maximum size
chunk_size (int) – Record to chunks of size KB before writing to disk
max_split_duration (int) – Specify the maximum duration (in minutes) of the recorded bag file
- Parameters
all_topics (bool) – Record all topics
topics (list(str)) – Record a bag file with the contents of the specified topics
topic_include_regex (list(str)) – Match topics using regular expressions
topic_exclude_regex (str) – Exclude topics matching the given regular expression
max_message_count (int) – Only record NUM messages on each topic
node (str) – Record all topics subscribed to by a specific node
compression (
ROSBagCompression
) – Compression can be LZ4 or BZ2max_splits (int) – Split bag at most MAX_SPLITS times
max_split_size (int) – Record a bag of maximum size
chunk_size (int) – Record to chunks of size KB before writing to disk
max_split_duration (int) – Specify the maximum duration (in minutes) of the recorded bag file.
- class ROSBagTimeRange(from_time: int, to_time: int)¶
ROSBagTimeRange represents the time range within which all the rosbags recorded are uploaded
- Ivar
from_time: rosbags recorded after or at this time are uploaded
- Vartype
from_time: int
- Ivar
to_time: rosbags recorded before or at this time are uploaded
- Vartype
to_time: int
- class ROSBagUploadTypes(value)¶
An enumeration.
- class TopicInfo¶
Topic related information
- class TopicOverrideInfo(topic_name=None, record_frequency=None, latched=None)¶
Topic Override Info
- class UploadOptions(max_upload_rate=1048576, purge_after=False, upload_type=ROSBagUploadTypes.ON_DEMAND, on_demand_options=None)¶
ROSBag Upload Options
- Variables
max_upload_rate (int) – Upload Rate in Bytes for ROSBag Files
purge_after (bool) – Purge File after uploaded
upload_type (
ROSBagUploadTypes
) – The type of upload for a rosbag jobon_demand_options (
ROSBagOnDemandUploadOptions
) – The options for a rosbag job with an upload type of OnDemand
- Parameters
max_upload_rate (int) – Upload Rate in Bytes for ROSBag Files
purge_after (bool) – Purge File after uploaded
upload_type (
ROSBagUploadTypes
) – The type of upload for a rosbag job